Skip to content

gfx1151: Flash-Next NVFP4 + MTP + --lm-head-dtype nvfp4 (serve-amd.sh default) -> illegal address on the first request #264

Closed

Description

@AzeezIsh

Symptom. ./serve-amd.sh nvidia/Qwen3.8-Flash-Next-NVFP4 (defaults: LM_HEAD=nvfp4, MTP K=4) faults on the first chat request on gfx1151. The request returns HTTP 500, every later request returns 503, and the log shows illegal=9:

ERROR spark::scheduler::mtp_step::bootstrap: run_mtp_propose_multi: cuMemcpyDtoHAsync_v2 failed: status 700
ERROR spark::scheduler::mtp_step::bootstrap: bootstrap start_checkpoint_async: cudaMemcpy2DAsync failed: status 700

Bisect (framework / desktop Strix Halo, ROCm, main ec054ef, job f98):

arm result
serve-amd.sh default (nvfp4 head, NUM_DRAFTS=3) fault
NUM_DRAFTS=1 fault
ATLAS_NO_LMHEAD_TGEMM=1 (no padded transposed twin) fault
NUM_DRAFTS=0 OK

Also: direct spark serve + --speculative --num-drafts 1 with the default head is OK (f87/f99); --lm-head-dtype fp8 + MTP is OK (f86); --lm-head-dtype nvfp4 + MTP faults identically (f86, on b5a8f6b). So it predates the 2026-10-29 merges. The 27B with the same serve-amd.sh defaults is fine.

Inference (not verified): the qwen4_exp MTP propose path on HIP mishandles the NVFP4 lm_head (vocab 248077, not a multiple of 16). The padded transposed twin is ruled out (it still faults with ATLAS_NO_LMHEAD_TGEMM=1).

Workaround: LM_HEAD=fp8 ./serve-amd.sh nvidia/Qwen3.8-Flash-Next-NVFP4 (fp8 head + MTP is OK and +3.5..6% decode over bf16, f86), or NUM_DRAFTS=0.

🤖 Generated with Claude Code

Activity

  1. AzeezIsh commented on Oct 30, 2026

    @AzeezIsh
    ContributorAuthor

    [amd-campaign f101 · 2026-10-30 05:17Z · framework · main b0df501, ATLAS_DEBUG_SYNC_KERNELS=1] The fault is caught right after a kernel launch inside run_mtp_propose_multi: grid [25000, 1, 1], block 256, no dynamic shared memory → hipErrorIllegalAddress. The same build with LM_HEAD=fp8 answers correctly ("The sky appears blue because molecules in the Earth's atmosphere scatter…"). The sync log carries no kernel name and no integer division of vocab 248077 gives 25000; f104 reruns with the shim's launch trace (ATLAS_TRACE_LAUNCH_SYNC=1) to name it.

  2. AzeezIsh commented on Oct 30, 2026

    @AzeezIsh
    ContributorAuthor

    [amd-campaign f104/f105 + code read · 2026-10-30 06:40Z · framework · main b0df501]

    • f105 (AMD_SERIALIZE_KERNEL=3, AMD_LOG_LEVEL=3): the fault surfaces at a cuLaunchKernel with grid [25000,1,1] block 256 (no shader names in this ROCm's level-3 log).
    • Which launch (inference): the default --mtp-vocab is 100000, and 100000 rows / 4 rows per 256-thread block = 25000. So this is the draft-head vocab projection over the reduced MTP vocab, i.e. the propose-path LM-head GEMV (mtp_head/forward.rs step 12 calls w4a16_decode_gemv with v = mtp_vocab_size), or the qwen4_exp proposer's equivalent.
    • Hypothesis (unverified): with --lm-head-dtype nvfp4 the BF16 lm_head is freed during NVFP4 quantization (factory/build.rs: "the BF16 lm_head just freed ~22 GB during NVFP4 quantization"), but the qwen4_exp draft path still reads a head pointer that is freed or stale. Supporting evidence: with NUM_DRAFTS=0, teardown logs freeing weight lm_head.weight: cuMemFree_v2 failed: status 1 (f98), i.e. the store still tracks an already-freed lm_head. The fp8 head works (a different quantization path that may keep or own its storage).
    • Next: read the qwen4_exp proposer's head wiring and run ATLAS_MTP_DEBUG_NORMS=1 / --mtp-vocab variations (a non-multiple-of-4 vocab moves the grid if this is the launch).
  3. AzeezIsh commented on Oct 30, 2026

    @AzeezIsh
    ContributorAuthor

    Root cause (code read, 2026-10-30 07:00Z): factory/build.rs copies the BF16 head into q4e_mtp_lm_head = lm_head (line 334) for the Qwen3.8-Flash-Next MTP drafter. Later (~line 885), when an NVFP4 head exists, it frees that same buffer via bf16_lm_head_is_dead. The drafter keeps the stale pointer, and its first vocab projection (100000 rows / 4 per block = grid 25000) reads freed memory.

    Fits every bisect arm:

    • fp8 and bf16 heads never reach the free;
    • NUM_DRAFTS=0 never reads the head;
    • the padded twin is unrelated.

    DeepSeek-V4 has the same early copy (v4_mtp_lm_head).

    Fix: branch fix/q4e-mtp-head-use-after-free skips the free while either drafter is loaded (cost: vocab × hidden × 2 B ≈ 1.27 GB on Flash-Next). Verifying on framework (f106: the exact serve-amd.sh default that faulted, plus LM_HEAD=fp8) before the PR.

  4. AzeezIsh commented on Oct 30, 2026

    @AzeezIsh
    ContributorAuthor

    Fixed by #272 (merged → main 1585c38). Verified on framework (f106): the serve-amd.sh default (NVFP4 head + MTP K=4) serves Flash-Next with coherent probes, 0 faults, decode 22.8 tok/s. Post-merge checks: s133 (strix), f107 (framework).

  5. added 2 commits that reference this issue on Nov 11, 2026
    ca3807c
    1585c38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions