Repository navigation
Conversation
… 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).
…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.
…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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Qwen3-ASR's decode GEMV on XPU (Gen12LP, Iris Xe): the follow-up to #2255 that ashhart named there ("The decode GEMV can be its own PR later"), for #2105.
Stacked on #2255. This branch is #2255's head
e7e03b485plus one commit,108ea70b2. Only that last commit is this PR; review it alone withgit diff e7e03b485 108ea70b2. I'll rebase onto main once #2255 lands.What it changes
asr_gemv, in a new imagezig/kernels/xpu/qwen3_asr_mv.cl. It computes one-row Linears in bf16, with fp32 sums.asr_gemm's tile, and the step sums are then added in order.asr_gemm's at m = 1, bit for bit. Same tokens by construction, and the shared schedule's check that decode logits equal the prompt pass's still holds.Lm.gemmsends one-row calls (decode, the tied head) toasr_gemv. Prompt passes keepasr_gemm.qwen3_asr.cl: the first try put the kernel inqwen3_asr.cl. That changed how the driver builtasr_conv(SIMD 16 instead of 8, 1,024 spill bytes), and the prompt pass got slower in all 3 paired rounds (+4%, +15%, +20%). In its own image,qwen3_asr.clis byte for byte qwen3-asr: the XPU binding on Gen12LP (#2105, stacked on #2239) #2255's.Shared code, checked first: nothing on XPU covers bf16 weights. The XPU matvecs (
qmv4*,lfm3_mv,nem_rows) all read MLX 4-bit weights, andlane_gemvis CUDA-only. Core's contract already has "replaces kernel X, bit for bit" (spec.replaces), and the test uses it rather than a check of its own.Evidence (Iris Xe 0x9a49, Qwen3-ASR-0.6B)
Kernel contract (
tf-xpu-qwen3_asr_contract-test, on108ea70b2):asr_gemvdeclaresreplaces = asr_gemm at one row. Gate 3 found it bit-equal toasr_gemmon 18 shapes: the binding's decode widths for 0.6B and 1.7B, the 151,936-wide head, k = 1,000 with a short last step, and the tile edges. Gate 1 checks it against float64; gate 4 found its sums exact at k 6,144, where fp16 would miss by infx and bf16 by 74,642x.gemv_steps_reversedadds each 16 step sums last first, applied bycl_editinzig/build/xpu_qwen3_asr_contract.zig. It goes red at gate 3: its bytes differ fromasr_gemmat one row from byte 1,660 at 1x1024x2048.Exactness on the full clip set, the 40 clips of #2239's gate2 under the tie rule (
tf-qwen3-asr-xpu-forced, on356dac96c; the only later change is in the contract test). Every clip's FORCED, SWAP, FAIL and DIST lines are identical to #2255's run: 80 of 80 files (40 plain, 40 planted), 0 differ.Speed (
tf-qwen3-asr-xpu, 1272-128104-0004, 29.4 s, 91 tokens). A = #2255's heade7e03b485, B =356dac96c; one warm-up each, then 3 rounds of A B B A. The transcript is the same in all 12 runs.qwen3_asr.clbuild as A.Host checks on this head
On
108ea70b2, 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-tests17/17. The XPU build for tgllp 108/108, and the BMG contract runner 15/15. Both have ocloc stubbed; the kernels ran on the card above.tools/pr_check.py0 errors, lean 165 vs 165 on the base (0 new),zig fmt --checkandgit diff --checkclean. It merges cleanly with mainfe6d47a18.Notes
tf-qwen3-asr-xpuis an offline one-stream greedy tool, and no served path changes.qwen3_asr.climage, same build), and the decode is bit for bit the same, as shown above.qwen3-asr: asr_gemv, the XPU decode GEMV, bit-equal to asr_gemm at one row (~3x decode on Iris Xe).