Repository navigation
[executorch][muse] Verify CUDA DFlash drafts on device under any sampling - #23984
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23984
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 Unclassified FailuresAs of commit f6ae868 with merge base d46a886 ( UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
…l cache Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #23735 * #23734 * #23974 * #23973 * #23972 * #23971 * #23970 * #23969 * #23968 * #23967 * #23966 * #23965 * #23964 * #23963 * #23962 * #23961 * #23960 * #23959 * #23958 * #23985 * #23984 * #23983 * #23982 * #23981 * #23980 * #23979 * __->__ #23978 MLX batches DFlash drafts by packing every owner's new target context and query block into one noncausal draft step. Let the CUDA cell cache serve the same step so the CUDA DFlash executor can reuse the off-graph KV path. - CacheGeometry::dflash_block_size (already on main) now selects a packed draft layout on CUDA: context rows commit, query rows are scratch. - CudaCellCache prepares packed draft steps (declared context + block rows per owner) and lowers the noncausal mask the draft attends with. - lower_offgraph_kv / cuda_backend learn the draft step width spec. - Drop the "DFlash is unsupported on CUDA" builder guard. Differential Revision: D125705710 Pull Request resolved: #23978
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #23735 * #23734 * #23974 * #23973 * #23972 * #23971 * #23970 * #23969 * #23968 * #23967 * #23966 * #23965 * #23964 * #23963 * #23962 * #23961 * #23960 * #23959 * #23958 * #23985 * #23984 * #23983 * #23982 * #23981 * #23980 * __->__ #23979 * #23978 DFlash needs the target's verify rows and tapped hidden states from one forward without the executor's own sampling. Add a RawTargetStep / execute_raw API and argmax_rows to CudaExecutor, reusing its batch planning, step declaration and commit, so a model adapter can drive verification the way the MLX DFlash executor drives its target. Differential Revision: D125705711 Pull Request resolved: #23979
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #23735 * #23734 * #23974 * #23973 * #23972 * #23971 * #23970 * #23969 * #23968 * #23967 * #23966 * #23965 * #23964 * #23963 * #23962 * #23961 * #23960 * #23959 * #23958 * #23985 * #23984 * #23983 * #23982 * #23981 * __->__ #23980 * #23979 * #23978 Export a tapped target plus a packed draft_forward for CUDA batching, matching the MLX DFlash draft ABI: tokens[owners, block], hidden[1, C, H], positions[C + Q], order[C + Q] -> logits[1, Q, V]. block = n_draft + 1. - export_dflash.py: --use-offgraph-kv-cache with --backend cuda emits the packed draft over a draft cell cache (--draft-max-cells, --max-draft-owners). - export_solo.py: device residency and cache wiring for draft methods. - dflash_model.py: packed draft forward; cuda.py: hidden tapping for CUDA. Differential Revision: D125705712 Pull Request resolved: #23980
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #23735 * #23734 * #23974 * #23973 * #23972 * #23971 * #23970 * #23969 * #23968 * #23967 * #23966 * #23965 * #23964 * #23963 * #23962 * #23961 * #23960 * #23959 * #23958 * #23985 * #23984 * #23983 * #23982 * __->__ #23981 * #23980 * #23979 * #23978 Add the CUDA DFlash batching executor, structured like the MLX one: one batching::Executor that owns a target CudaExecutor and a draft cell cache and runs drain / draft / speculate / rewind per batch. Owners of any context length are co-batched; the target verifies every owner's candidates in one forward. backend_factory dispatches --dflash on CUDA to it (replacing the NotSupported guard), with the same MuseGlimmerBackendConfig and flags as MLX. Only d=16 / n=15 is supported for now. Differential Revision: D125705713 Pull Request resolved: #23981
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #23735 * #23734 * #23974 * #23973 * #23972 * #23971 * #23970 * #23969 * #23968 * #23967 * #23966 * #23965 * #23964 * #23963 * #23962 * #23961 * #23960 * #23959 * #23958 * #23985 * #23984 * #23983 * __->__ #23982 * #23981 * #23980 * #23979 * #23978 Snapshot the verification taps on device and copy only the accepted (committed) rows to the host, instead of every verified row, mirroring D125629666 for the batched CUDA path. Differential Revision: D125705714 Pull Request resolved: #23982
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #23735 * #23734 * #23974 * #23973 * #23972 * #23971 * #23970 * #23969 * #23968 * #23967 * #23966 * #23965 * #23964 * #23963 * #23962 * #23961 * #23960 * #23959 * #23958 * #23985 * #23984 * __->__ #23983 * #23982 * #23981 * #23980 * #23979 * #23978 After a verify, the emitted correction/bonus token is kept as pending instead of running a target preamble for it; the next decode drafts directly from it. This removes one target forward per speculation round, as on MLX. Differential Revision: D125705715 Pull Request resolved: #23983
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #23735 * #23734 * #23974 * #23973 * #23972 * #23971 * #23970 * #23969 * #23968 * #23967 * #23966 * #23965 * #23964 * #23963 * #23962 * #23961 * #23960 * #23959 * #23958 * __->__ #23985 * #23984 * #23983 * #23982 * #23981 * #23980 * #23979 * #23978 Export static draft_forward_{N} (N owners, at most one block of new context each) and capture them in CUDA graphs through the existing CudaExecutor graph option; longer contexts still drain through the dynamic draft_forward. Decode contexts are padded to the static shape with scratch rows the cache never commits. Pool growth recaptures like the target's static methods. Differential Revision: D125705719 Pull Request resolved: #23985
…ling (#24042) This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #23984 by @Gasoonjia ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/83/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/83/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/82/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/83/orig Differential Revision: [D125705716](https://our.internmc.facebook.com/intern/diff/D125705716/) @diff-train-skip-merge Co-authored-by: gasoonjia <[email protected]>
Stack from ghstack (oldest at bottom):
Export dflash_verify / dflash_verify_argmax: batched on-device acceptance of
every owner's drafts under that owner's temperature / top-k / top-p, with a
greedy fast path. Only token IDs return to the host. Uniforms come from
(seed, position, purpose) so results do not depend on batch composition.
Target preamble sampling also stays on device (CudaExecutor::sample_rows).
Differential Revision: D125705716