Repository navigation
Conversation
Record patch embedding, vision, prefix encoding and all denoising steps through the shared model traversal with persistent native buffers and CPU input/output staging. Keep Metal kernels grouped by operation and precision under csrc/apple, with Pi0.5 assembly in the model layer. Add opt-in SDK/CMake builds, exact dylib export checks, descriptor guards, full-pipeline parity benchmarks and Metal trace/GEMM diagnostics. Validation on Apple M5 Pro, macOS 27.0.1, PyTorch 2.14.1: - SDK and CMake builds; 7 CTest and 120 Python tests passed. - 16 CPU/MPS configurations match the current HEAD traversal bit-exactly. - Real BF16 checkpoint: M=522 parity across 29 probes, direct/ICB replay and frontend; M=661/659 full inference and CPU reference passed. CUDA/RDNA devices and independent OpenPI task success were not evaluated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an opt-in BF16 Metal pipeline that records patch embedding, vision, projector, prefix encoding and all denoising steps into one reusable ICB. Plan construction reuses the existing Pi0.5 model traversal; replay uses persistent buffers with fixed shapes and bindings.
The replay backend uses Metal indirect command buffers (ICBs) because this workload is already lowered to custom Metal kernels with fixed buffer bindings, launch geometry and dependencies. ICBs let us encode those commands once and execute them repeatedly. The current runtime submits the recorded ICB range through a new command buffer for each inference, avoiding per-kernel host encoding while preserving explicit kernel and memory ownership. Apple's documentation describes both ICB command reuse and the CPU encoding/replay model.
MPSGraph represents tensor operations as a symbolic graph and compiles that graph into an executable. Using it here would require a graph-backend lowering and validation of its layouts, kernels and numerical behavior. ICB supplies command replay for the existing custom-kernel path; it does not perform graph-level fusion or automatically apply MPSGraph/MLX compilation optimizations. Kernel dependencies and execution stalls can still remain inside an ICB. Graph compilation and command replay address different parts of the optimization problem.
csrc/apple/, including TensorOps GEMM, D72 vision attention, split decode attention and merged encoder gate/up GEMM.Validated on Apple M5 Pro, 24 GiB, macOS 27.0.1, macOS SDK 27.0, Apple Clang 21, Python 3.12.14 and PyTorch 2.14.1:
Short paired measurements used BF16, two camera views, prefix M=522, decode M=10, 10 denoising steps, three warmups and five timed iterations:
These measure prepared-input execution: native includes CPU input upload and CPU action output; Torch uses MPS tensor inputs/outputs. Image preprocessing, tokenization and action unnormalization are excluded. These results describe the complete native path, not an isolated speedup from copy removal.
Reproduction commands, with local checkpoint/tokenizer paths supplied:
Checkpoint:
Fisher-Wang/pi05-libero-pytorch, revisionab107fbe6661e8abfec0f13dc27bfd3fafe24c69. M=522 uses a truncated prompt for shape qualification. Accuracy checks compare shared model providers; independent OpenPI/LIBERO task-success evaluation and CUDA/RDNA device validation are outside this validation.