~/satyajit

Qwen4-27B: what a merged kernel PR does and does not leak

mdjsonmcp

2026-10-26 · 14 min · qwen · inference · sparse-attention · speculative-decoding · quantization

A 1:49 narrated explainer, drawn in code. Every number and picture in it is this article's own; the sources are below.

› transcript

Hi, I'm Scarf! A post says a merged kernel change leaks a dense Qwen four model. Let's see what the code really shows. The change is real, but it says far less than the post claims. And the architecture it points at is already public. The screenshot names two per-rank shapes: Q twelve over K V two, and a hidden width of five thousand one hundred and twenty. Both match the released twenty-seven-billion model: twenty-four query heads over four K V heads. What the dense model adds is already public in vLLM. A token climbs three Gated DeltaNet layers, then one sparse attention layer, repeated, with a dense feed-forward block. Beside every layer run residual lanes. Four is Flash-Next's count, so for the dense model it is reasoned. The sparse layer compresses keys into blocks of four, and reads only two thousand and forty-eight tokens. Dense attention reads every earlier key. At two hundred and sixty-two thousand tokens, that is seventeen gigabytes a step. Sparse attention first compresses keys into blocks of four, and scores them. It keeps the best blocks. The read stays near two thousand tokens. Decoding one stream is bound by memory. Bandwidth is the card's memory speed. Each step streams the weights once. Reasoned ceilings: about thirty tokens a second on one card at INT4, and sixty on two. A kernel change proves kernels exist. The shapes are inference, and the release is unconfirmed. To recap: a real change, shapes carried over, and no release. Every source is in the full article. I'm Scarf. Bye!

Why read this

Essentialtop 10%

The leaked PR's text against two configs and the public Qwen4Exp code, references run on CPU, every spec labelled measured, reasoned or unconfirmed.

  • Original, source-checked analysis
  • Widely used
  • A new technique

Inference & servingNeeds a workstation GPUPractitioner teardown

How this was scored
Is it new?
2 of 3: A real new idea, method or capability
Can I trust it?
3 of 3: Reproduces the headline result, or shows from primary files it is wrong
Can I run it?
2 of 3: Open code or weights with real limits
Will I understand it?
2 of 3: Mechanism from first principles with figures
Can I act on it?
2 of 3: A concrete recipe, numbers or comparison
Will it last?
1 of 3: Relevant for months
Does it affect many?
2 of 3: A widely used model, tool or lab release
Only here?
3 of 3: The only place this analysis exists

Score 77 of 100, ranked 36 of 613 rated articles. Each question is answered 0–3 by hand, and a 3 is rare. How articles are scored

On 25 October a post with 83,000 views said that "Qwen4-27B architecture is being reverse-engineered from a merged kernel PR", and listed what the PR supposedly leaks: INT4 on one or two cards, MTP with four draft tokens, FP8 at TP2, four residual streams, QSA sparse attention. The post carries two images. One is the Qwen 4 logo. The other is a screenshot of the PR.

I read the screenshot, then went looking for the code behind it. Three things come out.

Labels used throughout: measured means I read it in a file or ran it. Reasoned is my arithmetic on those. Unconfirmed means no public source says. I did not find a reported figure for the 27B at all, and that is a finding too.

What the screenshot says

A dark-theme GitHub pull request page titled 'Enable Qwen3.8-flash-next 8 cards fp8 & int4 and optimize qwen4-27b', marked Merged, 10 commits and 56 files changed, into analytics-zoo:downstream/v0.31.0. The description, in Chinese, has a scope paragraph and a table with rows for FP8 compact MoE, INT4, HC and GDN, HC prefill, compact INT4 large prefill, QSA, other fusions, and safety.
The screenshot the post leads with. The page is in Chinese; I translate it below. (PR page, as screenshotted in the X post by @0x0SojalSec.)

The title is "Enable Qwen3.8-flash-next 8 cards fp8 & int4 and optimize qwen4-27b". It merged 10 commits touching 56 files into analytics-zoo:downstream/v0.31.0, from a branch dated 2026-10-19. Those are measured from the image. My translation of the scope paragraph, with the model names as written:

SYCL and SYCL-TLA kernels for downstream v0.31.0: Qwen3.8-Flash-Next at TP4 INT4 and TP8 INT4/FP8, and the Qwen4-27B dense model at TP2 FP8 and TP1/TP2 INT4. Mainly covers M from 1 to 8, MTP draft=4 with batch 1, and large prefill.

So the post's list is a fair reading of the scope sentence. But look at the proportions. Most of the PR is for Flash-Next, the 125B mixture of experts with 512 experts, at four and eight cards. The 27B gets one clause. The post's headline, "you might not need a MoE cluster", is about the smaller half. Several replies said the same: a 27B is dense, so the sentence is a non sequitur.

Three more things the image shows:

What I could not do. I could not open the PR. analytics-zoo is the name of Intel's older BigDL-era organisation, and the five public repositories a search returned for it hold none of this; the repository carrying downstream/v0.31.0 is not readable without credentials from my session. I cannot verify the author's affiliation either. The claim "Intel's vLLM XPU kernels merged this" is therefore unconfirmed as worded. What I can verify is below: the public repositories that sit next to it.

What the public code shows

Two public repositories carry related, readable evidence.

vllm-project/vllm-xpu-kernels (checked at daf6240, 26 October). Commit 8b95ea6, "Fix Qwen4Exp TP=2 kernel coverage and DP padding corruption (#635)", from Intel's hongbo.zhao, 14 October. It adds one row to the paged-decode table: query group 16, head size 256, page size 64. The comment says Qwen3.8-Flash-Next ("Qwen4Exp") at TP2 has a per-rank GQA ratio of 12, which falls in the 16 bucket. (Measured.) There is no Qwen4-27B anywhere in that repository, and no QSA kernel. Its public mHC kernels (csrc/xpu/mhc) were written for DeepSeek-V4; they carry HC = 4 and 20 Sinkhorn repeats.

One oddity, measured from the config: Flash-Next has 24 query heads over 2 KV heads, so its GQA ratio is 12 at TP1 as well, not "at most 8" as the commit message says. I cannot explain that gap. It does not change the fix.

vllm-project/vllm (6674eed, 26 October). It contains a package vllm/models/qwen4_exp/: hyper-connection ops, a QSA attention with its indexer and selection kernels, an MTP module, per-layer embeddings, and test files for each. It was added on 31 August by "Support Qwen3.8-Flash-Next (#53896)". Two facts matter here:

That second point is the one the post's headline hides. The PR title says qwen4-27b, a name from someone's branch. Public code says Qwen4Exp, and attaches it to a model already on the Hub.

The shapes, compared with what exists

I fetched config.json for both released models. The table sets those against the PR's text.

FieldQwen3.8-27BQwen3.8-Flash-NextLeaked PR textStatus for the dense Qwen4
Hidden size5,1202,560"H5120" for dense, "H2560" for Flash-NextMeasured as 5,120
Layers6448not visibleUnconfirmed
Attention heads / KV heads24 / 424 / 2"Q12/KV2" local at TP2Reasoned: 24 / 4
Head dim256256not visibleReasoned: 256
Full-attention intervalevery 4thevery 4thnot visibleReasoned
GDN value heads4848"BA48/96" pathsReasoned: 48
Intermediate width17,408MoE: 512 experts of 640denseReasoned: 17,408
Vocabulary248,320248,320not visibleReasoned
Hyper-connection lanesnone4 (rank 320)"HC"Reasoned: 4
Sparse attentionnoneQSA: ratio 4, budget 2,048"QSA"Measured that it exists, reasoned for the constants
MTP layers11"draft=4"Measured draft count, reasoned layer count

The three "reasoned" entries that carry the most weight come from the same trick. Two numbers in the PR text only make sense for specific shapes.

  1. "Q12/KV2" at TP2. It is a per-rank shape, so the model has 24 query and 4 KV heads in total. Qwen3.8-27B has exactly that. Flash-Next at TP2 would be Q12/KV1, and that is the row the public commit added. The PR text then says the old "Q3 and Q6" paths are kept; 24 heads at TP8 and TP4 give 3 and 6 per rank, which are Flash-Next's TP8 and TP4 shapes. (Reasoned.)
  2. "BA48/96". In a Gated DeltaNet layer the b and a projections are as wide as the number of value heads, so the pair is 96 at TP1 and 48 at TP2 if there are 48. Both released models have 48. (Reasoned.)
  3. "H5120". The visible text names "H2560/H5120" for the hyper-connection and gate kernels. 2,560 is Flash-Next. 5,120 is the 27B's hidden size. (Measured as text; the identification is reasoned.)

Taken together: the dense model in the PR has the released Qwen3.8-27B's skeleton (hidden 5,120, 24 query heads over 4 KV heads, 48 GDN value heads) with Flash-Next's two new organs added, hyper-connections and QSA. The released 27B has neither (its config has no hc_count and no indexer_* fields). So "carried over" covers the body, and "new" covers the residual path and the attention selector.

One more leak the post misses: the PR's MoE rows say E512/K2560/N160 or 320. Those are Flash-Next's 512 experts and hidden 2,560, with the 640-wide expert split across 4 or 2 cards. It is a MoE kernel note, not 27B information. (Reasoned.)

The mechanism, briefly

Hyper-connections. An ordinary transformer has one residual stream. Qwen's Gated Residual keeps four, each H wide, so the residual is 4H per token: 20,480 numbers at H = 5,120. Before each sublayer a gated mix reads the four lanes down to one H-wide input. After it, a combine writes the sublayer's output back into all four, scaled per lane by 2 sigmoid(inj / 4), which is exactly 1 when the learned injection is 0. I ported vLLM's reference for these ops to numpy and ran them on CPU. The site's Flash-Next article explains why Qwen deleted the lane-mixing matrix, and xHC and GLM-5.3-Flash show the alternative that keeps it.

QSA. Sparse attention picks which past tokens to read, but the picker can cost more than the reading. QSA compresses keys into blocks of 4, scores a query against each block with relu(q . k) summed over the index heads, keeps the top 2,048 / 4 = 512 blocks, expands them back to 2,048 tokens and appends up to 3 tail tokens. The attention then reads 2,051 positions however long the context. Compare MiniMax's MSA, which also scores blocks of past KV but picks them per GQA group.

MTP. One draft layer, run recursively. vLLM's config for this family sets n_predict to 1, so "draft = 4" means that layer is replayed four times, and the verifier checks 5 positions per step. The config also has an index_share_for_mtp_iteration flag, which lets the draft iterations reuse the QSA selection instead of redoing it.

Running the references on CPU

I ported test_hc_ops.py and the selection and expansion references in test_qsa_reference.py to numpy (my port, not vLLM's code run) and ran them at tiny scale on a shared 4-core VM. These are measured, and they show the mechanism, not the model.

grouped rmsnorm per-stream rms: [1. 1. 1. 1.]
mix out shape (3, 64) vs residual width 256 -> ratio 4.0
injection=0 weight [1. 1. 1. 1.]
unit-injection: |out-res - blk| max 2.3841858e-07
injection logits [-8. -2.  2.  8.] -> write weights [0.238 0.755 1.245 1.762] (range 0..2)
selected blocks [1, 5, 10, 11]
expanded token idx [4, 5, 6, 7, 20, 21, 22, 23, 40, 41, 42, 43, 44, 45, 46, 47] width 16
needle token 21 selected: True  in block 5
dense attn mass on selected tokens: 0.414 | cos(sparse,dense)= 0.8649 | read 16 of 48

What the run shows. The mix is a plain 4:1 read. A zero injection writes the block output unchanged into every lane, and the weights range over 0 to 2, so a lane can mute or double what a layer writes. In the QSA toy (ratio 4, a budget of 4 blocks, 48 tokens, one needle planted in token 21) the compressed scores find the needle's block; the sparse read keeps 41% of the dense attention mass from a third of the positions. It is random data, so 0.865 is a statement about this toy, not about quality.

At the leaked constants the same code reads 2,051 tokens, which is 25.0% of an 8,192 context, 3.1% of 65,536, and 0.78% of 262,144. The scan to choose them covers 65,536 compressed blocks at the long end. (Reasoned from the config's budget and ratio.)

What the shapes cost to serve

Every number below is reasoned, from Qwen3.8-27B's config, since nothing public gives the real one.

For the other formats: FP8 weights are 29.4 GB, too big for one 24 GB card, so the PR's FP8 target is two cards at TP2, with a ceiling of 33.9 tokens a second before communication. BF16 is 53.8 GB, with a ceiling of 8.9 on a single card that could hold it.

Post versus evidence

The post saysWhat I foundLabel
Qwen4-27B architecture reverse-engineeredThe PR names a qwen4-27b dense model. No config is visibleMeasured (title)
Merged Intel vLLM XPU kernelsMerged into analytics-zoo:downstream/v0.31.0, not vllm-project; affiliation not verifiedUnconfirmed
INT4 on 1-2 cards"TP1/TP2 INT4" in the scope textMeasured
MTP with 4 draft tokens"MTP draft=4/B1"Measured
FP8 TP2"Qwen4-27B dense TP2 FP8"Measured
4 residual streamsThe text says "HC" and "H5120"; four is Flash-Next's and the kernels' constantReasoned
QSA sparse attention kernels"QSA" row, with a Q12/KV2 TP2 pathMeasured
"You might not need a MoE cluster"A dense model needs none; most of the PR is the MoEReasoned
The shapes are leakingHidden 5,120 and 24/4 heads are inferable; layers, lanes, date, name are notReasoned

What a careful reader should take from this

A kernel PR is weak evidence about a model's release, and several replies said so. The useful reading is narrower. People at an inference vendor have working kernels, in the first week of a downstream branch, for a dense model with Flash-Next's residual path and sparse attention at the released 27B's width. That is a real engineering signal, and the strongest I could extract is the Q12/KV2 shape. It says nothing about weights, benchmarks, a name or a date. Qwen4 is not released, and Alibaba has not confirmed any of this.

What I could not check

vllm-project/vllm-xpu-kernels@daf6240 · snapshot 2026-10-26
tracked files
358
license
Apache-2.0
branch
main
tests
89 files
source
3.8 MB
commit date
2026-10-26
source by language
C++2.0 MB(123)Python1.6 MB(133)C190.9 kB(42)Shell13.6 kB(5)

by size of tracked source at this commit, file counts in brackets; docs, data and vendored trees excluded

local clone, 2026-10-26 at daf6240 — branch, commit, commitDate, fileCount, hasTests, languages, license, licenseFile, shallow, testFileCount

shallow clone: counts describe the pinned tree, not the history

vllm-project/vllm@6674eed · snapshot 2026-10-26
tracked files
8,514
license
Apache-2.0
branch
main
tests
2679 files
source
95.1 MB
commit date
2026-10-26
source by language
Python74.4 MB(5552)HTML7.3 MB(4)Rust5.5 MB(375)CUDA3.5 MB(195)C++2.0 MB(103)JavaScript1.5 MB(7)Shell850.7 kB(147)

by size of tracked source at this commit, file counts in brackets; docs, data and vendored trees excluded

local clone, 2026-10-26 at 6674eed — branch, commit, commitDate, fileCount, hasTests, languages, license, licenseFile, shallow, testFileCount

shallow clone: counts describe the pinned tree, not the history

Cite this article

For attribution, please use the following reference or BibTeX:

Satyajit Ghana, "Qwen4-27B: what a merged kernel PR does and does not leak", ai.thesatyajit.com, October 2026.

bibtex
@misc{ghana2026qwen427bvllmxpu,
  author = {Satyajit Ghana},
  title  = {Qwen4-27B: what a merged kernel PR does and does not leak},
  url    = {https://ai.thesatyajit.com/articles/qwen4-27b-vllm-xpu},
  year   = {2026}
}
share