Skip to content

Strix Halo Windows: Flash-Next port + newest DFlash fix stack (validation running) - #54

Closed
AzeezIsh wants to merge 35 commits into
feat/flashnext-nvidiafrom
fnext-win-r2
Closed

AzeezIsh wants to merge 35 commits into
feat/flashnext-nvidiafrom
fnext-win-r2

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

Flash-Next Windows stack (e98a3189-based, 35 commits over feat/flashnext-nvidia) plus the five fixes validated in the 27B DFlash2 build:

  • 833514a8 selector full rank-256 / top-16 scoring
  • 9a7367aa selector parity fixture
  • 088ab810 strix-hip expected-absent probe declarations
  • 17854911 FP8 lm_head guard on NVFP4-packed shared head
  • 3d0684aa content-loop watchdog fix for numeric lists — directly relevant: this stack's own port doc attributes an earlier 641-token generation cut to that watchdog false-positive

The two PR-branch commits this worktree lacked (d9eee900, 3f537e8e) turned out to be duplicates of in-stack commits (de3ac9db, 7af19cee) — the worktree was rebased; no cherry-pick needed.

Status — draft pending leg completion

  • Built on winbox with ATLAS_TARGET_MODEL=qwen3.8-flash-next — 119 kernels, 8 model-specific overrides, HIP shim DLLs staged. (Note: first_run.ps1 defaults ATLAS_TARGET_MODEL=qwen3.8-27b; must override.)
  • Served via win_serve_flashnext_nvfp4.ps1 (tag fnext-r2): MTP arm, seq 32768, util 0.901, prefill 1024, no pcache. Boot audit clean without the unresolved-kernel flag.
  • agentic-webserver leg running — 50 iterations, matching prior leg agentic-1789958764478 invocation. In progress at PR-open time; will undraft on completion + report.

Generated with Devin

…he gb10 Flash-Next target)

nvfp4 .cu symlinks:
- hyper_connection.cu, ple.cu, qsa_indexer.cu -> ../../../gb10/qwen3.8-flash-next/nvfp4/
- gated_delta_rule.cu -> ../../qwen3.6-35b-a3b/nvfp4/ (strix-hip mirror choice)
- gated_delta_rule_wy17.cu -> ../../../gb10/qwen3.6-35b-a3b/nvfp4/
- moe_w4a16_grouped_gemm.cu -> ../../qwen3.6-27b/nvfp4/ (strix-hip HIP port)
- w4a16_gemm.cu -> ../../qwen3.6-35b-a3b/nvfp4/ (strix-hip HIP port)
- vision_encoder.cu -> ../../qwen3.6-35b-a3b/nvfp4/

MODEL.toml is a real file (not a symlink like qwen3.6-35b-a3b's) because
[expected_absent] is per-hardware: it drops the gb10-only declarations for
the strix-hip-only probes (dense_gemv_fp8w, w4a16_gemv_dp4a x3,
w8a16_gemm_n_m128) since those kernels resolve on gfx1151; every other
section is verbatim.

KERNEL.toml carries the strix-hip qwen3.6-35b-a3b [build] flags and module
map verbatim; none of gb10 Flash-Next's extra module aliases (turbo/bf16k/
fp8k paged-decode, wht_bf16, tq_plus_innerq_apply) are added because those
.cu files do not exist on strix-hip.
…ule_wy17

The HIP mirror flattens each kernel source dir into OUT_DIR/hip_mirror/<hash>/,
so the quoted include '../../common/gdn_reduce.cuh' escapes to a nonexistent
dir and hipcc fails with 'file not found' — wy17 is the only strix-hip kernel
that reaches across dirs. Spell it 'gdn_reduce.cuh' and materialize the header
beside it via a relative symlink in both nvfp4 dirs (gb10 35b-a3b ->
../../common, strix-hip flash-next -> ../../common; the two gdn_reduce.cuh
copies are byte-identical). NVIDIA PTX verified identical: nvcc --ptx
-arch=sm_121 --fmad=false on the original and edited file produces a
byte-identical body (modulo .file/comment lines).
…lMem

cuMemGetInfo_v2 used to clamp tot = min(totalGlobalMem, commit_limit), so
the env could only lower the ceiling. On Strix Halo at VGM 32 GB the runtime
backs allocations with WDDM shared memory on top of the carve-out:
totalGlobalMem reads 89.47 GiB while a hipMalloc+kernel-touch ladder measured
106 GiB (2026-09-19). An explicitly set ATLAS_UMA_COMMIT_LIMIT_GB is now
authoritative (tot = commit_limit); the unset path still reports
totalGlobalMem - ~14 GiB driver reserve. HIP-shim only — never compiled for
gb10 (build_hip_shim*/hip mirror path).
Both Qwen3.8-Flash-Next NVFP4 packs measure device-after-load / on-disk at
~1.15 (nvidia pack 84.0/73.33 GB, RadixArk ~90.4/78.19 GB). The generic 1.3
over-projects ~10 GB and refused the boot pre-flight on a 96 GB Strix pool;
1.2 keeps ~4.5% margin over measured. New arm precedes the fp8 check; test
asserts qwen4_exp -> Some(1.2) and non-fp8 qwen3_5 -> None.
On ROCm 10 hipMemGetInfo succeeds (total=totalGlobalMem=89.47 GiB, free real),
so the synthesized-commit path never ran and ATLAS_UMA_COMMIT_LIMIT_GB was
silently ignored — observed: 'GPU 0: 89.5 GB total' with the env at 104.
The explicit ceiling now overrides both branches (free = limit - tracked used,
consistent with the synthesis path); the unset behavior is unchanged.
…xp sigmoid/grouped norms)

strix-hip/common/rms_norm.cu was a strict-subset snapshot of the gb10 file —
zero strix-specific lines — missing rms_norm_grouped and the three sigmoid
twins (gated_rms_norm_sigmoid / _f32_input_sigmoid / _prefill_sigmoid) that
qwen4_exp requires through a hard gpu.kernel() lookup. First Flash-Next boot
on gfx1151 failed closed: 'Kernel lookup norm::gated_rms_norm_sigmoid:
hipErrorNotFound'. Follow the established strix-hip convention (88 common/
files already symlink ../../gb10/common/) so the twins cannot drift from
their SiLU originals, which is the same reason they live in common/ at all.
On the native-HIP target cuBLASLt is a stub (libcublaslt_stub.cpp returns 1
for every call), which stranded the ~20 spark-model projection sites that
route BF16 prefill GEMMs through cublaslt::bf16_gemm_act_weight_t — Qwen3.8-
Flash-Next on gfx1151 failed every prefill at "QSA qk projection (prefill)"
because cublasLtCreate fails on the very first call.

- Add a process-global Bf16GemmFallback installed via install_bf16_fallback
  (first install wins). In bf16_gemm_act_weight_t, a ctx() error now routes
  to the installed fallback instead of propagating; NVIDIA behaviour is
  unchanged because ctx() succeeds there and the fallback is never
  consulted.
- Add make_bf16_fallback(pipelined, scalar): launches
  dense_gemm_bf16_pipelined via cuLaunchKernel when the kernel resolved and
  its vectorized-load contract holds (K % 8 == 0, 16-byte-aligned operands),
  else the scalar dense_gemm_bf16 which has no shape/alignment requirements.
- Mirror the new signatures in cublaslt_metal_stub.rs for API parity.
- Unit test: first install returns true, second returns false; where ctx()
  fails deterministically (CI GPU stubs / HIP shim) the GEMM reaches the
  installed closure with the exact (m,n,k) it was given.
…GEMMs

Install the cublaslt BF16 fallback once per process in init_gpu_backend,
right after AtlasCudaBackend comes up and while the kernel registry is
live, resolving gemm::dense_gemm_bf16_pipelined (optional — handle 0 when
a target lacks the tensor-core variant) and gemm::dense_gemm_bf16 (always
present) up front so the installed closure only ever launches kernels.

Fires only when cuBLASLt ctx() fails, so NVIDIA serve paths are untouched;
on the gfx1151 HIP target it is what lets every cublas_bf16_proj{,_dense}
call site reach a real GEMM.
Export DENSE_GEMM_BF16_PIPELINED_TILE (128), _PIPELINED_THREADS (256),
and _SCALAR_TILE (16) from spark_runtime::cublaslt and consume them in
both make_bf16_fallback and the ops::gemm_dense launchers
(dense_gemm, dense_gemm_bf16_pipelined). Pure refactor — identical
grids/blocks, no behaviour change.
…loop watchdog; correct the serial control for its rollback rework (≈2.1×, not 2.6×)
AzeezIsh and others added 5 commits September 22, 2026 02:33
…nt declares

The on-device DFlash2 candidate selector reduced each row's unary logits
to a top-4 list and evaluated the bilinear score over only the first 64
selector dimensions (`s_context[64]`, `tid < 64`, two-warp partial sum),
while the loader reads `selector_rank` (256) and `selector_top_k` (16)
from the drafter config and the host fallback already honours both. The
fast path therefore evaluated a cheaper selector than the trained one.

The kernel now takes `top_k`, keeps per-thread/warp/block top-k lists up
to DF2_SEL_MAX_TOP_K=16, builds the context vector over the full rank up to
DF2_SEL_MAX_RANK=256, scores one candidate per warp across the whole rank,
and orders candidates (value desc, index asc) so tie-breaks match the
engine's first-index-wins argmax rule. `Dflash2CandidateSelector::new`
fails fast when a checkpoint exceeds the caps instead of degrading; the
host fallback uses the same order. Pinned: kernel arity (10), the Rust
mirrors of the kernel caps, gb10/strix-hip copies byte-identical, and an
ignored GPU parity test against an f32 host reference.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ip qwen3.8-27b

Generated with [Devin](https://devin.ai)

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

On NVFP4-packed checkpoints the shared lm_head DenseWeight pointer
addresses PACKED bytes (e.g. nvidia/Qwen3.8-27B-NVFP4 ships lm_head.weight
as U8 [248320, 2560] — ~636 MB, not ~2.5 GB of BF16). The decode path
already guards this: the drafter's logits GEMM routes through the NVFP4
twin via w4a16, with a comment naming the exact failure — a BF16 GEMM on
packed bytes reads 4x the buffer and faults (CUDA-700 ILA).

Phase G missed that guard in two places:

1. from_weights.rs quantized lm_head_shared as BF16 unconditionally.
   With ATLAS_DFLASH_DRAFTER_FP8=1 the load crashed deterministically on
   gfx1151 — 90+ gfxhub page faults, hipErrorIllegalAddress — after all
   35 per-layer quantizes succeeded, at the lm_head launch.
2. The fp8 decode branches in batch_forward.rs and forward_block.rs fell
   back to dense_gemm_bf16_pipelined on lm_head_shared when the FP8
   mirror was absent — the same OOB read, deferred to first decode.

Fix mirrors the existing non-fp8 dispatch: skip the lm_head quantize
when lm_head_nvfp4 is Some (the packed-twin signal), and collapse the
fp8 branch into the shared dispatch — when no FP8 mirror exists the head
drafts logits through the NVFP4 twin exactly like the BF16 path. On
checkpoints whose lm_head is genuinely BF16 (no nvfp4 twin) the quantize
and the fp8 row-scaled path are unchanged.

Validated on AzeezStrix gfx1151: ATLAS_DFLASH_DRAFTER_FP8=1 now boots
clean — Phase G logs "drafter weights ready as FP8" with the lm_head
quantize skipped — and a probe request drafted via the nvfp4 fallback
(mean_na=2.583, p1=0.917, coherent output). cargo fmt clean.

Generated with [Devin](https://devin.ai)

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

Found on winbox serving Qwen3.8-Flash-Next-NVFP4 (2026-09-20, gfx1151;
identical logic on GB10): on the MinHeap+unittest prompt both decode arms
were cut at 641 tokens mid `values = [8, 3, 1, 6, 4, 2, 7,`.

  serial:  decode_logits_content — "Content-loop watchdog fired
           (period-2…64 repeat); rolled back to boundary, re-steering
           content_tokens=570 dropped=70 rollback=1" → rollback=2 →
           "ending response early (rollback declined)"
  MTP:     emit_step — "Content-loop watchdog fired in MTP/emit path …
           ending response"

detect_content_token_loop_normalized_with maps every numeric token to
NUMERIC_SENTINEL, so a comma-separated list of distinct numbers
normalizes to `N , N , N , …` — a period-2 anchored repeat at
NORM_MIN_REPEATS=4. Any list of ≥5 distinct numbers (test fixtures,
arrays, tables) tripped it.

Fix: a new `VocabMasks::punctuation` (token decodes to non-empty
ASCII punctuation/whitespace) lets the normalized detector learn the
matched period via detect_token_loop_period and decline when the window
is only sentinels and punctuation. A real numeric runaway (`1, 1, 1, …`)
still fires — identical tokens repeat literally, so the exact detector
catches it. `punct == None` keeps the legacy fail-open behaviour.
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Superseded by #80 (port/fnext-win-r3): the same Flash-Next Windows stack rebased onto main @ 5b07b95 with no conflicts, plus a cherry-pick of #78. Leaving this open until #80 is reviewed.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Triage (2026-09-26). Recommend closing as superseded by #80: the same stack, rebased onto main. This branch also fails the ≤500-LoC cap, the nvcc build and the release matrix, which #80 passes.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #80. All 35 of this branch's commits are patch-equivalent to commits in #80 or on main (checked with git cherry). The branch is kept.

@AzeezIsh AzeezIsh closed this Sep 27, 2026
AzeezIsh added a commit that referenced this pull request Sep 28, 2026
…transpose (2k TTFT ~2x) (supersedes #54)

Conflict in docs/porting/QWEN38_STRIX_PORT.md: kept both sections.
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