Skip to content

qwen3-asr: the XPU binding on Gen12LP (#2105, stacked on #2239) - #2255

Draft
jschmied wants to merge 4 commits into
ashhart:mainfrom
jschmied:qwen3-asr-xpu
Draft

jschmied wants to merge 4 commits into
ashhart:mainfrom
jschmied:qwen3-asr-xpu

Conversation

@jschmied

@jschmied jschmied commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Qwen3-ASR's XPU binding, for #2105, on Gen12LP (Iris Xe, no DPAS). Head e7e03b485, on main e6094de13: four commits. The first two are the binding (3b6dc91b3, bf48bf374, unchanged since the rebase). The two new ones answer ashhart's three asks (6764829964): bb07f9b91 adds the forced tool and e7e03b485 the kernel contract. Still a draft until the #2105 / #2118 decisions move.

ashhart's asks, on the Iris Xe (0x9a49, WSL2, ocloc 23.43)

1. The two short clips (cut50 = 1272-128104-0000 cut to 0.50 s, cut99 = cut to 0.99 s; Qwen3-ASR-0.6B, qwen-asr 0.0.6 CPU cases), tf-qwen3-asr-xpu --case on bf48bf374:

clip tokens transcript worst stage cosine
cut50 9 byte-identical 0.99860 (lm_norm)
cut99 10 differs at token 3 0.99904 (lm_layer27)
  • At cut99's token 3 the reference has an exact tie: 8589 and 3297, margin 0.0000 (it picks 3297). Ours picks 8589 by 0.125.
  • Under the tie rule (tf-qwen3-asr-xpu-forced), cut50 is 9 of 9 same and cut99 is 9 same plus that 1 swap: both PASS.
  • The three dev clips are byte-identical again (26, 17 and 91 tokens), worst cosines 0.99906, 0.99927 and 0.99765, equal to the old gate's rows.
  • tf-xpu-qwen3_asr_ops-test is ok.

2. Kernel contract (tf-xpu-qwen3_asr_contract-test, in xpu-tests). It ran on a263b1aab; this head differs from it only in comments:

SUMMARY tgllp 0x9a49 13 kernels: 13 pass gates 1-4, 0 fail, 0 known findings; 11 controls: 11 red as planted, 0 missed; 0 limit problems; gates 28247 ms, limits 0 ms
  • 13 kernels. From qwen3_asr.cl:

    • asr_gemm three ways: plain, with bias and residual, and with bias and GELU;
    • asr_conv, asr_flatten (bit for bit), asr_layernorm, asr_gelu, asr_attn_full;
    • asr_qk_rope: its q, k and v rows, and its cache writes (bit for bit).

    From the lfm3_gq2 build: lfm3_rmsnorm, the lfm3_attn_partial + lfm3_attn_merge_gate pair, and lfm3_swiglu. Each is checked against float64 at the binding's shapes (0.6B and 1.7B widths) and at the tiles' edges.

  • 11 planted controls, all red. Each is the same source with one edit, applied at build time by zig/build/cl_edit.zig, which fails the build if the edited line is gone. The edits are listed in zig/build/xpu_qwen3_asr_contract.zig:

    • ten go red at the shapes gate (residual dropped, kh and kw swapped, f-major flatten, bias dropped, SiLU for GELU, a causal mask, the rotation reversed, the norm weight dropped, keys read past the position, gate and up swapped);
    • one goes red at the sums gate: the Linear's 16-k steps added in bf16.
  • Gate 4 (exact fp32 sums under stress) is proven on the Linear.

    • The conv shares its tile body. Both attentions declare 0x, since softmax weights in [0, 1] leave nothing to prove.
    • The norms ask 0x for bf16. asr_qk_rope asks 50x for fp16: a sum past fp16's range zeroes rs, so an output can miss by at most itself over its bound (about 85x). Each spec states why.
  • Gate 5 is live. The card's properties are checked against a new Gen12LP row (xpu_limits.gen12lp: 12 subslices of 8 EUs, 7 threads, SIMD 8), and every loaded kernel against its record in qwen3_asr_xpu_records.zig. The declared control, the norm at 1,024 work-items, is red.

    • The first card run corrected the row and two records: asr_gemm and asr_conv build at SIMD 8.
    • Finding: asr_gemm spills 1,024 bytes on Gen12LP. The record states it.
  • The guarded buffers moved from contract_rig.zig to contract_guarded.zig, generic over the device, so the BMG runner and this one share them. The BMG runner and tf-xpu-kernel-contract still build.

3. The full clip set under #2239's tie rule: gate2's 40 clips (LibriSpeech test-clean plus FLEURS cmn), teacher-forced on the package's fp32 greedy ids with tf-qwen3-asr-xpu-forced. It ran on 0c162ed60, which differs from this head only in the contract's files (the Gen12LP row, two records and two stress fills). Qwen3-ASR-0.6B:

Iris Xe (this PR) CUDA, #2239's gate2
clips PASS 40 / 40 40 / 40
steps: same top token / swaps / fail 1340 / 2 / 0 of 1342 1339 / 3 / 0 of 1342
fp32 distance, worst column: ours / package bf16 2.3597 / 2.0766 1.9741 / 2.0766
fp32 distance, mean: ours / package bf16 0.09468 / 0.09519 0.08277 / 0.09519
--plant norms 40 / 40 clips fail (967 steps) 40 / 40 (970)
  • The two swaps are CUDA's: 1320-122612-0001 step 31 and 2094-142345-0001 step 22, ours at margin 0 both times. CUDA's third swap (2961-960-0000 step 38) is the same top token here.
  • Point 4 is not met on the worst column. Ours is 2.3597 at cmn-4527058471786347963 step 36, where the package's bf16 is 2.0766. The mean is lower than bf16's.
  • 1.7B was not run: it isn't on the laptop (WSL has 7.6 GiB of RAM), and I did not download it unasked.
  • The forced tools now share forced.zig's distance and step tally. That change is byte for byte the one qwen3-asr: the Metal binding (#2105, stacked on #2239) #2254 makes for its Metal tool, so the two merge cleanly in either order.

The decode GEMV stays a later PR, as agreed.

Host checks on this head

On e7e03b485, x86 lane (8 cores, no GPU), all green:

  • zig build -Dfixed-cpu test-host test-qwen3-asr-host: 2395/2395 steps, 24194/24356 tests (162 skipped).
  • zig build -Dfixed-cpu test test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths: 867/867 steps, 771/784 tests (13 skipped).
  • check-native-cuda-host compile-cuda-tests 17/17. The XPU build for tgllp (tf-qwen3-asr-xpu, tf-qwen3-asr-xpu-forced, xpu-tests) 105/105, and the BMG contract runner (-Dxpu-contract=true) 15/15. Both have ocloc stubbed, so they check the host code; the kernels ran on the card above.
  • tools/pr_check.py 0 errors, lean 165 vs 165 on the base (0 new), zig fmt --check and git diff --check clean.

What it adds

Shared kernels first:

  • the LM's RMSNorm, SwiGLU and causal GQA attention come from lfm3.cl, rebuilt as lfm3_gq2 with -DGQ=2; the merge with a +inf gate is x1;
  • the residual add is glue's add_bf16;
  • the embedding is a device copy.

qwen3_asr.cl, only where nothing on Gen12LP has the same rounding:

  • the bf16 Linear (vit_gemm's tiles on bf16 rows, with bias, GELU and residual);
  • the strided conv and flatten;
  • LayerNorm, GELU and the tower attention (in vit_attn's order);
  • Qwen3's q/k-norm RoPE (lfm3's rope rounds once; Qwen3 rounds each product and the sum).

#1838's vit_* kernels are not reused: they take fp32 activations, and the shared tower buffers are bf16.

The original gate (Qwen3-ASR-0.6B @ 5eb1441, Iris Xe)

The reference is qwen-asr 0.0.6's windowed backend, as on #2239. The prompt ids are equal on all three clips.

clip (LibriSpeech dev-clean) tokens transcript worst stage cosine
1272-128104-0000 26 byte-identical 0.99906
1272-128104-0001 17 byte-identical 0.99927
1272-128104-0004 (29.4 s, 4 windows) 91 byte-identical 0.99765
  • tf-xpu-qwen3_asr_ops-test: 16 checks against FP64 and 4 bitwise; all 14 planted controls fail as they should.
  • test-qwen3-asr-host: green.
  • Speed on the 29 s clip: tower 736 ms, prompt 1.69 s. Decode is about 4 tok/s, since there is no bf16 GEMV for decode on Gen12LP yet; that is a follow-up, not part of this PR.
  • On the laptop (at a0d850c1b): lean 0 new, fmt and diff-check clean.
  • On the GB10 at 796c21107: lean 0 new, zig build test, the no-GPU CI set, git diff --check and zig fmt --check pass.

Notes

  • Seeded sampling, resume and concurrency don't apply here: tf-qwen3-asr-xpu is an offline one-stream greedy tool, and no served path changes.
  • No refusal test: this rebase adds no refusal.
  • Against main: no kernel and no served path changes. Two shared files are touched: forced.zig (the CUDA forced tool's tally and distance moved there, as on qwen3-asr: the Metal binding (#2105, stacked on #2239) #2254) and the BMG contract rig (moved to contract_guarded.zig, unchanged in behaviour; the BMG runner still builds). Neither CUDA nor BMG was rerun on a device for this.
  • Proposed CHANGELOG line, for ashhart to place: qwen3-asr: the XPU binding on Gen12LP (no DPAS) and tf-qwen3-asr-xpu (#2255).

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied, and for the planted controls on the XPU ops. This follows #2239 too. Before it leaves draft:

  1. Restack on qwen3-asr: host slice, the shared tower and Qwen3 schedules over a backend binding (#2105) #2239's final head and rerun the two short-clip cases.
  2. Kernel-contract records for qwen3_asr.cl and the lfm3_gq2 build, with the XPU SUMMARY line.
  3. The full clip set under the tie rule from qwen3-asr: host slice, the shared tower and Qwen3 schedules over a backend binding (#2105) #2239, in place of three clips.

The decode GEMV can be its own PR later, as you say.


  • Synthena (Ash's Agent)

… KV head, against FP64 (ashhart#2105)

qwen3_asr.cl holds what no shared Gen12LP kernel covers: a bf16 Linear (64 x 64 tiles as vit_gemm,
bf16 rows, bias, GELU and residual epilogue), the 3 x 3 stride-2 conv on channels-last rows, the
flatten to torch's order, LayerNorm with bias, erf GELU, the tower's windowed attention and Qwen3's
per-head RMSNorm with RoPE rounded at each product and sum (lfm3's rounds once). The language
model's RMSNorm, SwiGLU and split-K GQA attention are lfm3.cl's, built again as lfm3_gq2 with GQ 2.
tf-xpu-qwen3_asr_ops-test checks each against FP64 with a planted control, the shared kernels as
the binding launches them.
xpu/ binds the shared tower and Qwen3 schedules to qwen3_asr.cl and the shared kernels on Level
Zero, as cuda/ does on CUDA: the store places bf16 tensors as stored, the embedding copies rows by
id, and lfm3's attention merge takes a +inf gate (bf16(sigmoid) = 1). tf-qwen3-asr-xpu runs a clip
against a qwen3_asr_case.py case, each stage's cosine and the greedy ids. On Iris Xe the three
LibriSpeech dev clips (1272-128104-0000, -0001, -0004) are byte-identical to the windowed
reference (26, 17 and 91 tokens; worst stage cosine 0.99765).
@jschmied

Copy link
Copy Markdown
Contributor Author

@ashhart restacked on main e6094de13 (#2239 merged), head bf48bf374, with no conflict. The tower picks up main's dumping() and gathered conv_out, and nothing else in the binding changed.

The Iris Xe gate was not rerun: no XPU tester was reachable. This head has host tests, an x86_64 cross-compile of tf-qwen3-asr-xpu and xpu-tests (76/76, ocloc stubbed, so host code only), and GB10 zig build test 820/820. The kernels are unchanged since the gate (range-diff), but the short-clip cases (item 1), the contract records (item 2) and the full clip set (item 3) are open until the Iris Xe box is back. It stays a draft.

…e Intel GPU; the forced tools share forced.zig (ashhart#2105)

tf-qwen3-asr-xpu-forced runs a clip teacher-forced on a case's greedy ids and judges every step by the tie rule, as
tf-qwen3-asr-forced does on CUDA: a differing top token passes only as a swap with both margins at most 0.25. With
logits_fp32 and logits_bf16 in the case it prints both distances to fp32. --plant splice and --plant norms (q_norm and
k_norm swapped in every layer, Model.swapQkNorms) are the faults it must catch. forced.zig now holds the distance and
the step tally both tools print, byte for byte the change ashhart#2254 makes for its Metal tool.
…a planted control each, gate 5 live (ashhart#2105)

tf-xpu-qwen3_asr_contract-test (in xpu-tests) runs gates 1 to 4 on the card for every kernel the binding launches from
qwen3_asr.cl (the Linear plain, with bias and residual and with bias and GELU; the conv, flatten, LayerNorm, GELU, the
tower's attention, Qwen3's q/k norm and RoPE with its cache writes) and from lfm3.cl at GQ 2 (RMSNorm, the split-K
attention pair, SwiGLU), each against float64. Each has a planted control: the same source with one edit (cl_edit
fails the build when the edited line is gone), red at the shapes gate, and one at the sums gate (the Linear's steps
added in bf16). Gate 5 reads the card's properties against a Gen12LP row (xpu_limits.gen12lp) and every loaded
kernel against its record (qwen3_asr_xpu_records.zig); the declared control at 1,024 work-items is red. The guarded
buffers move to contract_guarded.zig, generic over the device, so both XPU contract runners share them.
jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 22, 2026
…s bits at one row (ashhart#2105)

A 16-lane sub-group an output: lane l takes the 16-k steps l, l + 16, ..., each step's fma chain from 0 as
asr_gemm's tile, then the steps' sums are added in order, so every output equals asr_gemm's at m = 1 bit for bit.
It lives in its own image, qwen3_asr_mv.cl: added to qwen3_asr.cl it changed the driver's build of asr_conv
(SIMD 16 and 1,024 spill bytes on Gen12LP), so qwen3_asr.cl stays byte for byte ashhart#2255's.
The kernel contract runs it with replaces = asr_gemm at one row (gate 3 bit-equal on every shape), float64 at
gates 1 and 4, and a planted control that adds each 16 steps last first; its Gen12LP record joins gate 5.
jschmied added a commit to jschmied/TensorFold that referenced this pull request Nov 22, 2026
…s bits at one row (ashhart#2105)

A 16-lane sub-group an output: lane l takes the 16-k steps l, l + 16, ..., each step's fma chain from 0 as
asr_gemm's tile, then the steps' sums are added in order, so every output equals asr_gemm's at m = 1 bit for bit.
It lives in its own image, qwen3_asr_mv.cl: added to qwen3_asr.cl it changed the driver's build of asr_conv
(SIMD 16 and 1,024 spill bytes on Gen12LP), so qwen3_asr.cl stays byte for byte ashhart#2255's.
The kernel contract runs it with replaces = asr_gemm at one row (gate 3 bit-equal on every shape), float64 at
gates 1 and 4, and a planted control that adds each 16 steps last first; its Gen12LP record joins gate 5.
@jschmied

Copy link
Copy Markdown
Contributor Author

@ashhart all three asks rerun on the Iris Xe, head e7e03b485 (two new commits on bf48bf374). Details are in the body.

  1. Short clips: cut50 has a byte-identical transcript. cut99 differs only at token 3, where the reference has an exact tie (margin 0.0000) and ours leads by 0.125. Under the tie rule both PASS (cut99 with that one swap). The three dev clips are byte-identical again.
  2. Contract: SUMMARY tgllp 0x9a49 13 kernels: 13 pass gates 1-4, 0 fail, 0 known findings; 11 controls: 11 red as planted, 0 missed; 0 limit problems; gates 28247 ms, limits 0 ms. That covers 13 kernels from qwen3_asr.cl and the lfm3_gq2 build, each with a planted control. The controls are one-line edits of the same source, applied at build time. Gate 5 ran live against a new Gen12LP row; asr_gemm spills 1,024 bytes there, and the record says so.
  3. Full clip set: 40/40 PASS on 0.6B: 1342 steps, 2 swaps (both also on CUDA's list), 0 fail. All 40 plants were caught. One miss: our worst fp32 distance (2.36) is above the package bf16's (2.08), though the mean is lower (0.0947 vs 0.0952), so point 4 isn't met on the worst column. 1.7B wasn't run: it isn't on the laptop.

It stays a draft. The decode GEMV comes next as its own PR, stacked on this one.

@jschmied

Copy link
Copy Markdown
Contributor Author

@ashhart the decode GEMV follow-up is #4693, stacked on this head (e7e03b485): asr_gemv is bit-equal to asr_gemm at one row, and decode on the Iris Xe goes from 3.5 to 10.55 tok/s.

This branch has not been deployed

No deployments
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