Repository navigation
mxfp4 support for qwen3.5 - #576
Conversation
Signed-off-by: ganyi <[email protected]>
Signed-off-by: ganyi <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR updates Qwen3 Next MoE routing to support MXFP4 scenarios where shared experts may run at a different dtype than routed experts, and adjusts the ROCm AITER shared-expert fusion gating logic accordingly.
Changes:
- Split merged gate logits into routed-expert logits vs shared-expert gate logits when shared-expert fusion is disabled, and apply the shared gate explicitly in
Qwen3NextSparseMoeBlock.forward(). - Update
is_rocm_aiter_fusion_shared_expert_enabled()to disable fusion when shared experts’ resolved dtype differs from the global quant dtype.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
atom/models/qwen3_next.py |
Uses merged gate output to separately route experts and gate the shared expert when fusion is disabled. |
atom/model_ops/topK.py |
Changes the heuristic that decides whether shared experts can be fused into the AITER MoE kernel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Resolve actual dtypes for shared experts vs routed experts. | ||
| # Find a representative shared expert entry from the exclude list to | ||
| # get its resolved dtype, then compare against the global quant spec | ||
| # (which represents the dtype of non-excluded routed experts). | ||
| # We cannot use a fixed probe prefix because the exclude list format | ||
| # changes after remap_layer_name (native vs plugin mode, packed_modules | ||
| # remap). Instead, pick the first exclude entry that mentions | ||
| # "shared_expert" and resolve its dtype via get_layer_quant_config. | ||
| exclude_layers = quant_config.exclude_layers or [] | ||
| for layer in exclude_layers: | ||
| if "shared_experts" in layer: | ||
| is_shared_experts_excluded = True | ||
| if "experts" in layer and "shared_experts" not in layer: | ||
| is_experts_excluded = True | ||
| # don't fuse shared experts if they don't share the same quantization | ||
| if is_shared_experts_excluded != is_experts_excluded: | ||
| return False | ||
| for entry in exclude_layers: | ||
| if "shared_experts" in entry or "shared_expert" in entry: | ||
| shared_spec = quant_config.get_layer_quant_config(entry) | ||
| # Compare shared expert dtype against the global (routed) dtype. | ||
| # If they differ, shared experts cannot be fused into the MoE | ||
| # kernel (e.g. shared experts are BF16 while routed are FP4). | ||
| if shared_spec.quant_dtype != quant_config.quant_dtype: | ||
| return False |
There was a problem hiding this comment.
is_rocm_aiter_fusion_shared_expert_enabled() calls quant_config.get_layer_quant_config(entry) where entry is an exclude pattern, not an actual layer name. This mis-resolves the dtype for regex-style excludes (e.g. re:model\.layers\..*shared_expert.*), and can incorrectly return True (allowing fusion) even when shared experts are excluded and thus BF16. Treating an exclude entry as a layer name is unreliable; instead, if a shared-expert exclude is present, compare quant_config.torch_dtype vs quant_config.quant_dtype (or probe with a real shared-expert layer name) and disable fusion when they differ.
| exclude_layers = quant_config.exclude_layers or [] | ||
| for layer in exclude_layers: | ||
| if "shared_experts" in layer: | ||
| is_shared_experts_excluded = True | ||
| if "experts" in layer and "shared_experts" not in layer: | ||
| is_experts_excluded = True | ||
| # don't fuse shared experts if they don't share the same quantization | ||
| if is_shared_experts_excluded != is_experts_excluded: | ||
| return False | ||
| for entry in exclude_layers: | ||
| if "shared_experts" in entry or "shared_expert" in entry: | ||
| shared_spec = quant_config.get_layer_quant_config(entry) | ||
| # Compare shared expert dtype against the global (routed) dtype. | ||
| # If they differ, shared experts cannot be fused into the MoE | ||
| # kernel (e.g. shared experts are BF16 while routed are FP4). | ||
| if shared_spec.quant_dtype != quant_config.quant_dtype: | ||
| return False | ||
| break |
There was a problem hiding this comment.
This logic no longer guards against the case where routed experts are excluded (BF16) but shared experts are not. In that configuration quant_config.quant_dtype still reflects the global quant spec (e.g. FP4), so fusion could be enabled even though routed experts are not actually quantized to that dtype. Consider also detecting routed-expert exclusions (or otherwise deriving the routed-expert resolved dtype) before returning True.
| # Apply shared expert gate: the merged gate output contains | ||
| # [routed_logits, shared_expert_gate_logits], extract the tail | ||
| shared_gate_logits = logits[:, self.n_routed_experts :] | ||
| shared_output = F.sigmoid(shared_gate_logits) * shared_output |
There was a problem hiding this comment.
New code adds another use of F.sigmoid(...) even though this file already uses torch.sigmoid(...) elsewhere. torch.nn.functional.sigmoid is deprecated and this increases inconsistency; prefer torch.sigmoid here (and ideally align the other call site as well).
| shared_output = F.sigmoid(shared_gate_logits) * shared_output | |
| shared_output = torch.sigmoid(shared_gate_logits) * shared_output |
| if not is_rocm_aiter_fusion_shared_expert_enabled(): | ||
| router_logits = logits[:, : self.n_routed_experts] | ||
| else: | ||
| router_logits = logits | ||
| routed_output = self.experts( | ||
| hidden_states=hidden_states, router_logits=router_logits | ||
| ) | ||
| if not is_rocm_aiter_fusion_shared_expert_enabled(): |
There was a problem hiding this comment.
is_rocm_aiter_fusion_shared_expert_enabled() is called three times in this method. Since it’s used as a mode switch for slicing logits and applying the shared expert path, caching it in a local fuse_shared = ... variable would avoid repeated global config lookups and make it harder for the branches to diverge during future edits.
| if not is_rocm_aiter_fusion_shared_expert_enabled(): | |
| router_logits = logits[:, : self.n_routed_experts] | |
| else: | |
| router_logits = logits | |
| routed_output = self.experts( | |
| hidden_states=hidden_states, router_logits=router_logits | |
| ) | |
| if not is_rocm_aiter_fusion_shared_expert_enabled(): | |
| fuse_shared = is_rocm_aiter_fusion_shared_expert_enabled() | |
| if not fuse_shared: | |
| router_logits = logits[:, : self.n_routed_experts] | |
| else: | |
| router_logits = logits | |
| routed_output = self.experts( | |
| hidden_states=hidden_states, router_logits=router_logits | |
| ) | |
| if not fuse_shared: |
Reverts f2ca56a. A same-process paired A/B on the issue #576 SGLang command shows no TTFT gain from the one-launch track snapshot over the eager index_put + SGLang `_track_mamba_state_extend` (numbers in the PR). The eager path keeps the copies in SGLang's own helper, so a change in its track metadata cannot silently diverge in ATOM. Co-authored-by: Cursor <[email protected]>
…3422) * perf(sglang/gdn): park the ReplaySSM cursor once per prefill forward A prefill rewrites each request's GDN checkpoint, so the plugin parks the ring cursor of its slot at 0. It did so at the end of every GDN layer, and `slot_idx[slot_idx >= 0]` reads the live-slot count back to the host, so a Qwen3.8-Flash prefill (36 GDN layers) took 36 blocking D2H reads, each one draining the GPU queue before the host could launch the next layer. The cursor is one per slot, shared by every layer, and nothing reads it during an extend forward. Park it once per forward in `SGLangGDNForwardContext._build_gdn_metadata`, the counterpart of Native's `GDNAttentionMetadataBuilder._attach_replayssm`, and route pad rows to a spare trailing entry instead of filtering them with a boolean mask, so the reset issues no host read. The parked value stays 0 and the slots are the same rows of SGLang's `mamba_cache_indices`. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): take the extend token count from SGLang's host metadata `_build_gdn_metadata` sized the extend metadata with `int(query_start_loc[-1].item())`, one blocking D2H per prefill. `HybridLinearAttnBackend._forward_metadata` builds that same `query_start_loc` from `extend_start_loc` / `extend_seq_lens` and stores the host sum of `extend_seq_lens_cpu` next to it as `logical_num_tokens`, which is the same number. Use it, and keep the device read only when SGLang left it unset or the metadata had to be reconstructed. Co-authored-by: Cursor <[email protected]> * perf(sglang/qwen4-exp): skip FlashInfer MHA extend tables under native QSA `ATOMAttnBackendForSgl.init_forward_metadata` already skipped the MHA tables for TARGET_VERIFY and draft-extend under native QSA, but an extend still went through `_init_extend_mha`. That gathers `kv_indices` over the whole context and syncs on `kv_indices[token_num:]` in SGLang's `AiterIndicesUpdaterPrefill`, once for the target prefill and once more for the draft prefill (the draft runner's extend), and QSA reads none of it: the QSA layers take their tables from the plugin's QSA metadata, and no other reader of this backend's `forward_metadata` runs during an extend. Take the same placeholder for every extend. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): write radix-track extend snapshots in one launch The mamba radix cache extend snapshot per GDN layer was a conv-window gather + index_put in the plugin, then h[src] + cast + index_put (and a slot-to-slot copy for aligned rows) in SGLang's _track_mamba_state_extend: five to seven small kernels per layer per prefill. write_radix_track_snapshots performs the same copies from the same SGLang track metadata in one Triton launch, addressing every tensor by its real strides (transposed conv pool, VK SSM view, column slice of the fused projection) and casting h to the pool dtype as the eager path does. Recompute rows (Mamba2 only), non-4-D h and CPU tensors keep the eager path. SGLang is not modified. Tests compare the pools bit for bit against the eager path across pool views and target mixes, and check the single launch. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): split the radix-track launch into a per-forward plan The track rows, their slots, the conv window length and the grid's row count of write_radix_track_snapshots come from SGLang's forward metadata and are the same for every GDN layer of a forward. RadixTrackPlan holds that half (built once per forward by the caller); write() adds the layer's conv input, pools and chunk states and launches the same kernel with the same arguments. write_radix_track_snapshots keeps its signature and now builds a plan and writes it. fused_track_metadata_supported is the metadata half of fused_track_supported, so a forward can decide it once. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): derive the GDN wrapper's per-layer state once per forward After its compute every SGLangGatedDeltaNet layer re-derived the same forward-level state: the forward mode, the SGLang attention backend and its linear child, the track metadata, the conv destination slots and the radix-track launch arguments, and it asked SGLang's mamba pool for its layer views, which builds a new MambaPool.State dataclass on every call (at_layer_idx). The forward-context binder asked for all of them again. - _GDNStep: built once in SGLangGDNForwardContext.build from the same forward batch and linear backend, published by bind for that forward batch. A layer whose forward batch has a step takes _track_extend, which only pops its chunk states and writes the precomputed RadixTrackPlan. Unusual metadata (recompute rows, missing SSM indices or conv slots), decode, and forwards without a step keep the per-layer path. - _mamba_layer_cache: a layer's mamba2_layer_cache views are reused while the pool holds the same state object and layer map. Only SGLang's own HybridReqToTokenPool / MambaPool.State accessor is cached, and never with a HiCache transfer counter, whose per-layer wait lives in the accessor. _build_kv_cache_tensors reuses its KVCacheTensors on the same terms. Same reads, same kernels, same arguments; the pools are written byte for byte as before. Co-authored-by: Cursor <[email protected]> * test(sglang/gdn): cover the forward-level GDN step and the pool view reuse - test_sglang_gdn_layer_step.py (CPU): layer views are reused while the SGLang pool keeps its state object and are rebuilt for a new one; a HiCache transfer counter, a foreign pool or an overridden accessor asks every time; the binder's KV tensors are the views SGLang builds; which forwards get a precomputed plan and which keep the per-layer path; a layer only uses the step of its own forward batch; bind scopes the step. - test_sglang_gdn_radix_track_fused.py (GPU): the forward-level path writes the same bytes as the per-layer path over several layers that share one step, and a reused plan matches the one-shot call. Co-authored-by: Cursor <[email protected]> * test(sglang/gdn): give the fused-track test's mode stub is_target_verify Co-authored-by: Cursor <[email protected]> * revert(sglang/gdn): drop the radix-track plan and the GDN step from this PR Reverts f12cdd0, 723ade6, a662c62 and 4980bc0. The radix-track plan (S3) only exists to feed the fused track kernel, which leaves this PR in the next commit. The forward-level GDN step and the pool view reuse (S4/S6) move to #3433 on the eager track path. Co-authored-by: Cursor <[email protected]> * revert(sglang/gdn): drop the fused radix-track kernel Reverts f2ca56a. A same-process paired A/B on the issue #576 SGLang command shows no TTFT gain from the one-launch track snapshot over the eager index_put + SGLang `_track_mamba_state_extend` (numbers in the PR). The eager path keeps the copies in SGLang's own helper, so a change in its track metadata cannot silently diverge in ATOM. Co-authored-by: Cursor <[email protected]> * fix(sglang/gdn): park the ReplaySSM cursor on the reconstructed-metadata path too The extend park read the live slots before the reconstruct_linear_metadata fallback, so a forward without SGLang's GDN metadata never parked the cursor (as on main). Take the slots after the fallback, and import sglang lazily in the park test like the other plugin tests. Co-authored-by: Cursor <[email protected]> * fix(sglang/gdn): read SGLang's logical_num_tokens instead of probing for it `_build_gdn_metadata` took the extend token count from `getattr(fm, "logical_num_tokens", None)` and fell back to `query_start_loc[-1].item()`. `logical_num_tokens` is a declared `ForwardMetadata` field (SGLang v0.5.21 on; the release image runs v0.5.22), and SGLang sets it for every extend, so the probe only hid a too-old SGLang and would quietly bring back the sync this PR removes. Read `fm.logical_num_tokens` in the branch that has SGLang's metadata. Only the `reconstruct_linear_metadata` path, which has no host count, still reads `query_start_loc[-1]` back. `live_slots = idx` is assigned once, after the branch. The test stand-ins for `ForwardMetadata` now carry the field, set to what SGLang computes for them. The token-count test's second case is the reconstructed path instead of an unset field. Co-authored-by: Cursor <[email protected]> * refactor(sglang/gdn): drop the None slot path of note_full_state_write Its only caller, the extend branch of `_build_gdn_metadata`, always has the slot tensor. The per-layer `_verify_cache_slots` that could return None went away with the per-layer park. Co-authored-by: Cursor <[email protected]> * test(sglang/gdn): pin which forward modes park the ReplaySSM cursor The removed per-layer `is_draft_extend_v2()` guard now rests on SGLang's `is_extend()` leaving DRAFT_EXTEND_V2 out. The mode test covers that case, and MIXED as a mode that parks. The module docstring no longer points at Native's `_attach_replayssm`, which parks at -1 with a boolean mask; `note_full_state_write` already says why the plugin parks at 0. Co-authored-by: Cursor <[email protected]> * test(sglang/qwen4-exp): import ForwardMode lazily in the native-QSA skip test Same as the ReplaySSM prefill test: the other plugin tests import SGLang inside the test, not at module level. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: root <[email protected]>
…f transposing h (#3432) * perf(sglang/gdn): park the ReplaySSM cursor once per prefill forward A prefill rewrites each request's GDN checkpoint, so the plugin parks the ring cursor of its slot at 0. It did so at the end of every GDN layer, and `slot_idx[slot_idx >= 0]` reads the live-slot count back to the host, so a Qwen3.8-Flash prefill (36 GDN layers) took 36 blocking D2H reads, each one draining the GPU queue before the host could launch the next layer. The cursor is one per slot, shared by every layer, and nothing reads it during an extend forward. Park it once per forward in `SGLangGDNForwardContext._build_gdn_metadata`, the counterpart of Native's `GDNAttentionMetadataBuilder._attach_replayssm`, and route pad rows to a spare trailing entry instead of filtering them with a boolean mask, so the reset issues no host read. The parked value stays 0 and the slots are the same rows of SGLang's `mamba_cache_indices`. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): take the extend token count from SGLang's host metadata `_build_gdn_metadata` sized the extend metadata with `int(query_start_loc[-1].item())`, one blocking D2H per prefill. `HybridLinearAttnBackend._forward_metadata` builds that same `query_start_loc` from `extend_start_loc` / `extend_seq_lens` and stores the host sum of `extend_seq_lens_cpu` next to it as `logical_num_tokens`, which is the same number. Use it, and keep the device read only when SGLang left it unset or the metadata had to be reconstructed. Co-authored-by: Cursor <[email protected]> * perf(sglang/qwen4-exp): skip FlashInfer MHA extend tables under native QSA `ATOMAttnBackendForSgl.init_forward_metadata` already skipped the MHA tables for TARGET_VERIFY and draft-extend under native QSA, but an extend still went through `_init_extend_mha`. That gathers `kv_indices` over the whole context and syncs on `kv_indices[token_num:]` in SGLang's `AiterIndicesUpdaterPrefill`, once for the target prefill and once more for the draft prefill (the draft runner's extend), and QSA reads none of it: the QSA layers take their tables from the plugin's QSA metadata, and no other reader of this backend's `forward_metadata` runs during an extend. Take the same placeholder for every extend. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): write radix-track extend snapshots in one launch The mamba radix cache extend snapshot per GDN layer was a conv-window gather + index_put in the plugin, then h[src] + cast + index_put (and a slot-to-slot copy for aligned rows) in SGLang's _track_mamba_state_extend: five to seven small kernels per layer per prefill. write_radix_track_snapshots performs the same copies from the same SGLang track metadata in one Triton launch, addressing every tensor by its real strides (transposed conv pool, VK SSM view, column slice of the fused projection) and casting h to the pool dtype as the eager path does. Recompute rows (Mamba2 only), non-4-D h and CPU tensors keep the eager path. SGLang is not modified. Tests compare the pools bit for bit against the eager path across pool views and target mixes, and check the single launch. Co-authored-by: Cursor <[email protected]> * fix(sglang/gdn): keep only the most recent FlyDSL prefill schedules `_flydsl_prefill_metadata` memoizes AITER GDN prefill schedules by (lengths, query_start_loc data_ptr, _version). An AITER schedule holds a strong reference to its offset tensor and is only usable with that exact, unmodified tensor, outside graph capture. SGLang builds a fresh query_start_loc for every eager extend, so every prefill forward added an entry that could never hit again and pinned three small device tensors for the lifetime of the server. Bound the memo to the 8 most recently used entries, the same policy as FLA's `tensor_cache`. Reuse of an unchanged buffer still hits; an evicted entry only drops the cache's reference, the in-flight forward keeps its own. Co-authored-by: Cursor <[email protected]> * perf(gdn): run FlyDSL GDN prefill under ReplaySSM `select_policy` turned off both FlyDSL GDN stages once ReplaySSM was on, so every MTP deployment (ReplaySSM defaults on with speculative decoding, Native and SGLang alike) fell back to the Triton chunked prefill. Only FlyDSL decode conflicts with ReplaySSM: it needs the state pool stored as VK, while the ReplaySSM kernels address a contiguous KV checkpoint. FlyDSL prefill reads the initial state through the pool's strides, returns the final state as a logical KV view that the layer writes back with the same index_copy_ as the Triton path, and writes no records, so it leaves exactly the checkpoint ReplaySSM expects. Keep decode off under ReplaySSM and let prefill follow ATOM_GDN_PREFILL_BACKEND as it does without the ring: drop the ReplaySSM gates in select_policy, the Native GDN layer and Qwen4Exp finish_prefill. The SGLang plugin picks the policy up unchanged; its gfx942 gate stays. ATOM_GDN_PREFILL_BACKEND=triton restores the previous dispatch. Co-authored-by: Cursor <[email protected]> * perf(gdn): let write_state_checkpoints read a VK-stored h The checkpoint writer read `h` as contiguous KV and silently misread anything else. FlyDSL stores its chunk states VK, so its prefill copies the whole `h` (about 100 MB per layer at 8192 tokens, TP2) into KV only for this writer, and SGLang's radix track, to pick a few rows out of it. Take `h` as a logical [..., H, K, V] tensor stored KV or VK, read off its strides the way the pool's layout already is (STATE_VK). When `h` and the pool store the state the same way, the copy walks storage order on both sides; otherwise it walks the KV side and remaps the other, as the RTP checkpoint writer does. Any other inner layout raises instead of being read as KV. KV sources (the Triton `h`, `h_snap`) take the same path as before. No caller passes a VK `h` yet; the FlyDSL wrapper follows separately. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): walk VK order in the radix-track kernel when h and pool are VK `write_radix_track_snapshots` already reads `h` by its real strides, so a view over FlyDSL's VK chunk states needs no change to be correct. With FlyDSL decode the SSM pool is VK as well, and walking logical KV order then strides both the read and the write. Walk VK order when both sides store VK: per launch 48 -> 12 us for one unaligned row, 96 -> 20 us for four (24 heads of 128x128, MI308X). Every other case, including every launch with a Triton `h`, keeps the existing order. Tests run the fused kernel and SGLang's eager helper on VK views of `h` bit for bit, including K != V. Co-authored-by: Cursor <[email protected]> * perf(gdn): hand out FlyDSL's chunk states as a KV view, not a copy `gdn_flydsl.prefill(..., keep_intermediate_states=True)` transposed the whole VK `h` into a contiguous KV copy in every GDN layer that keeps snapshots: SGLang's radix track and Native checkpoints, with or without MTP. That copy is 0.13 / 0.39 / 0.50 ms per layer at 2112 / 6336 / 8192 tokens (TP2, MI308X), and one more `h`-sized allocation at the peak. Both consumers now address `h` by its strides, so return `h.transpose(-1, -2)`, the logical KV view of the same storage, the way the final state is already returned: same shape, same values, same row per chunk boundary. `snapshot_layout="vk"` is unchanged, and the RTP wrapper, which asks for it, still gets the VK tensor itself. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): split the radix-track launch into a per-forward plan The track rows, their slots, the conv window length and the grid's row count of write_radix_track_snapshots come from SGLang's forward metadata and are the same for every GDN layer of a forward. RadixTrackPlan holds that half (built once per forward by the caller); write() adds the layer's conv input, pools and chunk states and launches the same kernel with the same arguments. write_radix_track_snapshots keeps its signature and now builds a plan and writes it. fused_track_metadata_supported is the metadata half of fused_track_supported, so a forward can decide it once. Co-authored-by: Cursor <[email protected]> * perf(sglang/gdn): derive the GDN wrapper's per-layer state once per forward After its compute every SGLangGatedDeltaNet layer re-derived the same forward-level state: the forward mode, the SGLang attention backend and its linear child, the track metadata, the conv destination slots and the radix-track launch arguments, and it asked SGLang's mamba pool for its layer views, which builds a new MambaPool.State dataclass on every call (at_layer_idx). The forward-context binder asked for all of them again. - _GDNStep: built once in SGLangGDNForwardContext.build from the same forward batch and linear backend, published by bind for that forward batch. A layer whose forward batch has a step takes _track_extend, which only pops its chunk states and writes the precomputed RadixTrackPlan. Unusual metadata (recompute rows, missing SSM indices or conv slots), decode, and forwards without a step keep the per-layer path. - _mamba_layer_cache: a layer's mamba2_layer_cache views are reused while the pool holds the same state object and layer map. Only SGLang's own HybridReqToTokenPool / MambaPool.State accessor is cached, and never with a HiCache transfer counter, whose per-layer wait lives in the accessor. _build_kv_cache_tensors reuses its KVCacheTensors on the same terms. Same reads, same kernels, same arguments; the pools are written byte for byte as before. Co-authored-by: Cursor <[email protected]> * test(sglang/gdn): cover the forward-level GDN step and the pool view reuse - test_sglang_gdn_layer_step.py (CPU): layer views are reused while the SGLang pool keeps its state object and are rebuilt for a new one; a HiCache transfer counter, a foreign pool or an overridden accessor asks every time; the binder's KV tensors are the views SGLang builds; which forwards get a precomputed plan and which keep the per-layer path; a layer only uses the step of its own forward batch; bind scopes the step. - test_sglang_gdn_radix_track_fused.py (GPU): the forward-level path writes the same bytes as the per-layer path over several layers that share one step, and a reused plan matches the one-shot call. Co-authored-by: Cursor <[email protected]> * test(sglang/gdn): give the fused-track test's mode stub is_target_verify Co-authored-by: Cursor <[email protected]> * test(sglang/gdn): run the forward-level track plan tests on a VK h too Co-authored-by: Cursor <[email protected]> * revert(sglang/gdn): drop the radix-track plan and the GDN step from this PR Reverts f12cdd0, 723ade6, a662c62 and 4980bc0. The radix-track plan (S3) only exists to feed the fused track kernel, which leaves this PR in the next commit. The forward-level GDN step and the pool view reuse (S4/S6) move to #3433 on the eager track path. Co-authored-by: Cursor <[email protected]> * revert(sglang/gdn): drop the fused radix-track kernel Reverts f2ca56a. A same-process paired A/B on the issue #576 SGLang command shows no TTFT gain from the one-launch track snapshot over the eager index_put + SGLang `_track_mamba_state_extend` (numbers in the PR). The eager path keeps the copies in SGLang's own helper, so a change in its track metadata cannot silently diverge in ATOM. Co-authored-by: Cursor <[email protected]> * fix(sglang/gdn): park the ReplaySSM cursor on the reconstructed-metadata path too The extend park read the live slots before the reconstruct_linear_metadata fallback, so a forward without SGLang's GDN metadata never parked the cursor (as on main). Take the slots after the fallback, and import sglang lazily in the park test like the other plugin tests. Co-authored-by: Cursor <[email protected]> * Limit ReplaySSM FlyDSL GDN prefill to gfx942; keep RTP-LLM on Triton Review follow-up for the ReplaySSM FlyDSL prefill switch: - select_policy enables FlyDSL prefill under ReplaySSM only on gfx942, where Native MTP GSM8K and TTFT were measured. Other arches keep the Triton prefill under ReplaySSM until they have the same data. Native and every select_policy caller get the gate. - RTP-LLM _configure_gdn_backends keeps Triton prefill when the metadata has replayssm set. RTP-LLM does not set it today, so its behaviour is unchanged. - Move the policy matrix to tests/test_gdn_flydsl_policy.py. It loads gdn_flydsl.py with Triton stubbed, so the non-GPU unit tests run it without AITER or Triton. Cover the gfx942 gate and the arch check. - Assert that finish_prefill builds the FlyDSL schedule with replayssm=True, and builds none when FlyDSL prefill is off. - GPU tests expect the gate on non-gfx942 devices. Co-authored-by: Cursor <[email protected]> * test(sglang/gdn): SGLang's eager radix track reads FlyDSL's KV view of h bit for bit Co-authored-by: Cursor <[email protected]> * refactor(gdn): no default for the checkpoint kernel's H_VK; drop a dead stride test `_copy_checkpoints_kernel` gave the new `H_VK` constexpr a default of False. Its only caller, `write_state_checkpoints`, always passes it, and a caller that left it out would read a VK-stored `h` as KV without an error. It now has no default; it moves ahead of the defaulted constexprs, and the launch passes every constexpr by keyword. `write_state_checkpoints` tested `h`'s inner strides for VK with an extra `!= (k * v, v, 1)` conjunct. That conjunct only changes the answer when K == V == 1, where the KV and VK layouts are the same and both index maps give the same address, so it goes, together with two redundant `tuple()` calls. The docstring no longer explains the refusal by what the writer used to do. No caller's checkpoint changes: KV sources (the Triton `h`, `h_snap`) still launch with H_VK=False and FlyDSL's view with H_VK=True. Co-authored-by: Cursor <[email protected]> * test(gdn): run the checkpoint writer's layout refusal in the pre-checkin gate `tests/test_gdn_flydsl_snapshot_layout.py` was meant as the CPU half of this PR's tests, but both of its cases `importorskip`ped Triton, and "Run non-GPU unit tests" has none: at 641c147 its log shows them as "SKIPPED ... GDN prefill requires Triton" and "... GDN checkpoints require Triton". So CI ran none of the PR's new tests. - The refusal of an `h` that is neither KV- nor VK-stored is host logic that runs before any launch. The test now loads `state_checkpoint.py` from its source with Triton stubbed for the import, the way `tests/test_gdn_flydsl_policy.py` loads `gdn_flydsl.py`, so the gate runs it. - The CPU check that the KV snapshot is a view of the kernel's storage is removed. It replaced every call inside `prefill` with a stub, looked the RTP wrapper up with `getattr`, and was skipped in CI too. The GPU test `test_flydsl_kv_snapshot_is_a_view_of_the_vk_snapshot` checks the same contract on the real FlyDSL kernel: same values, VK storage, same allocator peak. - A test docstring no longer describes the KV copy as what the view replaces. Checked with triton, aiter, flydsl and sglang made unimportable and no GPU visible: the new case passes, and it fails on the base tree, which has no check (the writer runs on to `triton.cdiv`). The old file, run the same way, reports the same two skips as CI. Co-authored-by: Cursor <[email protected]> * test(gdn): track strided snapshots through the frontend forward Give the eager-track test the full mamba pool state/index contract and exercise SGLangGatedDeltaNet.forward instead of its changing private track argument. Keep the real SGLang eager writer; only the unrelated base GDN compute is replaced with a supplied output and snapshot. This lets the same test exercise main and the forward-level step introduced by #3516 without adding a production shim or probing private signatures. * docs(gdn): require transpose views for VK checkpoints * docs: clarify GDN snapshot contract and add test licenses Address review 6041313871: add the requested MIT and copyright headers to the two new regression tests and identify RTP as the only raw-VK checkpoint consumer. The shared writer requires the default KV view. Validation: 3 files syntax-checked; executable AST unchanged; Black, Ruff, and diff checks pass; CPU snapshot-layout test: 1 passed. No GPU rerun for these license/docstring-only edits. --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: root <[email protected]>
Motivation
vllm acc:
vllm-atom acc
atom
vllm-atom script:
atom script
Technical Details
Test Plan
Test Result
Submission Checklist