Skip to content

perf(b12x): optimize SM121 TC-GEMV loads, DSMEM split-K, router split-K cap, and W4A8 PDL - #193

Merged
lukealonso merged 2 commits into
mainfrom
sm121-tc-gemv-dsmem-w4a8-pdl
Nov 30, 2026
Merged

lukealonso merged 2 commits into
mainfrom
sm121-tc-gemv-dsmem-w4a8-pdl

Conversation

@lukealonso

@lukealonso lukealonso commented Nov 30, 2026 •

Copy link
Copy Markdown

Why

Node-level nsys profiling of TP4 speculative decode (P = 4) on 4× DGX Spark (NVIDIA GB10, SM121, 48 SMs, 25.2 MB L2, 261.8 GB/s LPDDR5x) identified four concrete small-batch decode bottlenecks:

  1. sm120_dsmem_auto_enabled in _lib/utils/dsmem.py disabled DSMEM cluster split-K on SM121 (get_sm_version == 120 gate and single-wave cap), forcing 171 per-round cuMemsetD32Async flag clears and global workspace atomics on split-K GEMVs.
  2. MXFP8 TC-GEMV (_mxfp8_tc_gemv.py) and grouped WoA TC-GEMV (wo_projection/_tc_gemv.py) issued 128-bit ld.global.nc.v4.u32 loads (with has_side_effects=True in the shared intrinsic) without 256-bit L2::evict_first vectorization, reducing LPDDR5x read efficiency and polluting L2.
  3. BF16 TC-GEMV tuning allowed split_k = 16 (chunks_per_warp = 1, 16-way atomics) on the 384 × 5120 MoE router on 48-SM GPUs (~40 µs overlapped), and NVFP4 TC-GEMV gated evict_first to n >= 65536, missing TP4 draft LM heads (N = 32320, 93 MB).
  4. W4A8CompactMicro defaulted PDL off on SM121 despite lower cold-L2 latency with PDL enabled.

What Changed

  • SM121 DSMEM cluster split-K (flashinfer/experimental/b12x/_lib/utils/dsmem.py, callers, and tests/experimental/b12x/test_sm120_dsmem_splitk.py):
    • Enabled SM121 default-on multi-wave DSMEM cluster split-K (split_k in (2, 4), n_tiles == 1).
    • Added sm120_dsmem_auto_requires_single_wave(device) (returning get_sm_version(device) != 121) used by sm120_dsmem_auto_enabled and the 5 auto-DSMEM validation call sites, while keeping validate_launcher_dsmem_cluster(..., require_single_wave=True) strict on all SMs.
  • MXFP8 and Grouped WoA TC-GEMV loads (gemm/blockscaled/_mxfp8_tc_gemv.py, _tuning.py, gemm/wo_projection/_tc_gemv.py, _preparation.py, _tuning.py):
    • Added paired K = 128 256-bit L2::evict_first.v8.b32 weight loads (_ld_global_nc_evict_v8_u32 when use_pdl=False, coherent _ld_global_evict_v8_u32 with has_side_effects=True when use_pdl=True, matching _nvfp4_tc_gemv.py), non-volatile _ld_global_nc_v4_u32_ro for non-PDL v4 loads, preserved self.use_pdl coherence across weight, scale, and cos_sin loads, added wo_a_split_k = 4 to WoA tuning knobs, enabled SM121 wo_b sk_b = 2 DSMEM (k_b >= 2048), and bumped compile/tuning contract versions.
  • Small-SM BF16 router split-K cap and NVFP4 evict_first (gemm/bf16_gemv/_tuning.py, gemm/blockscaled/_nvfp4_tc_gemv.py):
    • Capped _tc_split_k_candidates on small-SM GPUs (sm_count <= 64, max_ctas = max(96, 2 * sm_count)), preventing split_k = 16 on the MoE router (candidate_contract_version = 19).
    • Lowered NVFP4 TC-GEMV evict_first threshold from n >= 65536 to (n * k // 2) >= (16 << 20) (version = 6).
  • W4A8CompactMicro SM121 PDL (moe/_shared/kernels/w4a8_compact_micro.py, moe/fused_moe/_tuning.py):
    • Defaulted PDL on for SM121 (get_sm_version(device_index) == 121, version = 41, candidate_contract_version = 75).

Claimed Benefit and Result

  • Isolated cold-L2 rotating CUDA-graph microbenchmarks on GB10 (SM121):
    • wo_a: 48.8 → 37.0 µs (233.8 GB/s, 89.3% SoL)
    • qkv_a: 52.3 → 42.3 µs (223.8 GB/s, 85.5% SoL)
    • wo_b: 51.4 → 43.7 µs (247.3 GB/s, 94.5% SoL)
    • q_b: 48.9 → 44.9 µs (240.7 GB/s, 91.9% SoL)
    • sh_up: 34.2 → 27.5 µs (220.9 GB/s)
    • BF16 router: 39.8 µs (overlapped, sk = 16) → 18.9 µs solo (sk = 2 DSMEM)
    • W4A8CompactMicro: 363.9 → 357.0 µs (M = 4), 517.2 → 511.8 µs (M = 6)
  • Combined-stack end-to-end 4× DGX Spark TP4 DeepSeek-V4.1-Flash serving (paired with the companion hyperflare-recipes defer_launch=True + exact survival changes and Helios scheduler PR):
    • Node-level nsys P = 4 median round period dropped 33.72 → 32.52 ms (-1.20 ms, min 31.15 → 30.34 ms), non-MoE time across 39 target layers dropped 17.01 → 15.68 ms (-1.33 ms), and split-K memsets dropped 171 → 4 per round (95.2 → 9.3 µs).
    • Matched-depth GPU round times across 5 live prompts dropped 1.5–2.2 ms (P = 1: 22.3–22.9 → 20.8 ms, P ≈ 4: 33.9–34.6 → 32.0–32.4 ms, P ≈ 5: 35.6–35.9 → 34.0–34.3 ms, P ≈ 6: 37.0–38.2 → 36.1 ms).

Supporting Evidence and Limitations

  • SM120 GPU contract, parity, and SASS verification: pytest tests/experimental/b12x/test_sm120_dsmem_splitk.py tests/experimental/b12x/test_sm120_decode_pdl.py — 27/27 passed, including cuobjdump PDL+DSMEM SASS ordering and zero-LDG.E.*.CONSTANT checks across all 5 TC-GEMV/WoA kernels, 0-ULP parity, delayed producer races, and SM121 auto-DSMEM / strict validator unit tests.
  • Numerical parity on GB10 (SM121): Verified across all 8 MXFP8 GEMV shapes and GroupedWoa with AUTO-DSMEM = True (cosine similarity 0.9999999–1.0000000, max abs error <= 0.0156). Back-to-back A/B verified v8.b32 with L2::evict_first faster by 1.0–2.2 µs than no-evict v8.b32 across all 6 tested shapes (qkv_a, q_b, wo_b, sh_up, sh_dn, GroupedWoa).
  • End-to-end export and live serving: Full 57-graph TP4 export (gb10-tp4-202611301553) and 5-prompt serving benchmark verified on 4× DGX Spark (prior to follow-up commit 8591bf45c, which leaves non-PDL SM121 PTX unchanged and makes PDL v8 loads coherent).
  • Limitations / unrun checks: SM120 / SM103 discrete GPU performance was not re-benchmarked; pre-existing failures in test_wo_projection.py (dense_gemm/kernel.py:4822 TYPE_UNSTABLE_JOIN on the untouched dense path) and test_bf16_gemv_search_levels.py (untouched split-K assertion) were observed independently of this diff.

Discord: lukealonso

…-K, and W4A8 PDL

Node-level nsys profiling of TP4 speculative decode on 4x DGX Spark
(NVIDIA GB10, SM121, 48 SMs, 261.8 GB/s LPDDR5x) showed four concrete
decode bottlenecks in small-batch dense GEMV and MoE kernels:
1. `sm120_dsmem_auto_enabled` disabled DSMEM cluster split-K on SM121,
   forcing ~120+ per-round `cuMemsetD32Async` flag clears and global
   workspace atomics on split-K GEMVs.
2. MXFP8 TC-GEMV (`_mxfp8_tc_gemv.py`) and grouped WoA TC-GEMV
   (`wo_projection/_tc_gemv.py`) issued 128-bit volatile loads with
   `coherent=self.use_pdl` on read-only weight and scale tensors,
   cutting LPDDR5x read efficiency and polluting L2.
3. BF16 GEMV tuning allowed `split_k=16` on small-SM GPUs for the
   384x5120 MoE router, causing 16-way atomic contention (~40 us
   overlapped), and NVFP4 TC-GEMV gated `evict_first` to `n >= 65536`,
   missing TP4 draft LM heads (`N=32320`).
4. `W4A8CompactMicro` defaulted PDL off on SM121 despite lower cold-L2
   latency with PDL enabled.

This change:
- Enables SM121 multi-wave DSMEM cluster split-K (`split_k in (2, 4)`,
  `n_tiles == 1`) in `_lib/utils/dsmem.py`.
- Switches MXFP8 TC-GEMV and GroupedWoa TC-GEMV read-only weight/scale
  loads to non-volatile 256-bit `ld.global.nc.L2::evict_first.v8.b32`
  paired K=128 loads (with non-volatile `ld.global.nc.v4.u32` odd-chunk
  tail and non-coherent weight/scale loads under PDL), adds
  `wo_a_split_k=4` and SM121 `wo_b` `sk_b=2` DSMEM in `wo_projection/`,
  and bumps compile/tuning contract versions.
- Caps BF16 TC-GEMV `split_k` candidates on small-SM GPUs (`sm_count <=
  64`, `max_ctas = max(96, 2 * sm_count)`) and lowers the NVFP4
  `evict_first` threshold to `(n * k // 2) >= 16 MiB`.
- Enables `W4A8CompactMicro` PDL by default on SM121.

Measured results on GB10 (SM121):
- Cold-L2 rotating CUDA-graph microbenchmarks: `wo_a` 48.8 -> 37.0 us
  (233.8 GB/s), `qkv_a` 52.3 -> 42.3 us (223.8 GB/s), `wo_b` 51.4 ->
  43.7 us (247.3 GB/s, 94.5% SoL), `q_b` 48.9 -> 44.9 us (240.7 GB/s),
  `sh_up` 34.2 -> 27.5 us, BF16 router 39.8 (overlapped) -> 18.9 us
  solo (`sk=2` DSMEM), `W4A8CompactMicro` 363.9 -> 357.0 us (`M=4`) and
  517.2 -> 511.8 us (`M=6`).
- End-to-end 4x DGX Spark TP4 DeepSeek-V4.1-Flash serving (paired with
  the recipe `defer_launch=True` change and Helios scheduler updates):
  nsys P=4 median round dropped 33.72 -> 32.52 ms (-1.20 ms), non-MoE
  39-layer time dropped 17.01 -> 15.68 ms (-1.33 ms), split-K memsets
  dropped 171 -> 4 per round (95.2 -> 9.3 us), and matched-depth GPU
  round times dropped 1.5-2.2 ms across P=1..6.

Validation:
- Numerical parity verified on GB10 across all 8 MXFP8 GEMV shapes and
  GroupedWoa (cosine similarity 0.9999999-1.0000000, max abs error <=
  0.0156, AUTO-DSMEM enabled).
- Full 4-rank TP4 export (57 graphs) and live serving verified on 4x
  DGX Spark. SM120 / non-SM121 hardware was not re-benchmarked.
@original-el8

original-el8 commented Nov 30, 2026 •

Copy link
Copy Markdown

Reviewed and narrowed #188 (fc2658ca) so it complements #193 cleanly (wo_mxfp8.py 64-chunk/8-warp quantizer + SM121 blockscaled/_tuning.py search space, zero merge conflicts with #193; #186 and #187 also merge cleanly).

Two small items spotted in the diff:

  1. _ld_global_nc_evict_v4_u32 cache policy (flashinfer/experimental/b12x/gemm/blockscaled/_mxfp8_tc_gemv.py:224-231): Emits "ld.global.nc.v4.u32 {$0, $1, $2, $3}, [$4];" without L2 eviction (ptxas restricts ld.global.nc.L2::evict_first to 256-bit .v8.b32/.v4.b64, so 128-bit n_tiles == 2 / odd-tail / unaligned v4 loads need "ld.global.cs.v4.u32" if streaming eviction is intended).
  2. require_single_wave check on SM121 (flashinfer/experimental/b12x/_lib/utils/dsmem.py:597): Skipping int(grid_x) > active_clusters whenever get_sm_version(ordinal) == 121 also bypasses callers that pass require_single_wave=True explicitly.

lukealonso added a commit to NVIDIA/hyperflare-inference that referenced this pull request Nov 30, 2026
…tep ring2)

Why:
On 4-rank switchless dual-port RoCE rings (DGX Spark / NVIDIA GB10, SM121),
small-message BF16 allreduce previously used the oneshot protocol, which
relays across opposite ranks over CPU mailbox hops. FlashInfer's merged
`local-inference-lab/flashinfer#192` (`2a07747b8e12e54ec8e8e4bbef34de8586618e68`)
adds a 2-step neighbor-only ring allreduce (`KIND_RING2_STEP1` /
`KIND_RING2_STEP2`) plus small-message inline WR and ring-relay
improvements in `_roce_proxy.c`. Per `docs/roce-ring.md`, Helios's
vendored `helios/native/roce_proxy.c` must remain byte-identical to
FlashInfer's `_roce_proxy.c` after its provenance header so preparation
and serving share the transport protocol.

What changed:
Re-vendored `helios/native/roce_proxy.c` byte-for-byte (after the 9-line
provenance header) from `local-inference-lab/flashinfer` commit
`2a07747b8e12e54ec8e8e4bbef34de8586618e68` (`#192`). Relative to Flare
`main`, this brings in:
- `KIND_RING2_STEP1` (5) and `KIND_RING2_STEP2` (6) direct-neighbor RDMA
  write handling (`post_direct_striped_batched`, `post_ring2_step`) with
  batched completion signaling (`RING2_SIGNAL_STRIDE = 16`,
  `RING2_MAX_OUTSTANDING = 6`, statically verified against
  `ROCE_SEND_DEPTH` with queue slack for relay ops and ring ACKs).
- Small-message and ring-relay transport improvements from FlashInfer
  `#192`: QP `max_inline_data` raised from 16 to 256 (with fallback to 16
  and per-HCA `max_inline` tracking) to enable `IBV_SEND_INLINE` on relay
  mailbox and `post_striped` payloads `<= max_inline`; `ring_next_from`
  and precomputed `ring_relays_origin[]` so `ring_service` skips
  non-relayed origins; `post_op` posting relayed peers before direct peers
  on rings; and idle-loop polling (`ring_service` every spin when
  `!ring2_active`, every 16th when `ring2_active`; `drain_cqs` every 16th).
- High-capacity CPU pinning (`pin_high_capacity_cpus`, `"flare-roce"`
  thread name) already merged upstream in `flashinfer#156` (overlaps open
  `#576`).
- Existing control opcodes (0..4) and `ROCE_ABI_VERSION = 14` remain
  unchanged, preserving full compatibility with existing ABI-14 cores.

Claimed benefit and result:
Enables native Rust serving (`flare run`) to drive b12x's 2-step RoCE ring
allreduce on 4-rank switchless rings without opposite-rank CPU relay hops.
Note that an isolated `#643`-only run on a `main`-exported core does not
emit kinds 5/6; paired with `local-inference-lab/flashinfer#192`
(`2a07747b8`), `local-inference-lab/flashinfer#193`,
`local-inference-lab/hyperflare-recipes#112`, and
`#644` on 4x DGX Spark TP4 DeepSeek-V4.1-Flash
serving (`max_tokens = 256`, 5-prompt suite):
- In node-level nsys P=4 traces, `RoceRing2AllReduceLaunch` averages
  31.8-33.0 us/call across 88 calls/round (eliminating opposite-rank CPU
  relay hops on small BF16 allreduces).
- Combined-stack matched-depth GPU round times dropped 1.5-2.2 ms across
  P=1..6 versus pre-existing non-ring2 baseline core
  `gb10-tp4-202611291503` (P=1: 22.3 -> 20.8 ms, P~4: 34.59 -> 32.36 ms,
  P~5: 35.92 -> 34.16 ms; 5-prompt mean 74.02 -> 76.11 tok/s under
  `balanced`, `greedy_code` 74.39 -> 80.89 tok/s).

Supporting evidence and limitations:
- Byte-parity check: `diff` between `tail -n +10 helios/native/roce_proxy.c`
  and `flashinfer@2a07747b8:flashinfer/experimental/b12x/comm/roce/_roce_proxy.c`
  returned 0 bytes diff.
- Native RoCE proxy unit tests (`cargo test --locked --release
  --manifest-path helios/Cargo.toml --features roce --lib --target-dir
  flare-cli/target execution::roce`): **30 passed, 0 failed** (6
  `execution::roce::tests` + 24 `execution::roce_fabric::tests`).
- Full crate tests (`cargo test --locked --release` on `helios` with
  `--features runtime-core,server`, `flare`, `flare-cli`): all passed.
- Live 4-rank multi-GPU collective execution verified on 4x DGX Spark
  dual-port switchless RoCE rings serving both ring2-enabled cores
  (`gb10-tp4-202611301141`, `gb10-tp4-202611301553`, 57 graphs each) and
  legacy non-ring2 ABI-14 core (`gb10-tp4-202611291503`).
- Limitations / unrun checks:
  - Keeping `ROCE_ABI_VERSION = 14` preserves compatibility with existing
    ABI-14 cores, but an older Flare binary without `#643` loading a newer
    ring2-exported core will connect and fail on replay op 1 with
    `unknown op kind 5` rather than rejecting at startup.
  - Collides on `roce_proxy.c` with open `#576` (`pin_high_capacity_cpus`
    from merged `flashinfer#156`) and `#577` (`RING_WINDOW` / `reserve`);
    whichever lands second will rebase cleanly against the vendored file.
  - Non-4-rank ring topologies and non-SM121 RoCE NICs were not benchmarked.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
lukealonso added a commit to NVIDIA/hyperflare-inference that referenced this pull request Nov 30, 2026
…tep ring2) (#643)

Why:
On 4-rank switchless dual-port RoCE rings (DGX Spark / NVIDIA GB10, SM121),
small-message BF16 allreduce previously used the oneshot protocol, which
relays across opposite ranks over CPU mailbox hops. FlashInfer's merged
`local-inference-lab/flashinfer#192` (`2a07747b8e12e54ec8e8e4bbef34de8586618e68`)
adds a 2-step neighbor-only ring allreduce (`KIND_RING2_STEP1` /
`KIND_RING2_STEP2`) plus small-message inline WR and ring-relay
improvements in `_roce_proxy.c`. Per `docs/roce-ring.md`, Helios's
vendored `helios/native/roce_proxy.c` must remain byte-identical to
FlashInfer's `_roce_proxy.c` after its provenance header so preparation
and serving share the transport protocol.

What changed:
Re-vendored `helios/native/roce_proxy.c` byte-for-byte (after the 9-line
provenance header) from `local-inference-lab/flashinfer` commit
`2a07747b8e12e54ec8e8e4bbef34de8586618e68` (`#192`). Relative to Flare
`main`, this brings in:
- `KIND_RING2_STEP1` (5) and `KIND_RING2_STEP2` (6) direct-neighbor RDMA
  write handling (`post_direct_striped_batched`, `post_ring2_step`) with
  batched completion signaling (`RING2_SIGNAL_STRIDE = 16`,
  `RING2_MAX_OUTSTANDING = 6`, statically verified against
  `ROCE_SEND_DEPTH` with queue slack for relay ops and ring ACKs).
- Small-message and ring-relay transport improvements from FlashInfer
  `#192`: QP `max_inline_data` raised from 16 to 256 (with fallback to 16
  and per-HCA `max_inline` tracking) to enable `IBV_SEND_INLINE` on relay
  mailbox and `post_striped` payloads `<= max_inline`; `ring_next_from`
  and precomputed `ring_relays_origin[]` so `ring_service` skips
  non-relayed origins; `post_op` posting relayed peers before direct peers
  on rings; and idle-loop polling (`ring_service` every spin when
  `!ring2_active`, every 16th when `ring2_active`; `drain_cqs` every 16th).
- High-capacity CPU pinning (`pin_high_capacity_cpus`, `"flare-roce"`
  thread name) already merged upstream in `flashinfer#156` (overlaps open
  `#576`).
- Existing control opcodes (0..4) and `ROCE_ABI_VERSION = 14` remain
  unchanged, preserving full compatibility with existing ABI-14 cores.

Claimed benefit and result:
Enables native Rust serving (`flare run`) to drive b12x's 2-step RoCE ring
allreduce on 4-rank switchless rings without opposite-rank CPU relay hops.
Note that an isolated `#643`-only run on a `main`-exported core does not
emit kinds 5/6; paired with `local-inference-lab/flashinfer#192`
(`2a07747b8`), `local-inference-lab/flashinfer#193`,
`local-inference-lab/hyperflare-recipes#112`, and
`#644` on 4x DGX Spark TP4 DeepSeek-V4.1-Flash
serving (`max_tokens = 256`, 5-prompt suite):
- In node-level nsys P=4 traces, `RoceRing2AllReduceLaunch` averages
  31.8-33.0 us/call across 88 calls/round (eliminating opposite-rank CPU
  relay hops on small BF16 allreduces).
- Combined-stack matched-depth GPU round times dropped 1.5-2.2 ms across
  P=1..6 versus pre-existing non-ring2 baseline core
  `gb10-tp4-202611291503` (P=1: 22.3 -> 20.8 ms, P~4: 34.59 -> 32.36 ms,
  P~5: 35.92 -> 34.16 ms; 5-prompt mean 74.02 -> 76.11 tok/s under
  `balanced`, `greedy_code` 74.39 -> 80.89 tok/s).

Supporting evidence and limitations:
- Byte-parity check: `diff` between `tail -n +10 helios/native/roce_proxy.c`
  and `flashinfer@2a07747b8:flashinfer/experimental/b12x/comm/roce/_roce_proxy.c`
  returned 0 bytes diff.
- Native RoCE proxy unit tests (`cargo test --locked --release
  --manifest-path helios/Cargo.toml --features roce --lib --target-dir
  flare-cli/target execution::roce`): **30 passed, 0 failed** (6
  `execution::roce::tests` + 24 `execution::roce_fabric::tests`).
- Full crate tests (`cargo test --locked --release` on `helios` with
  `--features runtime-core,server`, `flare`, `flare-cli`): all passed.
- Live 4-rank multi-GPU collective execution verified on 4x DGX Spark
  dual-port switchless RoCE rings serving both ring2-enabled cores
  (`gb10-tp4-202611301141`, `gb10-tp4-202611301553`, 57 graphs each) and
  legacy non-ring2 ABI-14 core (`gb10-tp4-202611291503`).
- Limitations / unrun checks:
  - Keeping `ROCE_ABI_VERSION = 14` preserves compatibility with existing
    ABI-14 cores, but an older Flare binary without `#643` loading a newer
    ring2-exported core will connect and fail on replay op 1 with
    `unknown op kind 5` rather than rejecting at startup.
  - Collides on `roce_proxy.c` with open `#576` (`pin_high_capacity_cpus`
    from merged `flashinfer#156`) and `#577` (`RING_WINDOW` / `reserve`);
    whichever lands second will rebase cleanly against the vendored file.
  - Non-4-rank ring topologies and non-SM121 RoCE NICs were not benchmarked.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
…lidator

- Remove redundant `_ld_global_nc_evict_v4_u32` wrapper (identical PTX to
  `_ld_global_nc_v4_u32_ro`) and preserve `use_pdl` coherence across
  MXFP8 TC-GEMV and GroupedWoa weight/scale/RoPE loads by adding
  coherent `_ld_global_evict_v8_u32` (`ld.global.L2::evict_first.v8.b32`,
  `has_side_effects=True`) matching `_nvfp4_tc_gemv.py`.
- Move the SM121 multi-wave auto-DSMEM policy out of
  `validate_launcher_dsmem_cluster` into
  `sm120_dsmem_auto_requires_single_wave` passed by the 5 auto-DSMEM
  call sites, so explicit `require_single_wave=True` is enforced on all
  SMs as documented.
- Update `sm120_dsmem_split_enabled` docstring and
  `tests/experimental/b12x/test_sm120_dsmem_splitk.py` for SM121 default
  auto-DSMEM behavior and strict `validate_launcher_dsmem_cluster`
  enforcement.

Verified on local SM120 GPU: 27/27 passed across
`tests/experimental/b12x/test_sm120_dsmem_splitk.py` and
`tests/experimental/b12x/test_sm120_decode_pdl.py` (including cuobjdump
PDL+DSMEM SASS audit).
@lukealonso

Copy link
Copy Markdown
Author

Addressed both points in 8591bf45c:

  1. Removed the redundant _ld_global_nc_evict_v4_u32 wrapper (the v4 tail/fallback paths use _load_v4_u32 / _ld_global_nc_v4_u32_ro, matching _nvfp4_tc_gemv.py). Running the SM120 GPU PDL+DSMEM suite also caught that unconditional .nc loads broke the use_pdl=True SASS check (LDG.E.*.CONSTANT), so _load_weight_v8_u32 now mirrors _nvfp4_tc_gemv.py with coherent _ld_global_evict_v8_u32 (ld.global.L2::evict_first.v8.b32, has_side_effects=True) when use_pdl=True and restores self.use_pdl coherence on v4, u8, and cos_sin loads.
  2. Moved the SM121 multi-wave auto-DSMEM policy out of validate_launcher_dsmem_cluster into sm120_dsmem_auto_requires_single_wave(ordinal) at the 5 auto-DSMEM call sites, so validate_launcher_dsmem_cluster(..., require_single_wave=True) strictly enforces single-wave residency on all SMs. Updated sm120_dsmem_split_enabled's docstring and tests/experimental/b12x/test_sm120_dsmem_splitk.py accordingly.

Verified pytest tests/experimental/b12x/test_sm120_dsmem_splitk.py tests/experimental/b12x/test_sm120_decode_pdl.py on SM120: 27/27 passed (including cuobjdump PDL+DSMEM SASS ordering and no-LDG.E.*.CONSTANT checks).

@lukealonso
lukealonso merged commit 6ce11d2 into main Nov 30, 2026
7 of 10 checks passed
lukealonso added a commit to local-inference-lab/hyperflare-recipes that referenced this pull request Nov 30, 2026
…ap, and deferred shared expert (#112)

* perf(deepseek41): wire RoCE ring2 collectives, DSpark main_proj overlap, and deferred shared expert

Why:
During TP4 speculative decode on 4x DGX Spark (SM121), four recipe-level
execution overheads left GPU time on the table:
1. `PreparedAllReduce` and `PreparedAllGather` in `components/collectives.py`
   did not expose b12x's fused-addend 2-step RoCE ring allreduce or
   device-gated RoCE allgather when available.
2. `PreparedPackedSpeculativeRound` still broadcast vocabulary-parallel
   distribution confidence from rank 0 even though every rank reduces the
   identical confidence vector locally from gathered softmax records.
3. `PreparedContext` in `components/dspark.py` could not overlap its
   output-sharded `mtp.0.main_proj` projection on the auxiliary stream
   when `compact` was off and RoCE collectives handled the gather.
4. `ConcurrentSharedExpert` in `recipes/deepseek41/decoder.py` set
   `defer_launch = (M > 4)`, causing `shared_up` to contend with
   `router_projection` at `M <= 4` instead of filling the
   `route_topk` + route-coalesce memory bubble before `FC1`.

What changed:
- `hyperflare_recipes/components/collectives.py`: Added capability-checked
  fused-addend support (`_roce_supports_addend`) for RoCE `PreparedAllReduce`
  and device-side `gate` forwarding for RoCE `PreparedAllGather` (preserving
  compatibility with current `uv.lock` FlashInfer until `flashinfer#192`
  merges).
- `hyperflare_recipes/components/packed_speculation.py`: Skipped the
  redundant confidence broadcast when `confidence_head is None`
  (vocabulary-parallel distribution confidence is identical on every rank).
- `hyperflare_recipes/components/dspark.py` & `parallel_draft.py`: Added
  `flare::start_dspark_main_proj` / `flare::join_dspark_main_proj` and
  `overlap_context_main` to overlap sharded `mtp.0.main_proj` on the
  auxiliary stream with target completion and synchronize before commit.
- `hyperflare_recipes/recipes/deepseek41/decoder.py`: Enabled
  `defer_launch=True` for `ConcurrentSharedExpert` across all decode sizes.
- Added/updated component unit tests in `test_collective_plan_choice.py`,
  `test_dspark_context_shard.py`, and `test_packed_speculation.py`.

Claimed benefit and result:
Reduces per-round collective, confidence-broadcast, draft-context, and
shared-expert contention overhead in TP4 speculative decode. Combined with
`local-inference-lab/flashinfer#192`, `local-inference-lab/flashinfer#193`,
and `NVIDIA/hyperflare-inference#643`/`#644` on 4x DGX Spark TP4
DeepSeek-V4.1-Flash serving (`gb10-tp4-202611301553`), node-level nsys
P=4 median round dropped 33.72 -> 32.52 ms (-1.20 ms), non-MoE time
across 39 target layers dropped 17.01 -> 15.68 ms (-1.33 ms) with `sh_dn`
completing before `FC1` starts, and matched-depth GPU round latency
dropped 1.5-2.2 ms across P=1..6.

Supporting evidence and limitations:
- Component unit tests on tachyon (`TRITON_INTERPRET=1 pytest
  tests/components/test_collective_plan_choice.py
  tests/components/test_dspark_context_shard.py
  tests/components/test_packed_speculation.py -q`): all passed (48/48
  including `test_vocabulary_completion_abi.py`).
- Full 4x DGX Spark TP4 export (57 graphs) and 5-prompt live serving
  verified on SM121.
- Limitations: `uv.lock` is not bumped in this PR and should be updated
  once `local-inference-lab/flashinfer#192` and `#193` merge; SM120 /
  non-SM121 GPUs were not benchmarked in this pass.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=6fcc

* fix(deepseek41,collectives): align RoCE addend capability check and medium-batch shared-expert overlap

- In `_roce_supports_addend` (`hyperflare_recipes/components/collectives.py`),
  check `getattr(runtime, "supports_all_peer_auxiliary", False)` before the
  `_uses_ring2` fallback so runtimes implementing one-shot and two-shot
  fused addends keep fused reductions across switched RoCE, two-shot, and
  16-byte payloads while preserving ring2-only gating when absent.
- In `hyperflare_recipes/recipes/deepseek41/decoder.py`, set
  `ConcurrentSharedExpert(..., defer_launch=(rows <= 4) or (rows > 64))`
  so `M <= 4` avoids `router_projection` bandwidth contention and `M > 64`
  avoids SM starvation, while `5 <= M <= 64` keeps shared-expert projections
  overlapped with routed-expert execution.
- Update `tests/recipes/test_deepseek41_expert_overlap.py` for the
  `(rows <= 4) or (rows > 64)` policy and add precedence coverage plus a
  capability skip guard in `tests/components/test_collective_plan_choice.py`.

Verified: `pytest tests/recipes/test_deepseek41_expert_overlap.py
tests/components/test_collective_plan_choice.py
tests/components/test_dspark_context_shard.py
tests/components/test_packed_speculation.py` (184 passed, 8 skipped
live-ring2 cases on pre-ring2 FlashInfer).

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=6fcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants