Skip to content

moe: compute the silu activation once per CTA in the verify-row silu_down kernel (+25% short / +10% agent decode, byte-identical) - #228

Merged
AzeezIsh merged 2 commits into
mainfrom
perf/fp4l-moe-verify-dedup-act
Oct 28, 2026
Merged

AzeezIsh merged 2 commits into
mainfrom
perf/fp4l-moe-verify-dedup-act

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

Stacked on #219 (base perf/fp4l-moe-verify-dedup). I'll retarget this to main once #219 merges.

The decode profile of #219 (sparky nsys, 3 × 1,024 tokens, ms per generated token) showed its silu_down rows kernel at 6.55 ms/token, against 3.28 for the per-row kernel it replaces, while reading half the bytes of gate_up. The cause: silu_down_shared_t_rows_impl recomputed silu(g)·u (two __expf + divide) per element, per row, inside every one of its 256 column threads. The single-row kernel computes s_act once per CTA.

This stages the activation per k-tile in shared memory, computed once per element per CTA with the single-row kernel's expression (gf / (1.0f + __expf(-gf))) * uf in fp32. The inner loop reads it back. Each row's per-element accumulate (act·(lut·sc), same order) is unchanged, so outputs stay byte-identical.

Evidence (sparky GB10, nvidia/Qwen3.8-Flash-Next-FP4-Local, default recipe profile r1short, MTP 3; job 39c-s71-insitu)

prompt (tokens out) #219 tok/s (3 runs) this PR tok/s (3 runs) Δ
short A (382) 27.76 / 27.72 / 27.75 34.87 / 34.92 / 34.92 +25.7%
short B (178) 27.27 / 27.28 / 27.30 34.22 / 34.20 / 34.30 +25.4%
short C (253) 26.62 / 26.57 / 26.65 33.52 / 33.41 / 33.58 +25.9%
agent run 0 (512) 24.01 / 23.98 / 24.01 26.41 / 26.35 / 26.44 +10.0%
agent run 1 (512) 25.48 / 25.36 / 25.49 28.10 / 28.07 / 28.17 +10.4%
agent run 2 (512) 24.55 / 24.43 / 24.52 27.06 / 27.00 / 27.10 +10.3%

Medians: short 27.28 → 34.22 tok/s, agent (~17K-token prompt) 24.52 → 27.06 tok/s. Against main before #219 (25.98 / 23.41, earlier A/B on the same prompts), that's about +32% short and +16% agent decode. Within-arm spread is ≤ 0.1 tok/s.

A microbench of #219's vs this PR's rows kernels (sparky job 40) and a GB10 merge gate (agentic-webserver 50 + BFCL ST-995) on the merge with main follow. Byte-identical outputs mean BFCL should match main exactly.

Test plan

Generated with Devin

AzeezIsh and others added 2 commits October 28, 2026 04:27
…mpute

The rows silu_down kernel recomputed (g/(1+exp(-g)))*u per element per
column thread; with one column per thread that's 256x redundant SFU work
and made silu_down_rows ~2x slower than the per-row arm while reading
half the bytes. Stage s_act (fp32) per k-tile like the single-row smem
kernel's phase-1 precompute; identical expression and values, same smem
budget as the s_g/s_u pair it replaces. Bench now prints separate
gate_up/silu_down times per case.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…cap)

cases.rs grew past 500 with the per-phase timing split; the guard helpers
belong with the constants anyway.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Microbench (sparky job 40): the first real run of the slim bench, both builds in one job, every case byte-identical, 6 RESULT lines parsed per arm. Cold rotation over 48 layer tables. Ratio = rows kernel ÷ 4 single-row launches:

rows=4, union of 40 slots #219 this PR silu_down rows time, single → rows (this PR)
19 0.759 0.481 254 → 114 µs
26 0.771 0.479 328 → 142 µs
33 0.975 0.599 367 → 190 µs

The single-row reference itself differs ~15% between the two builds' runs (same kernel code), so treat these as directional. The in-situ A/B above is the decisive number. The GB10 merge gate on this head (agentic-webserver 50 + BFCL ST-995) is running as sparky job 41.

@AzeezIsh
AzeezIsh changed the base branch from perf/fp4l-moe-verify-dedup to main October 28, 2026 08:49
AzeezIsh added a commit that referenced this pull request Oct 28, 2026
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

GB10 gate progress (sparky job 41, head 86c11d7 = main + #219 + this PR; default FP4-Local recipe profile r1short):

  • 4-request T=0 control: byte-identical to main.
  • agentic-webserver 50: 50/50, 50/50, 11.19 s/turn, harness decode 24.81 tok/s (run-1793181820586414906, 379 turns).
build s/turn harness decode tok/s
main before S7 (train 2) 12.43 22.05
+ #219 (S7) 11.99 22.92
+ this PR (S7.1) 11.19 24.81

That's one agentic run per build, and the direction matches the fixed-prompt A/B above. BFCL ST-995 is running (~3 h); byte-identical outputs should give 87.44 / 87.32 exactly.

AzeezIsh added a commit that referenced this pull request Oct 28, 2026
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

All gates passed: merging. sparky GB10, head 86c11d7 (= main db442e2 + this PR), default FP4-Local recipe profile:

gate result
control byte-identical to main
exactness (job 39c) EXACT_VERIFY_CHECK 512 rows + BATCH_FAST_CHECK C=4: 0 rows differ; arm engaged
decode A/B (job 39c, 3 pairs vs #219) short 27.28 → 34.22 tok/s (+25%), agent 24.52 → 27.06 tok/s (+10%)
agentic-webserver 50 (job 41) 50/50, 50/50, 11.19 s/turn, 24.81 tok/s (run-1793181820586414906); #219: 11.99 / 22.92; main before S7: 12.43 / 22.05
BFCL ST-995 (job 41) 87.44 / 87.32 (run-1793191492360335768), all 15 subsets identical to main
TTFT p50 / p90 639 / 3,026 ms (job 35: 637 / 3,002), prefill unchanged
serve log 0 ERROR / 0 panic
CI green except the repo-wide PR benchmark gate

@AzeezIsh
AzeezIsh merged commit 87df79b into main Oct 28, 2026
21 of 22 checks passed
AzeezIsh added a commit that referenced this pull request Oct 28, 2026
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

1 participant