Repository navigation
qwen3-asr: host slice, the shared tower and Qwen3 schedules over a backend binding (#2105) - #2239
Conversation
|
Ready for review. #2225 has landed, so I rebased onto main
A Metal binding of the same schedules passes on an M3 Pro (3 dev clips byte-identical). It follows as its own PR, stacked on this one. |
|
Thanks @jschmied. 38 of 40 clips byte-identical, the other two at a bf16 tie and a 0.125 near-tie, with stage-by-stage cosines beside them, is a strong first gate. Two things before it can go further. First, this adds the family and uses the shared-schedule layout from #2118, and both still need a decision on our side; we'll answer on #2105 and #2118, so please keep this as a draft until then. Second, a small one for whenever it moves: |
|
Thanks. Back to draft until #2105 and #2118 are answered. Shared kernels at nvcc 13.0. I compiled
So every kernel main already has compiles to the same registers, shared and constant bytes and the same instructions; the PR only adds the three functions, and their registry rows are in the PR. nvcc
Also on this push: |
|
Thanks — the host/CUDA split is easy to follow, and tapping every stage in the case generator is useful. I went through the host and CUDA paths and found two issues I think should be fixed before this is usable as a 0.6B/1.7B gate, plus a few smaller points. 1. A single chunk shorter than 100 frames uses the wrong convolution geometry
This is not only the shape of the conv dumps: the right-edge conv2/conv3 outputs read the extra padded rows, so the kept rows can differ. I reproduced it with a 50-frame (0.5 s) clip:
Suggested fix: when 2.
|
|
Thanks @shuuul, all fixed on
Host checks on this head, each step with its own exit code, all 0: The GPU on our box is down until a reboot. The CUDA re-run follows after it: the 0.6B and 1.7B 40-clip gates plus the 50- and 99-frame cases with stages. I'll post the results here. |
|
The CUDA gates on
All four differences are near ties against the package, with the top two logits at most 0.25 apart on either side:
The two Since the tools now exit 1 on a differing transcript, these clips fail by exit code, which is what a gate should do. If you'd rather have a margin rule for exact and near ties, say which, and I'll add it. |
|
Thanks @jschmied for taking every point from @shuuul's review, and for the GB10 rerun with each difference listed with its margins. Thanks too, @shuuul, for the careful read. Nothing is needed from you while this is a draft. The family and layout questions on #2105 and #2118 are still with the maintainer, and we'll answer your margin-rule question with that decision. As we said on #2105, the audio route (#1632) comes first.
|
|
Thanks @jschmied for the GB10 rerun with every margin listed, and @shuuul for the careful review. The family is a yes (#2105), and this layout is fine for a new family (#2118). On your margin question, here is the rule. It's the one we used on #2648.
Before it leaves draft:
The windowed reference is right, with the global comparison listed as you have it. Since this doesn't touch the server, it can land before #1632. The served path waits for #1632.
|
|
@ashhart thanks. Everything below is on 1. Rebase.
Tie rule.
So the 0.6B passes 44 of 45 clips and the 1.7B passes 45 of 45. Every other step matches. The failing step isn't a swap. In the package's bf16 run our 468 is third: 9197 25.75, 36 25.5, 468 25.375. The package's fp32 run of the same step puts 468 first, at 25.7277 against 9197's 25.7162. Under the rule as written it fails. I've left the rule alone and listed the step. Planted changes on dev clip 0000:
2. One Qwen3 forward on CUDA through #2285. Here's what I propose. I'll build it once #2285 lands, and nothing here depends on it yet.
3. Decode against prompt, two passes against one.
4. Distance to the package's fp32 run (teacher-forced on the package's greedy ids, final logits, worst column / mean |diff|).
Today's path isn't uniformly closer to fp32 than the package's bf16. On 0.6B 0000 its mean is 0.133 against 0.102, and that's the clip where the multi-row algorithms differ most. One algorithm a shape brings that mean to 0.090. I'll repeat this table through #2285's pass. 5. Provenance. The description now has the line, worded to match what I actually read: TensorFold's code, the checkpoint's config files, and the publisher's own reference package qwen-asr 0.0.6. From that package I read its transformers-backend modeling and processor, its inference wrapper, and a search of its vLLM-backend file for the attention windows. I also checked the log-mel front end against transformers' Verify on |
|
Thanks @jschmied. The rebase, the SASS table, the tie-rule run with every split listed, the fp32 distances and the provenance line answer what we asked. The #2285 plan (one Qwen3 layer path on CUDA, the schedule in Two decisions from our side:
One small thing for now: the exact-tie swap in Once it runs through #2285's pass, please post the tie-rule run, the fp32 distance table, and
|
|
@ashhart thanks. On
Verify on |
|
@jschmied yes, that shape works for us: one Qwen3 layer path on CUDA, the start, splice and head read only when set, and the embedding hashes on main against the new head. Three things from our side:
For the embedding hashes: we're rerunning #2285's receipts for the 0.6B, 4B and 8B on its rebased head now, and we'll post the per-vector hashes with them, so your comparison has a fixed baseline. |
|
Thanks @jschmied. The exact-tie order now lives in Nothing is needed until #2285 lands. When you rebase onto it, two small things from today's main:
|
|
@ashhart #2285 is in, so here is the rebase and the run through its pass. Head
Verify on |
…th (ashhart#2105) The package pads every chunk to the longest one, so a clip of one chunk shorter than 100 frames goes through the three convolutions at its own length; the right-edge conv2 and conv3 outputs then see no padded rows. The plan gives that length (chunk_frames), and the shared tower schedule and the float64 reference both take it. The schedule test runs 50- and 99-frame clips against the reference and checks the first convolution's length. On cases from qwen3_asr_case.py for a 0.5 s and a 0.99 s cut of a dev clip, the 0.6B's host check at torch's points gives audio_rows cosine 0.99984 and 0.99992, the conv stages at the package's shapes; at the parent commit the 50-frame case gave audio_rows 0.889 and stopped with StageSize at the conv stages.
….Checkpoint (ashhart#2105) The host check mapped MODEL_DIR/model.safetensors only, so the released 1.7B (two shards and an index) failed with FileNotFound. It now opens the folder with core.Checkpoint.openModel, as the CUDA load does, and validates the names of every shard as one set. On the 1.7B: WEIGHTS ok (708 tensors), and the 50- and 99-frame cases give audio_rows cosine 0.99993 and 0.99992 at torch's points.
…shhart#2105) tf-qwen3-asr-check exits 1 when the worst stage cosine is under --min-cos (default 0.995; a token or prompt mismatch already failed). tf-qwen3-asr with a case exits 1 when the prompt ids or the greedy transcript differ from the case's, or a compared stage's cosine is under --min-cos (default 0.99). The SUMMARY line names the gate and PASS or FAIL.
…a window of whole chunks; no empty group (ashhart#2105) The LM copies hidden-wide rows from the tower's output, so a config whose audio output_dim differs from the text hidden size is refused. n_window_infer under one chunk is refused by name (the modulo already refused it, as the integer fields are at least 1). tower.Weights.load refuses a group of 0 chunks, which encode steps through. The 1.7B's released geometry (24 tower layers, 16 heads of 64, output 2048 = hidden 2048) is admitted in a test.
…its special-token, repetition and language handling (ashhart#2105) Only its own test used it; the tools compare token ids and the decoded reply. A parser matching the package's can come with the serving path that needs one.
…t#2105) A case from qwen3_asr_case.py --ids-only holds no stage tensors, so the host check stopped at the missing mel stage. With --ids-only it checks the weights, the prompt ids and the reference reply's decode, and compares no stage. On the 1.7B's gate case 1089-134686-0001: PASS.
…hhart#2105) The package taps conv_out before the positions are added, and the schedule fuses the add into conv_out's Linear. When a binding is dumping (a new dumping() on the binding), the schedule runs conv_out once more without the positions and dumps it; the timed pass is unchanged. tf-qwen3-asr gathers it over the chunk groups as it does the convs. The schedule test compares the host binding's conv_out with the float64 reference's.
…on case is checkable on the host (ashhart#2105) The tower runs attention within n_window_infer windows, as the package's vLLM backend and flash-attention-2 path do; the package's stock transformers SDPA path attends over every row. chunks.zig records that. The case's manifest names its attention, Plan.attending(.global) is one window over every row, and the float64 reference and tf-qwen3-asr-check run the case's kind. tf-qwen3-asr, which runs the windows, refuses a global case (exit 2). On dev clip 1272-128104-0004 (2940 frames, 4 windows) with the 0.6B: the global case passes at audio_rows cosine 0.99987 (worst stage 0.99979), the windowed case at 0.99989; the global case checked with windows gives 0.919 and fails the gate.
… prompt in two passes equals one (ashhart#2105) The splice is cut to the pass, so a prompt can be split inside the audio rows. forwardHeads puts the head over a pass's last rows, the CUDA binding can keep each head row's logits and download its caches, and lm_test.zig checks both equalities on a computing host binding, with a planted cache slot that fails them.
…case's bf16 and fp32 logits (ashhart#2105) Each clip runs on the reference's greedy ids to the end. A step whose top token differs passes only if the two tokens swap places and both margins are at most 0.25 logit; every such step is listed, anything else fails with exit 1. With logits_fp32 and logits_bf16 in the case (qwen3_asr_case.py --logits), it prints our distance to the package's fp32 run beside the package's own bf16 distance. --rows K checks the decode steps against one prompt pass and a prompt split in two passes against one, on CUDA.
…y round, plants swapped q and k norms, and --row-gemms (ashhart#2105) topk may list an exact tie (margin 0) in either order; the greedy id is the reference's pick. --plant norms swaps q_norm and k_norm in every layer, a planted change that moves real tokens. --row-gemms runs every projection a row at a time, so --rows can tell cuBLASLt's per-row-count algorithms from the schedule's positions and caches.
…o forced.zig, with its test (ashhart#2105) forced.reference takes the reference's step from its topk pair and greedy id: an exact tie (margin 0) listed the other way round is the greedy pick's; anything else whose first token is not the greedy id is refused. Its test fails without the swap.
…ith a start position, an audio splice and a tied head over chosen rows (ashhart#2105) qwen3/cuda/lm.zig's forwardFrom takes an Extra: the input's first position, every layer's own k and v caches, rows spliced over the embedded ones, the final norm and the tied head over the pass's last rows, and stage taps. Each is read only when set: forward(.{}) issues the embeddings' launches with the same arguments. qwen3_asr/cuda/lm.zig (the schedule's CUDA binding) goes; the ASR checkpoint loads through weights.Model.fromCheckpoint under its thinker.model. scope, and the position and RoPE uploads are lm.tables, shared with the engine. tf-qwen3-asr-forced drops --row-gemms: every projection keeps one algorithm per (n, k).
… its caches before any launch, with its tests lm.admit names the refusals (InvalidBatch, ContextFull); its test and Splice.within's run in test-qwen3-cuda-host.
…s audio tower (ashhart#2105) The three pinned serving sources gain only new code: a vision_kernel<64, 8> instance, tf_vit_conv_cols and tf_vit_conv_flatten, and their wrappers. The existing kernels' SASS is unchanged on sm_80/86/89/120/121.
…ds, so main.zig stays within 600 lines (ashhart#2105)
Follow main e54cb34 (cuda tests: split command help to keep the runner under 600 lines). Original ashhart#2239 mail24 removes its standalone contract command in favor of the existing kernel-contract words; remove only its temporary help row from the current module.
|
Thank you @jschmied. 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. |
Refs #2105. Rebased on main
6d0a128b0(with #2285 and #2995); head3689e0113. The agreed gate on 40 fresh clips(6928895212) passes on
7e9b99f2a, with every per-clip line identical to the2fe5b72d9run (below). The earliergate's
cut50step-3 fail stays on record.Runs on
7e9b99f2a(3689e0113only re-pinsprefill_attention.cuindense_serving_test.zig): gate 2,--rows 8decode and two-pass equalities, the contract set, the embedding bytes againstmain, and every check. Sections marked
51dc03072are history from earlier rounds; the code they cover is unchangedexcept where this round says otherwise.
The first slice of #2105: the family's host parts, a tower schedule shared by every backend, a Qwen3 decoder schedule
for the host reference and the Metal and XPU bindings, and the CUDA path, measured on a GB10. It doesn't touch the
server and doesn't depend on #1632.
It reads the checkpoint's Qwen2 slow-tokenizer export through #2225, now on main, because the checkpoint ships no
tokenizer.json.
Shape
families/qwen3_asr/(host, any OS):tower.zigandlm.zig: the schedules, generic over a bindingr. They never import a backend.schedule_test.zigruns both schedules on a host binding. The tower must match the float64 reference at torch'sbf16 points (global attention fails it), and every LM op must stay inside its buffers.
families/qwen3_asr/cuda/: a device store, the tower over vit.cu's LayerNorm, pointwise and cuBLASLt Linearkernels, and
model.zig, which runs the language model through qwen3 cuda: Qwen3 embedding checkpoints (BF16) on the native CUDA engine (#2261, 1 of 2) #2285's Qwen3 pass (next section).One Qwen3 layer path on CUDA: #2285's pass
qwen3/cuda/lm.ziggainsforwardFrom(…, trunk, ends, Extra)(:354).Extra(:200) holds:start: theatthe input's rows stand from.attentionhas one start position, qwen3 cuda: Qwen3 reranker checkpoints (BF16) on the native CUDA engine (#2261, 2 of 2) #2995'sat(:447, positionsa.pos + 4 * (at + p)at:470); the inputs takex.start + trunk(:431);cache: every layer's own k and v caches in place of the scratch's one;splice: rows copied over the embedded ones, cut to the pass;head: the final norm over the pass's last rows and the tied head on the device, as one more pinned (vocab,hidden) plan that only ASR prepares;
tap: stage reads fortf-qwen3-asr's stage compare.forward(…, trunk, ends)keeps main's signature and isforwardFrom(…, trunk, ends, .{})(:349-350): the same launches with the same arguments.lm.admit(:210) refuses a start or head on more than one input, beside a trunk or without its caches, a headover no rows or more rows than the pass, and positions past the caches, before any launch. Its test (
:218) nameseach refusal, and main's reranker call (a trunk,
.{}) passes. With the cache check planted out (r5) it went red(18/19), and green again (19/19) with it back.
weights.Model.fromCheckpoint(weights.zig:48) loads the ASR checkpoint's Qwen3 under itsthinker.model.scope. It takes the head's stored name:fromDirpassesnames.headKeyas main does, and ASRpasses
thinker.model.embed_tokens.weight, the table its tied head reads (qwen3_asr/cuda/model.zig:73-74). The position and RoPE uploads moved from the engine intolm.tables(lm.zig:127), whichboth call (
engine.zig:75).qwen3/pass_cuda.zigis the small module root the ASR tools import.qwen3_asr/cuda/lm.zig(our binding of the schedule on CUDA) andtf-qwen3-asr-forced --row-gemms.qwen3_asr/lm.zig) stays in the family for now. It moves tofamilies/qwen3/schedule.zigwiththe Metal and XPU bindings (qwen3-asr: the Metal binding (#2105, stacked on #2239) #2254, qwen3-asr: the XPU binding on Gen12LP (#2105, stacked on #2239) #2255), its only other users.
Provenance
The family was written from TensorFold's code, the checkpoint's config files, and the publisher's reference package
qwen-asr 0.0.6. From that package I read the transformers-backend modeling and processor, the inference wrapper, and a
search of its vLLM-backend file for the attention windows. The log-mel front end was checked against transformers'
WhisperFeatureExtractorsource, which the package calls. No code was copied from any of them.Gate 2 (agreed in 6928895212): 40 fresh clips against the package's fp32 run, on
7e9b99f2asentence ids 21-40. All 40 SHA-256 values were posted before the run and matched it (40 of 40).
tf-qwen3-asr-forcedmd5950aee2f16035e735026e0bab9b0e856on7e9b99f2a. All 160 runs'FORCED,SWAP,DISTandSUMMARYlines are byte-identical to the2fe5b72d9run (md5063522d4…). Each clip is teacher-forced on the package'sfp32 greedy ids (qwen-asr 0.0.6, vLLM windows). A step whose top token differs from fp32's is listed, and it passes
only as a swap of the same two tokens with both margins at most 0.25.
1320-122612-0001step 31: 13 (0.000), then 979 (0.0929).2094-142345-0001step 22: 13 (0.000), then 26 (0.0530).2961-960-0000step 38: 11 (0.000), then 1558 (0.1606).--plant norms: fails 40 of 40 clips on 0.6B (970 steps) and 37 of 40 on 1.7B (526 steps), with exit 1.Gate: the tie rule (as on #2648), teacher-forced against qwen-asr 0.0.6, on
51dc03072and a 99-frame cut, and 3 LibriSpeech dev clips. That's 45 per checkpoint.
tf-qwen3-asr-forcedruns each clip on the reference's greedy ids to the end. A step whose top token differspasses only if the two tokens swap places and both margins are at most 0.25 logit. Every such step is listed, and
anything else fails with exit 1.
1272-128104-0004step 11 (ours 3138 at 0.25, the reference's 705 at 0.000),cut99step 7 (13 at 0.000, 30 at 0.125),cmn-10369927130798325266step 19 (3837 at 0.000, 67338 at 0.25),cmn-15324743446256875074step 23 (17 at 0.25, 40820 at 0.25).Swaps:
1272-128104-0004step 11 (705 at 0.125, 11 at 0.000);cmn-10104380129516909856step 27 (3837 at0.25, 1773 at 0.000).
Listed exception (agreed on review, unchanged):
cmn-15324743446256875074step 10. Ours is 468 (margin 0.125).The bf16 reference picks 9197 (margin 0.25), with 468 third. The package's fp32 run picks 468, at 25.7277 against
9197's 25.7162.
Open fail,
cut50step 3: ours is 5632 with margin 0.625 over 18284. The reference case picks 18284 at0.125. The package's own teacher-forced logits on this clip disagree with that case: its bf16 run puts 5632 first
(22.75 against 22.625) and its fp32 run puts 18284 first (22.7922 against 22.5113). With the bf16-rounded norms
(r4) this step was a swap at 0.25; qwen3 cuda: Qwen3 embedding checkpoints (BF16) on the native CUDA engine (#2261, 1 of 2) #2285's fp32 norms move it to 0.625.
The rule for listing a step (review, 6826729645): the package's bf16 and fp32 runs order the two tokens oppositely,
and either our pick is the fp32 pick or our fp32 distance on that clip is no worse than the package's bf16. Step
10 meets it.
cut50step 3 meets the first part, and the whole clip is closer to fp32 than bf16 is, but step 3alone is not (0.667 / 0.1191 against 0.536 / 0.0843, table below; our worst column there is 18284 itself). So it
is not listed, and this stays draft.
Stage compare at step 3 against the package's fp32 run: the tower is level with bf16. Through LM layer 20 our
mean is at or below bf16's. From
lm_layer21both columns are above it, and 18284's lead (a logit lens throughthe final norm and head rows) falls further behind fp32 over layers 21-27. At the head the lead is -0.625 for
ours, -0.125 for bf16 and +0.281 for fp32: the gap builds up, with no single stage out of line.
The prompt is extended by the forced ids of steps 0-2. LM rows are at step 3's row; worst column / mean |diff|
to fp32; the lead is 18284 minus 5632 through the lens:
On review (6840111036) this reads as bf16 precision on a two-step tie, not a defect. The fail stands, and a new
gate on fresh clips was agreed before any run, and it passes (Gate 2 above).
rows one position late move no top token, but they raise the worst fp32 distance to 14.26 / 7.68.
Distance to the package's fp32 run, on
51dc03072At the final logits, teacher-forced on the package's greedy ids. Each cell is worst column / mean |diff|:
cut50, 9 stepscut50, step 3 aloneOn #2285's pass, our mean distance is below the package's bf16 run in 5 of 6 dev cells. The worst column is below it
in 5. On
cut50the whole clip is below it in both; step 3 alone is above it in both.cut50step 3 alone: the same clip and tool, with the case's prompt extended by the forced ids of steps 0-2. As acheck, the step 0-2 and step 0-3 slices give the same step-3 mean by difference (0.1191 ours, 0.0843 bf16).
In r4 the 0.6B means were 0.133 / 0.102 / 0.085.
Decode against prompt, two passes against one, on
7e9b99f2atf-qwen3-asr-forced --rows 8, no other flag): the prompt pass's last 9 rows equal the 9 decode steps bitfor bit. A prompt split in two passes inside the audio rows leaves 0 cache values different and the same last logits.
That holds on all six dev runs (0.6B and 1.7B, three clips each), because
gemm.zigkeeps one algorithm per (n, k)at every row count.
lm_test.zig): the same two equalities, and a planted cache-slot fault fails them.Embedding bytes against main
Qwen3-Embedding-0.6B (the size on the GB10 now), main
6d0a128b0against7e9b99f2a, each built withzig build native -Dnvccand served withserve --context 32768: the sha256 of every returned fp32 vector matchesmain's (the 4 card texts alone and together, and seeded inputs of 2048, 8192, 16384 and 30000 ids, 9 of 9 requests).
They also equal
51dc03072's. The batches over 32768 tokens are refused by name on both builds. Not run: 4B, 8B andthe Qwen3-Reranker checkpoints (not on disk). The rerankers reach
forwardFromwith a trunk and.{}, the calladmit's test passes.Earlier (r5,
51dc03072against000b534a2): every vector byte-equal in 0.6B, 4B and 8B, and the card texts equalArminova's
4257e6f01hashes.Kernels
tf_vit_conv_cols: 3x3 stride-2 conv taps, channels last;tf_vit_conv_flatten: torch's [c, f] rows;vision_kernel<64, 8>instance for windowed attention at head dim 64.kernel-contract's family sets; alone,tf-cuda-test kernel-contract tf_vit_conv qwen3-asr(on7e9b99f2a):all 3 kernels pass gates 1-4, and both planted controls (one per copy kernel) are caught.
zig/tests/cuda/main.zigis main's (600 lines).
These kernels compile to the same SASS on this head (below).
vision_kernel<64, 8>takes 128 registerson sm_120/121 instead of 120 and has its own record; the two copies compile the same.
Checks
Rebased on main
6d0a128b0. Conflicts:contract_controls_set.cukeeps main'scontract_experts_bf16_controls.cuhand ours;
qwen3_cuda.zigkeeps_ = native;and_ = pass;;lm.zigandweights.zigas above; CHANGELOG.vit.cuandprefill_attention.cuare byte-identical to2fe5b72d9's, and main hasn't changed them since000b534a2, so the SASS comparison below still holds.vit.cuandprefill_attention.cuat nvcc 13.0.88, main against this head, sm_80/86/89/120/121 (after main'stwo-query-heads change):
vit.cu: 55 of 55 records identical in res-usage and SASS;prefill_attention.cu: 70 of 70;Checks: on the GB10, every check exits 0 (on
7e9b99f2a, the code of3689e0113but one test pin):git diff --check,zig fmt --check,cuda_common_check, lean (221 against 221 on the base, 0 new),pr_check,zig build test,test-cuda-host,test-qwen3-asr-host,tf-qwen3-asrandtf-qwen3-asr-forced,test-qwen3-cuda-host,test-qwen3-checks-host,qwen3-cuda-gpu-build, the CI set (test-kernel-contract, test-golden, test-server-security,test-pull-security, fuzz-cortheon),
compile-cuda-testsfor aarch64 and x86_64,check-release-pathsandtest-gradient-serving. The x86 host set found one pin of ours:dense_serving_test.zigpinsprefill_attention.cu's bytes.3689e0113re-pins it, in the re-pin commit, with a line naming the addedvision_kernel<64, 8>, andtest-qwen-serving-hostis green. The x86 host set on3689e0113(-Dfixed-cpu test test-host test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths, thencheck-native-cuda-host compile-cuda-tests,pr_checkandzig fmt) passes except one test:cli_config_test's "serve --config: expandreads the file…" fails there because the CI user's umask is 0002. Its
serve.tomlis written 0664, andexpandrefuses a group-writable file. It passes on the GB10 (umask 0022), and this PR doesn't touch the server.
Seeded sampling and concurrency don't apply yet: nothing here is served (no lane until Nemotron 3.5 Transcribe: audio input, the 65,536-token window, an hour of audio, MTP drafts #1632), and the tools are
greedy on one stream. Resume is the two-pass split above (caches and logits bit-equal to one pass).
Proposed CHANGELOG line (Unreleased; the commit you asked for is
3689e0113):Qwen3-ASR 0.6B and 1.7B on CUDA: the audio tower and greedy decode, the language model through the Qwen3 CUDA pass (#2239).Next
The served path (a
qwen3_asrCUDA lane backend) waits for #1632. WER/CER, throughput and the 1.7B's eval follow.