[executorch][muse-glimmer] Run DFlash sampling on CUDA - #22492
Open
Gasoonjia wants to merge 1 commit into
Open
Conversation
Gasoonjia
requested review from
kirklandsign and
larryliu0820
as code owners
September 2, 2026 20:37
This was referenced Sep 2, 2026
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22492
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit c1a4838 with merge base c65ad53 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
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.
Stack from ghstack (oldest at bottom):
Keep the CUDA DFlash decode loop device-resident instead of round-tripping activations and logits through the host.
Export embed_text, target_forward_from_embeddings, and target_prefill_from_embeddings device-in/device-out, and keep draft_forward logits on device. Draft sampling, target sampling, speculative acceptance, and correction then run through the CUDA sampling primitives on the model's shared stream, so a verification step never touches host memory. The candidate, probability, position-table, and token-staging buffers are preallocated before CUDA graph capture so replay stays valid.
A CUDA build always samples on device; there is no runtime switch. The host sampler is reached only by non-CUDA (MLX) builds, so the host speculative cycle, run_target_only_cycle, and the run_target token wrapper are guarded with #ifndef EXECUTORCH_BUILD_CUDA rather than left as unreachable code behind an unconditional return.
The verifier reuses the existing embed_text + target_forward_from_embeddings chain rather than adding a token-input target method: candidate tokens already live on the device, so embed_text consumes them in place and hands its embeddings straight to the target with no copy. The remaining host callers (prefill and the vision splice) stage their own inputs into the preallocated device buffers. Keeping a single target implementation means the CUDA and MLX paths decode through the same method, and it removes both the duplicate complete-target weight blob and the export-time blob surgery that used to omit it -- surgery that depended on runtime method load order and on the AOTI delegate payload's line shape.
Sampling stays a runtime primitive: no sampling method is added to the .pte, and the DFlash timing mechanism is unchanged.
Differential Revision: D117826290