Repository navigation
moe: gfx1151 small prefill pieces through the t_rows dedup kernels (Flash-Next TTFT -9..-19%, byte-identical) - #313
Merged
Conversation
…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]>
4 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On gfx1151, prefill pieces below
ATLAS_HIP_MOE_GROUPED_MIN_TOKENS(256) go toforward_batched_qwen4exp_fast. Its fused kernels (qwen4exp_moe_fast) are off underatlas_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:SSM_SLOTSdefaults to 8 (serve-amd.sh: SSM_SLOTS defaults to 8 so hybrid models reuse cached prefixes (TTFT after 8k context 3.2–3.8× lower) #311). Framework f169s8: 1,152 per-token gate/up + 1,152 silu/down launches for a 24-token tail, ~0.45 s of a 2.24 s TTFT.On hip, when t_rows is eligible, each chunk of up to 8 tokens now runs
moe_expert_union_tplus the_t_rowsgate/up and silu/down pair:_tkernels the loop launchedscratchon top of the prefill metadata, and f173 caught it withATLAS_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):
🤖 Generated with Claude Code