Repository navigation
factory: keep the BF16 lm_head while an MTP drafter holds it (fixes #264: Flash-Next + NVFP4 head + MTP faulted on the first request) - #272
Merged
Conversation
) Qwen3.8-Flash-Next served with --lm-head-dtype nvfp4 and MTP (the serve-amd.sh default) hit an illegal address on its first propose: a launch with grid [25000,1,1], which is the draft vocab projection over --mtp-vocab 100000 (#264). build.rs copies the BF16 head into q4e_mtp_lm_head (and v4_mtp_lm_head for DeepSeek-V4) early on. Later, when an NVFP4 head exists, it frees the same buffer as dead weight. The drafter kept the stale pointer. That explains every bisect arm (framework f98/f101/f105): - the fp8 and bf16 heads never reach the free; - NUM_DRAFTS=0 never reads the head; - the padded transposed twin is unrelated (ATLAS_NO_LMHEAD_TGEMM=1 still faulted). The free now skips when either drafter was loaded. That costs vocab x hidden x 2 B of memory, which is ~1.27 GB on Flash-Next. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 30, 2026
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.
Fixes #264.
Bug.
factory/build.rscopies the BF16 head intoq4e_mtp_lm_head = lm_head(andv4_mtp_lm_headfor DeepSeek-V4) early in the build. Later, when an NVFP4 head exists,bf16_lm_head_is_deadfrees that same buffer. The Qwen3.8-Flash-Next drafter keeps the stale pointer, and its first vocab projection (grid 25000 =--mtp-vocab100000 / 4 rows per block) reads freed memory:hipErrorIllegalAddresson the first request under theserve-amd.shdefaults (LM_HEAD=nvfp4, MTP K=4).Fix. Skip the free while either drafter is loaded. Cost: vocab × hidden × 2 B ≈ 1.27 GB on Flash-Next.
Verified on framework (desktop Strix Halo, gfx1151), f106, the exact serve-amd.sh default that faulted before (f97/f98/f101/f105):
The bisect that led here is on #264. It ruled out the padded transposed twin (
ATLAS_NO_LMHEAD_TGEMM=1still faulted) and showed that fp8/bf16 heads and NUM_DRAFTS=0 never reach the freed buffer.🤖 Generated with Claude Code