Repository navigation
Qwen4-27B (dense) on native CUDA, GB10: shape parameterization ahead of the checkpoint (RFC) #1244
Description
This is an RFC, not a claim. Nothing here is started. We'd like to know whether you want the preparation work below, and in which shape, before any weights are public.
What is known (from Intel's merged kernel PR only). analytics-zoo/vllm-xpu-kernels#22 (merged 2026-10-19) adds kernels for a dense "Qwen4-27B". Line numbers are at its head 265bbe2:
- Hidden 5120; hyper-connections with 4 streams, width 20480 (
csrc/qwen38/hc_dense_sycl.cpp:23-25). - HC low rank 640 at TP1 (
:519), 320 at TP2 (:242). - GDN projections at TP2: [8192, 5120] and [48, 5120] (
csrc/qwen38/fp8_dense.cpp:153-154); GDN norm heads 48 (TP1) / 24 (TP2) x 128 (custom-kernels-inventory.md,try_gdn_norm). - Attention head dim 256 (
fp8_dense.cpp:378-379). Local Q12/KV2 at TP2 (csrc/qwen38/qsa_sycl.cpp:1122-1127,vllm_xpu_kernels/qwen38_qsa.py:35,204). The code takes KV = Q/6 (fp8_dense.cpp:389), so the full model is Q24/KV4 at TP1. That is inferred. - Dense FFN: 14336 (7168 at TP2) appears as a GEMV shape (
fp8_dense.cpp:33-34) and in the INT4 tests as 28672x5120 and 5120x14336. The same numbers are also the QKV width, so "intermediate 14336" is inferred, not stated.
The PR does not give the layer count, the layer schedule, or the MTP shape. It says Qwen4 QSA weights were not provided to the authors, and QSA with MTP is not enabled there. A placeholder repo, IteraCompute/Qwen4-27B-NVFP4, exists on the Hub (README only, tagged work-in-progress, no config).
What TF already has.
qwen3_5dense 27B is the same skeleton: hidden 5120, 24/4 heads, head dim 256, GDN 16/48/128/128 (families/qwen3_5/config_checks.zig:177). Its CUDA geometry reads intermediate, layers and heads from the config (cuda_geometry.zig:243-248) and accepts a dense FFN.- Flash Next: HC count and rank come from the config (
flashnext/config.zig:235-236,weights.zig:59-68). The GDN kernels use the same 16/48/128/128 (kernels/cuda/flashnext_gdn.cu:6). QSA runs at KV2, head dim 256, with NQ/NKV passed at runtime (kernels/cuda/flashnext_attn.cu:72).
What has to change.
flashnext/config.zig:231-234requiresnum_experts,num_experts_per_tokand the expert widths, and:200accepts onlyqwen4_exp. Dense needs these optional plus a dense FFN width.- The CUDA path refuses any other shape:
cuda_config.zig:11-34, from constants incuda_prompt_wt.zig:10-31(48 layers, 2560, rank 320, 512 experts, Q24/KV2,proj_n),cuda_attn.zig:9-20,cuda_moe.zig:8-12,cuda_gdn.zig:9-13. Layers, hidden, HC width and rank, heads and the FFN width become fields. - A dense SwiGLU FFN in the Flash Next graph, from the
qwen3_5dense lane. - QSA at Q24/KV4 and HC at 5120x4 (20480).
Proposed steps, each a small PR that can land before the checkpoint.
- Config: dense or MoE, with a synthetic-shape unit test. No kernels.
- Parameterize the CUDA constants listed above. The 2560 checkpoint must produce identical bits and pass the existing gates.
- Synthetic kernel-contract records at the new shapes (HC 20480, rank 640, QSA Q24/KV4, FFN 14336) against the f64 reference.
- Dense FFN node in the graph, tested the same way.
Waits for the checkpoint: config.json, tensor names, the layer schedule, the MTP head, the quant format, and whether every full-attention layer has the indexer.
Unconfirmed:
- That Qwen4-27B is the final name, and that Intel's dense model is the one that will be released.
- FFN intermediate, layer count, and the TP1 head counts (all inferred).
- Whether the indexer columns sit in the QKV projection (Intel's QKV widths have none).
- Anything about the placeholder repo beyond its metadata.
Questions for @ashhart:
- A separate family, or a dense mode in
flashnext? - Does anyone at TF already have the config or weights?
- Do you want steps 1-3 ahead of the release, or after it?
Activity
jschmied commentedon Oct 24, 2026
Additions since the first post:
hc_lowrankhas to come from the config.qwen4_expbuilds a sparse MoE block in every decoder layer and requiresnum_experts > 0.tiny-dense-devprofile (crates/hipfire-arch-qwen4/reference_oracle/QWEN4_PROFILES.md). It is dense SwiGLU in place of MoE, labeled non-upstream, and goes up to hidden 5120. It could serve as an extra cross-check next to our own f64 reference.The prep steps from the first post (config, shape parameters, contract records at the new shapes, a dense FFN node) are in progress locally and will be offered as small PRs only if wanted.
jschmied commentedon Oct 24, 2026
The prep steps are on our fork, as branches rather than PRs. Each step stacks on the one before, on main 6244c62:
qwen4-configqwen4-shapesqwen4-contractqwen4-ffnDense detection
build/v0.31.0, theqwen4_expXPU decoder). A layer is MoE when it is not inmlp_only_layers,num_experts > 0and(layer_idx + 1) % decoder_sparse_step == 0. Otherwise it is a denseQwen3NextMLPwithintermediate_sizeandhidden_act.hc_countandhc_lowrank; a dense config has no 320 default.Step 2 is bit-identical on Flash Next. The CUDA constants now come from one comptime table, and loading checks each kernel's limits and names the offending field.
nvidia/Qwen3.8-Flash-Next-FP4-Localserved from main and from the branch gives the same sha256 for 200 greedy tokens. Two prompts were used: 64 tokens, and 9,592 tokens, which runs the QSA indexer.Step 3
Step 4 is tested on synthetic weights against f64 at hidden 5120 and FFN 14336. Nothing loads such a checkpoint yet.
Main fixes carried in step 3, each its own commit:
w4a8_tests.zigagainst the currentprompt()signature;On this GB10 the full
kernel-contracton main still stops at the w4a8 record withCUDA_ERROR_MISALIGNED_ADDRESS, which poisons the records after it. I have not looked into that yet.Still fixed in the CUDA path
QSA memory follow-ups, not changed here
Happy to turn any of these into PRs if wanted.
jschmied commentedon Oct 25, 2026
Follow-up branch
qwen4-next, stacked onqwen4-ffn. Each fix is its own commit.Review fixes
Ffn.initfailed after taking them.mlp_only_layersentry past the last layer is an error instead of being dropped.projNis marked provisional.New
layer_types, falling back tofull_attention_interval. The two must agree when both are present. A host test checks all 48 Flash Next layers against the old formulas.zig build compile-flashnext-dense).Unchanged on Flash Next: greedy output (drafted, plain and 4 concurrent streams, at 64, 9,592 and 31,332 tokens) hashes the same on this branch and on main. Full
zig build testpasses and lean_check shows 0 new.Open, for when a dense checkpoint exists
ashhart commentedon Oct 26, 2026
/atc claim
Changelog and recipe: Qwen4 dense preparation passes its synthetic de…
ashhart commentedon Oct 26, 2026
Qwen4 dense preparation landed on main in 03c2820: the native binary admits
qwen4andqwen4_textconfigs on Metal and CUDA, sharing Flash Next's layer graph with a dense feed-forward, and refuses geometry its kernels don't cover before allocating. Synthetic device gates pass on an M3 Ultra (zig build test-qwen4-metal) and a GB10 (tf-cuda-test qwen4): nonzero checkpoints through the serving engine match a binary64 reference with no tolerance, across prompt cuts, resume, concurrency and copied drafts. No real checkpoint, speed or memory fit is claimed yet; on release day we'll check the published config and tensor names and run the model on both.ashhart commentedon Oct 27, 2026
/atc release
ashhart commentedon Oct 27, 2026
Thank you, @jschmied, for the RFC and the preparation branches. The dense Qwen4 preparation is on main (21c7df9 through 03c2820): the native binary admits qwen4 and qwen4_text configs on Metal and CUDA, refuses geometry its kernels don't cover, and passes synthetic device gates on both. On release day we'll check the published config and tensor names and run the checkpoint; please open a new issue if anything in the real release differs. Closing this RFC as done.