Repository navigation
moe: dedup transposed-table expert reads across MTP verify rows (FP4-Local decode, byte-identical) - #219
Conversation
moe_expert_union_t computes the unique-expert union of ROWS verify rows; the _v3_*_b256 rows kernels stage each unique expert's tile once (smem double-buffer) plus the per-row activation slice, accumulating acc[COLS=1][ROWS] with the single-row _t kernel's exact expression/order. gb10-only symbols. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Third arm in MoeLayer::forward_rows between rows_pair and per-row: moe_expert_union_t -> gate_up/silu_down rows kernels over *_ptrs_t only. Eligible 2..=8 rows on the published transposed layout, NVFP4 scales, no LoRA/pre-norm/hash/bias-router, handles resolved, kill switch BISECT_MOE_T_ROWS. Logs once on first engage. Includes the eligibility truth-table test. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Merge gate progress (sparky GB10,
|
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Correction to the in-situ evidence above. The EXACT_VERIFY_CHECK run in job 30b (160 tokens, ~55 verify steps) printed no summary line, because summaries print every |
|
Merge gate (job 35) PASS:
TTFT is unchanged (S7 only touches decode verify rows), and the agentic speedup comes from decode (+3.9% harness decode, consistent with the +4.5% fixed-prompt A/B). Last item before merging: the exactness re-check (job 37), running now. |
Pure move: main.rs (harness), tables.rs (layer tables, RNG, constants, union routing), cases.rs (memory guard + RESULT printer). Fixes three pre-existing clippy lints now that the example is linted. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Exactness re-check (job 37) PASS, now with summary lines proving the steps were compared:
Pushed 3dacfd1: the bench example is split into |
Pure move into init_t_rows.rs, same shape as init_optional: TRowsKernels::resolve returns the union + per-ROWS rows handle arrays; init.rs consumes the fields. Same kernel names, same !atlas_hip gating, same values. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…e cap; main red since #197) Pure move into init_batched.rs (BatchedKernels::resolve), same shape as init_optional/init_t_rows: batch2/batch3/batch5 fused verify, token-major prefill trio, atomic-c4 pair. Same kernel names, gating and field values. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The clean branch ships _v3_r{2..8}_b256 only; rows=1 crashed on a missing
symbol and MOE_ROWS_ONLY used the old v0 names. Bench now runs rows 2..=4
and MOE_ROWS_ONLY resolves the shipped names.
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Two more pushes, neither touches the serve binary:
Correction: the job-30b "clean-branch microbench" guard printed PASS on that crashed run (0 RESULT lines parsed), so it was vacuous. The merge evidence here doesn't depend on it: the in-situ control, the summary-line exactness checks (job 37) and BFCL (job 35) all ran on the real binary. The first real run of the slim bench is queued as sparky job 40, and every verdict now fails on 0 parsed lines. Merging once CI's nvcc check is green. |
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
All gates passed: merging.
Follow-up #228 (stacked) fixes this PR's silu_down rows kernel: another +25% short / +10% agent decode, byte-identical, gating now. |
Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
On FP4-Local (
nvidia/Qwen3.8-Flash-Next-FP4-Local) the MTP verify rows (draft depth 3 → 4 rows) each ranforward_row_localon the transposed-table MoE arm. So every row re-streamed the experts it shared with the other rows. Measured on 2026-10-19: the 4 rows' 40 routed slots hit a mean of 26.1 unique experts (p10 19, p90 33), so ~35% of routed-expert reads were duplicates.This adds a dedup arm to
MoeLayer::forward_rows:moe_expert_union_tmaps the rows'rows × top_kids onto the union of experts (no host sync).moe_expert_{gate_up,silu_down}_shared_t_rows_v3_r{2..8}_b256stage each unique expert's tile once (smem double buffer, 16-byte loads, 256 columns per CTA) and apply it to every row that selected it. Each row's accumulator is a register, computed unconditionally with the row mask applied only at the store. Each (row, slot) output uses the single-row_tkernel's per-element expression and k-order, so it is byte-identical to running each row alone.forward_rows_t.rs: the per-row router GEMV + top-k and the blend are the same launches asforward_row_local; only the routed + fused shared expert GEMVs are deduplicated. It reads only the*_ptrs_ttables; the row-major originals are freed on FP4-Local._tkernels, no LoRA / router hooks, rows 2..8). Kill switch:ATLAS_QWEN4EXP_BATCH_FAST_BISECTbitBISECT_MOE_T_ROWS(no new env var). The kernels are gb10-only, so the lookups aretry_kernel_gated(!cfg!(atlas_hip), …). Default-on when eligible, since it's an exact speedup.Evidence (sparky GB10)
Microbench (
examples/moe_t_rows_bench.rs, cold: 48 rotating layer tables, routing with an exact union target; ratio = rows kernel ÷ rows × single-row launches): rows=4 at union 26/40 slots 0.764, rows=2 0.908, rows=3 0.791 / 0.814. Every case byte-identical. It took a few rounds (campaign log #211, 10-27): the first version was 1.5–1.76× slower because of a runtime-indexed accumulator demoted to local memory.In situ, on this exact branch (87b28ea vs the base binary c3bf9aa = main da7985c's tree; default FP4-Local recipe profile r1short, MTP 3,
ATLAS_QWEN4EXP_BATCH_FAST=1; sparky job30b-s7-gate-v3b256):ATLAS_QWEN4EXP_EXACT_VERIFY_CHECK=1: 0 mismatches, with the dedup arm engaged (its one-time engage log fired).nvidia/Qwen3.8-Flash-Next-NVFP4) control: byte-identical.ab_stream.pywith fixed prompts; completion lengths are identical in both arms:Medians over 9 runs each: short 25.98 → 27.20 tok/s, agent 23.41 → 24.46 tok/s, about +4.5% decode. Within-arm spread is ≤ 0.1 tok/s. The in-situ gain is smaller than the microbench ratio implies: routed gate_up + silu_down was ~13 of ~30 ms per token in the 10-19 profile, and only part of it is verify rows.
Before merging
Per the verify-before-merge policy, a GB10 gate of this PR merged onto current main (control, agentic-webserver 50, BFCL ST-995) is queued on sparky. Byte-identical outputs mean BFCL should match main exactly. Results will be posted here and in #211.
Test plan
forward_rows_t_tests.rs)Generated with Devin