Repository navigation
Conversation
|
Thanks @jschmied. The Metal binding follows #2239. Using the core kernels wherever the rounding matches is the right call. Before it leaves draft:
|
…ashhart#2105) families/qwen3_asr/metal/ binds the shared schedules beside cuda/: one device with buffers addressed as slot << 40 | offset, the weights put as stored, and qwen3_asr.metal's kernels at the CUDA binding's bf16 points. Tower: conv taps (3x3 stride 2, channels last) into a GEMM with bias, torch's [c, f] flatten, LayerNorm, the exact GELU, and bidirectional attention a window at a time. LM: the embedding gather, add + RMS norm, q/k RMS norm with RoPE into the caches, causal GQA attention over them, SwiGLU, and the tied head; one-row GEMMs take a GEMV. tf-qwen3-asr-metal runs a clip against a case as tf-qwen3-asr does; compile-qwen3-asr-metal-host builds it without running shaders. On an M3 Pro, Qwen/Qwen3-ASR-0.6B, the greedy transcripts of LibriSpeech dev-clean 1272-128104-0000, -0001 and -0002 are byte-identical to qwen-asr 0.0.6's windowed reference (worst stage cosine 0.9986, at lm_layer27).
…nels (ashhart#2105) The binding now takes what core already has where its rounding points match the reference: shared_attention for the tower's windows (q, k and v split to its token-major rows, every key visible) and the LM's causal GQA (a byte mask a pass row, `ordinary` for decode), the Qwen-VL tower's tfp::gemm_nax for the LM's bias-free prompt GEMMs, and qwv_bias_gelu (exact, zero bias) for every GELU. qwen3_asr.metal keeps what has no core twin at these points: the biased GEMM and its one-row GEMV, conv taps, flatten, LayerNorm on bf16 rows, add + RMS norm, q/k norm with RoPE from transformers' bf16 tables, SwiGLU, the embedding gather and the q|k|v split. On the M3 Pro the three LibriSpeech dev-clean transcripts stay byte-identical (worst stage cosine 0.9988); the prompt pass takes 55-92 ms where it took 107-196 ms.
77ea0c5 to
ee48ea2
Compare
|
@ashhart restacked on main Rerun on this head: on the M3 Pro, 3 of 3 transcripts are byte-identical and the cosines equal the old rows; Your item 1 is covered by that rerun. Items 2-4 are still open: the kernel-contract records with Metal's |
Qwen3-ASR's Metal binding, for #2105. Head
ee48ea298: rebased onto maine6094de13on the user's request. #2239 has merged (7fb9fc661), so its commits are dropped; this PR is two commits (ab4e79403,ee48ea298). #2239 moved; still draft until the #2105 / #2118 decisions move.This head (
ee48ea298, on maine6094de13)The rebase conflicted only in
metal_targets.zig. Main's lines are kept, and ours were added next to them. Four edits follow main:shared_attention'sShapeno longer has.rotary_dim. BothAttention.initcalls inmetal/shared.zigdrop the field (it was 0).metal/tower.ziggainsdumping(). Main's tower schedule runsconv_outonce more without the positions, for the package's tap, only while dumping.tf-qwen3-asr-metalgathersconv_outover the chunk groups and compares it once whole, astf-qwen3-asrdoes on main.qwen3_asr_metal.zigtakes the metallib (or main's emptyno_shadersone) andno_compiler, asdrama3_metal.zigdoes. Without Xcode,tf-qwen3-asr-metalfails with main's message, and the compile check still builds.Rerun on this head:
test-qwen3-asr-hostgreen,zig fmt --checkandgit diff --checkclean,tools/pr_check.py0 errors, lean 0 new. The Metal binding and driver also compile for aarch64-macos here (build-obj, no SDK, no link), with 0 errors.metal_targets.zigis reached only on macOS), so a Linux build compiles none of it. The Mac'szig build testbelow is the full set.tf-qwen3-asr-metalmd5 1e91d14393c6c182cb70a2fcedeb971e.test-qwen3-asr-host28/28,compile-qwen3-asr-metal-host43/43.zig build test965/970 steps. The failures are exactly maine6094de13's set on the same Mac (deepseek_v41 vision_config ×2, persistence_identity, tensorfold-native's memcpy nm step). Two more in the first run were memory pressure from another job; both pass idle.What it adds
families/qwen3_asr/metal/besidecuda/: the binding the shared tower and LM schedules call, plusqwen3_asr.metal, thetf-qwen3-asr-metaltool andcompile-qwen3-asr-metal-host.shared_attentionfor the tower's windows, the LM's causal prompt and decode through the ordinary path;gemm_naxfor the LM's bias-free prompt GEMMs;qwv_bias_gelu(exact) for every GELU.tf_lane_ropecomputes its own);Gate (Qwen3-ASR-0.6B, M3 Pro)
The reference is qwen-asr 0.0.6's windowed backend, as on #2239.
Carried from the original run (the rows above are this head's):
a0b56fd67):test-qwen3-asr-hostgreen;zig build test694/694 steps (8880 passed, 68 skipped, 0 failed); lean 0 in the touched files.zig fmtand comment commits.77ea0c53e: lean 0 new,zig build test, the no-GPU CI set,git diff --checkandzig fmt --checkpass.Notes
tf-qwen3-asr-metalis an offline one-stream greedy tool, and no served path changes.qwen3-asr: the Metal binding (tower and Qwen3 LM, greedy on one queue) and tf-qwen3-asr-metal (#2254).tf-qwen3-asr-metalstops with main's existing no-compiler failure.