Skip to content

XPU: validate Qwen4-35B-A3B FP8 checkpoint geometry - #6372

Merged
ashhart merged 3 commits into
ashhart:mainfrom
supernovae:xpu/qwen4-35b-fp8-host
Dec 5, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
supernovae:xpu/qwen4-35b-fp8-host

Conversation

@supernovae

@supernovae supernovae commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Add the offline xpu-flashnext --check-checkpoint command for the official Qwen4-35B-A3B FP8 checkpoint. It validates the expert and Engram/PLE headers, checks exact PLE gather across a chunk seam, and reports the Xe2 TP=2 and TP=4 geometry and resident weight floor. This is the first host-validation slice from the maintainer's scope.

Checks on this head

  • Head commit 7c26d0343cc30eb9d0331a328b413533928ffd11.
  • Lean checker 88 findings on the base and 88 on this head, zero new. PR preflight and changed-file Zig formatting passed.
  • Host tests zig build test-flashnext-xpu-host passed six tests with zero failures or skips. The host-only xpu-flashnext build passed.
  • Pinned checkpoint The checker validated all 30,720 routed expert matrices and FP32 block-scale headers. It mapped all 128 PLE shards and produced the same six BF16 rows across the chunk seam, with hash 2a6d799b4b8e9e86. Changing the hidden size or the FP8 scale block size made the diagnostic reject the fixture.
  • CI GitHub CI passed changes, fast-gate, verify, fmt, pytest and zig on the head above. Unaffected jobs were skipped.
  • Platform coverage Linux x86_64 with Zig 0.17.0 and ocloc 26.27.039122. Offline Qwen4 host checks and legacy BMG-G31 device checks are covered. CUDA, HIP, Metal and Windows device runs are outside this Xe2 host slice.

Reproduction

Use Zig 0.17.0. Set OCLOC and NGEN_HEADERS to the compiler and the oneDNN nGEN headers. Set QWEN4_DIR to the local snapshot of Qwen/Qwen4-35B-A3B-FP8 at 4d35041fcd017a5608bd83bb65388757919d029c.

zig build test-flashnext-xpu-host
zig build xpu-flashnext -Doptimize=ReleaseFast -Docloc="$OCLOC" -Dxpu-device=bmg -Dngen-include="$NGEN_HEADERS"
zig-out/bin/xpu-flashnext "$QWEN4_DIR" --check-checkpoint
TP Experts per rank Query heads per rank KV heads per rank Resident weight floor per rank
2 128 8 1 16.43 GiB
4 64 4 1 8.69 GiB

Receipt

  • Paths and boxes The new checkpoint command runs without GPUs. The device regression control uses four 32 GiB Arc Pro B70s on Linux with Level Zero.
  • New switch --check-checkpoint runs the explicit offline diagnostic and exits after reporting validation.
  • Main against head The four-card TensorFold/Qwen3.8-Flash-Next-MLX-4bit-MTP@2b170fa6309d5d1ee380b35636075fac7945f286 fixture used a 2,048-token prompt and 48 greedy output tokens. Main and this head returned identical token IDs. Perfect and incorrect speculative windows both matched plain decoding. Embedded MTP matched plain and accepted 30 of 41 proposals on both builds. The single-run main/head samples were 626.7/669.0 tok/s in prefill and 53.4/54.3 tok/s in plain decode.
  • Serving benchmarks and speed receipt N/A for the offline checker. Results for Qwen4 inference belong to the arithmetic and serving follow-ups.
  • Weights licence The pinned checkpoint is Apache-2.0. The PR uses downloaded model files for the offline check.

Checklist

  • One reviewable host slice tied to the maintainer's scope and its commit.
  • Added host checks cover invalid TP and an out-of-range PLE row. The offline checker passed on the pinned checkpoint.
  • Changed sources pass formatting and introduce no lean findings.
  • Outgoing source and commit metadata were checked for private paths and contributor identity.

@supernovae

Copy link
Copy Markdown
Contributor Author

Downstream prefill measurements are available for reviewers following #6317. This PR covers the FP8 checkpoint headers, Engram/PLE geometry and TP allocation plans. The measurements below came from the subsequent native serving and sparse-index changes.

On four Arc Pro B70s with the official FP8 W8A16 target, PLE, BF16 DFlash2, prefix caching disabled and 4,096-row solo chunks, the sharded indexer reduced median client time to first token from 10.586 to 9.972 s at 32,768 tokens and 22.295 to 20.246 s at 65,152 tokens. The latter is 3,218 input tok/s. All 256 generated IDs per scored request matched the plain reference. At the default 2,048-row chunk size the 65,152-token result was 23.09 to 21.11 s in one paired run. The earlier GDN/chunk comparison is tracked in #6395.

The follow-up qualification and maintainer's additional boundary and exchange gates are tracked in #6413. Raw samples and reproduction

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Thanks @supernovae. The change stays inside the XPU family, and the existing affine shape values and PLE arithmetic are unchanged.

Three things are left before landing, and we'll do all of them ourselves on this branch:

  • Pin the published checkpoint. We'll add Qwen/Qwen4-35B-A3B-FP8 at revision 4d35041fcd as a fixture (its config plus the expert and PLE header facts the checker reads) and test that the new parser accepts it, with one negative case per refusal.
  • Put the filesystem checker in the host test graph, so the existing XPU host step runs every new error branch against those fixtures.
  • Widen the chunk test. Its only split sits right after EOS, which hides a history reset. We'll keep that case and add ordinary seams with a reset control.

This validates checkpoint geometry; FP8 serving and its token checks come with the follow-up PRs. Nothing more is needed from you here.

  • Synthena

@ashhart
ashhart force-pushed the xpu/qwen4-35b-fp8-host branch from 7c26d03 to 1ab9104 Compare December 5, 2026 07:06
@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Thanks, @supernovae, for the geometry check and the FP8 PLE path. The published checkpoint's config and layout pass it.

The published checkpoint passes on its layout. For Qwen/Qwen4-35B-A3B-FP8@4d35041fcd:

  • Its unedited config.json parses to the FP8 shape.
  • Every expert matrix (40 × 256 × 3, FP8 with FP32 block scales) reads at its published name, dtype and shape.
  • The PLE table's 128 shards are each exactly the 1,250,028 × 128 rows your hash derives from the config. We checked this against the index and all 33 shard headers.

What we added on your head (rebased onto current main with no conflicts; your commit is unchanged):

  1. Published acceptance in the host tests. A fixture holds the unedited config.json and a small extract of the index and header facts the checker reads, with the sha256 of each full file and the repo@revision.
    • geometry.parse accepts the real config.
    • One negative case per refusal family, each varying only that field: missing head_dim, vocab_size one past, layer_types missing or one short, a non-integer field, and a PLE layer list other than [2].
    • Removing each check fails its case.
  2. The checker in the host test graph. It moved from xpu_main.zig into xpu_checkpoint.zig; --check-checkpoint prints what it returns.
    • test-flashnext-xpu-host builds a sparse checkpoint at the published names, dtypes and shapes, and runs the checker on it.
    • It then runs every reachable new error branch: a missing expert or one of another dtype or shape, the PLE scale and hash vectors missing or misshapen, an empty head, a gap between heads, a table one row too short, a NaN, zero or negative scale, a misshapen n-gram shard, and all-zero gathered rows.
    • The PLE width check cannot fail once the geometry passes, since parse pins the same fields, so it stays as a guard.
    • Expert refusals now name the tensor instead of logging, and the n-gram shape log is skipped under test, so the host tests can reach those branches.
  3. Chunk seams. The EOS seam stays, and every split of the same six tokens into non-empty chunks (32 of them, ordinary seams 1 and 5 included) must equal one whole call, rows and history both. A planted history reset at an ordinary seam fails it.

Nothing is left that we need from you. We have no Intel GPU, so if you can run --check-checkpoint on the real files and paste its output here, that is the last confirmation we can't get ourselves.

  • Synthena

@supernovae

Copy link
Copy Markdown
Contributor Author

Ran the reviewed head 1ab910436c9bd15ffae3971407c5ea4bf43133b4 against the real, unmodified Qwen/Qwen4-35B-A3B-FP8@4d35041fcd017a5608bd83bb65388757919d029c checkpoint on the four-B70 host. The NVMe checkpoint check exited 0. The host test target also passed all 24 tests.

FP8 pass: 30720 expert matrices and FP32 block-scale headers
TP=2: 128 local experts, 8 query heads, 1 KV heads, weight floor 17635737600 bytes/rank
TP=4: 64 local experts, 4 query heads, 1 KV heads, weight floor 9326428160 bytes/rank
PLE pass: 128 shard slices, 20480458752 mapped bytes, 6 rows of 2048 BF16 values, hash 2a6d799b4b8e9e86 (whole == each of 32 chunkings)

Reproduce with zig build xpu-flashnext test-flashnext-xpu-host and the BMG build options, then xpu-flashnext "$FP8_DIR" --check-checkpoint. This confirms the checkpoint headers, mapped PLE lookup, and all 32 ways to chunk the six-token fixture.

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

READY to land on this head. Author run on this head against the real, unmodified Qwen/Qwen4-35B-A3B-FP8 at 4d35041fcd: the checkpoint check exits 0 (30720 FP8 expert matrices, TP=2 and TP=4 layouts, PLE lookup equal across all 32 chunkings) and the host target passes 24 of 24. XPU-only; we have no XPU hardware, and no other backend's code changes.

  • Synthena

@supernovae

supernovae commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor Author

With the FP8 reader now in main, I prepared a tested merge of the reviewed 1ab910436c9b and main 0b9102458dcd. It retains the published-config tests from this PR and the four geometry tests that shipped in #6424. The CLI routes the real checkpoint through the audited checker. Native build and focused host tests: 66/66 steps succeeded; 29/29 tests passed. The same official FP8 revision on NVMe returned:

FP8 pass: 30720 expert matrices and FP32 block-scale headers
TP=2: 128 local experts, 8 query heads, 1 KV heads, weight floor 17635737600 bytes/rank
TP=4: 64 local experts, 4 query heads, 1 KV heads, weight floor 9326428160 bytes/rank
PLE pass: 128 shard slices, 20480458752 mapped bytes, 6 rows of 2048 BF16 values, hash 2a6d799b4b8e9e86 (whole == each of 32 chunkings)

Rebased head

The minimal integration combines the current checkpoint head 369b528df30c and TFQ Ultra on main after #6426 landed. It passed 68/68 build steps and 40/40 host tests, including all ten geometry tests. The real FP8 and Ultra checkpoints both passed every Engram chunking. The Linux native adapter and GPU kernels match the previously qualified Ultra head byte-for-byte.

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

READY to land on this head. Our rebase onto 20cf98c: the XPU build file and the shape tests keep both sides (main's four tests byte for byte plus this PR's six); host tests, serving pins, fmt/AST pass; code as on the READY head 1ab9104.

  • Synthena

@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

READY to land on this head. Same tree as the head the train passed; the only change adds author credit trailers to our two commits.

  • Synthena

ashhart and others added 3 commits December 5, 2026 11:58
…e refusal per geometry check

zig/tests/fixtures/qwen4_fp8 holds the unedited config.json of
Qwen/Qwen4-35B-A3B-FP8@4d35041fcd017a5608bd83bb65388757919d029c and
facts.json, an extract of the index and all 33 shard headers that the
checker reads (expert and PLE tensor names, dtypes, shapes, counts and
the PLE tensors' offsets) with the sha256 of each full file.

test-flashnext-xpu-host now parses the published config to the FP8
shape, binds it to its digest, and refuses one case per check, each
varying only that field: no head_dim, vocab_size one past, layer_types
missing or one short, a field that is not an integer, and a PLE layer
list other than [2]. Removing each check fails its case.

Co-authored-by: Byron Miller <1461719+supernovae@users.noreply.github.com>
…he host tests, every PLE chunking checked

xpu-flashnext --check-checkpoint printed from code in xpu_main.zig that
no host test reached. The check now lives in xpu_checkpoint.zig and
returns what it read; --check-checkpoint prints it as before.
test-flashnext-xpu-host builds a sparse checkpoint at the published
names, dtypes and shapes (facts.json), with the hash vectors the config
derives and non-zero codes in the rows the check gathers. It passes
(30720 expert matrices, 128 PLE shards of 1250028 x 128) and runs each
reachable refusal: an expert missing or of another dtype or shape (by
name), the PLE scale or a hash vector missing or misshapen, an empty
head, a gap between heads, a table one row short, a NaN, zero or
negative scale, a misshapen n-gram shard, all-zero gathered rows and a
refused geometry. Expert refusals pass a Why instead of logging, and
the n-gram shape refusal's error log is skipped under test, so the
host tests can reach them.

The chunk check keeps the EOS seam and adds every split of the same
tokens into non-empty chunks (32, ordinary seams 1 and 5 among them),
each required to equal one whole call in rows and history. A planted
history reset at an ordinary seam fails it.

Co-authored-by: Byron Miller <1461719+supernovae@users.noreply.github.com>
@ashhart
ashhart force-pushed the xpu/qwen4-35b-fp8-host branch from 369b528 to 530eee5 Compare December 5, 2026 12:22
@ashhart
ashhart merged commit 44ead21 into ashhart:main Dec 5, 2026
22 of 26 checks passed
@ashhart

ashhart commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Thank you @supernovae. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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.

2 participants