Skip to content

moe: gfx1151 small prefill pieces through the t_rows dedup kernels (Flash-Next TTFT -9..-19%, byte-identical) - #313

Merged
AzeezIsh merged 2 commits into
mainfrom
perf/hip-moe-small-prefill-trows
Nov 1, 2026
Merged

AzeezIsh merged 2 commits into
mainfrom
perf/hip-moe-small-prefill-trows

Conversation

@AzeezIsh

@AzeezIsh AzeezIsh commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

On gfx1151, prefill pieces below ATLAS_HIP_MOE_GROUPED_MIN_TOKENS (256) go to forward_batched_qwen4exp_fast. Its fused kernels (qwen4exp_moe_fast) are off under atlas_hip, so it fell through to the per-token loop: one routed+shared gate/up and one silu/down launch per token per layer. That covers:

On hip, when t_rows is eligible, each chunk of up to 8 tokens now runs moe_expert_union_t plus the _t_rows gate/up and silu/down pair:

  • byte-identical per (row, slot) to the single-row _t kernels the loop launched
  • the loop's GEMM router, per-token top-k, blends and EP reduce are unchanged
  • chunks never leave a single row (9 → 7 + 2)
  • union buffers live in the router-logits buffer, which is free after top-k. The first cut placed them in scratch on top of the prefill metadata, and f173 caught it with ATLAS_DEBUG_SYNC_KERNELS (reshape_and_cache fault).

A/B (framework f171b, main-300 vs 7abfe7b, Flash-Next MAX_BATCH 1, SSM_SLOTS 8, MTP, Gufo depth protocol ×2):

TTFT main this
cold 1.87k 2.34 / 2.34 s 2.13 / 2.14 s
1.85k after 8k 3.15 / 3.15 s 2.98 / 2.98 s
1.86k after 16k 5.76 / 5.76 s 4.69 / 4.68 s
  • Decode tok/s unchanged (23.5 / 22.6 / 22.7).
  • Prefix hits restored 4/4 on both.
  • 8 cold split-tail prompts give identical text across builds 8/8.
  • 0 faults.

🤖 Generated with Claude Code

AzeezIsh and others added 2 commits November 1, 2026 16:19
…nels (byte-identical; cold TTFT with snapshots on)

forward_batched_qwen4exp_fast handles prefill pieces below
ATLAS_HIP_MOE_GROUPED_MIN_TOKENS on the transposed tables. gfx1151 has no
qwen4exp_moe_fast kernels, so it fell through to the per-token loop: one
routed+shared gate/up and one silu/down launch per token per layer. That
is the snapshot-split tail of every cold prompt with SSM snapshots on
(framework f169s8: 1,152 + 1,152 per-token launches for a 24-token tail,
~0.45 s of a 2.24 s TTFT, vs 1.75 s with snapshots off), and every short
agentic suffix after a prefix hit.

Under atlas_hip, when t_rows is eligible, each chunk of up to 8 tokens now
runs moe_expert_union_t and the _t_rows gate/up + silu/down pair. These
are byte-identical per (row, slot) to the single-row _t kernels the loop
launched, and the loop's GEMM router, per-token top-k, blends and EP
reduce are unchanged. Chunks never leave a single row (9 -> 7 + 2), and
the routing scratch is bounded before anything launches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tadata

The first cut put the union buffers right after the routing
indices/weights in scratch. Prefill uploads its attention metadata
(positions, slot mapping, block table) at exactly that offset
(prefill_a.rs meta_offset), so the next attention layer's
reshape_and_cache wrote through a clobbered slot mapping: framework
f171 HSA memory aperture violation; f173 under ATLAS_DEBUG_SYNC_KERNELS
named reshape_and_cache in layer 3 on the 27-token tail. They now live
in the router-logits buffer, which is free once every top-k has read it
(same stream, launched before the chunk loop) and is sized for a whole
chunk.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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