Repository navigation
Conversation
…n float32's range on every device Metal and Vulkan stage the activations of a matrix product in half precision, and the CPU those of an F16 matrix, and a value past 65504 becomes inf. The inputs of the FFN down projections of a transformer pretrained as a language model, or of one that predicts audio tokens one at a time, reach that range at some tokens: Drama-3-Japanese, a fine-tune of fishaudio/drama-3, reaches 86,682 in its experts' down projection and 66,927 in its shared expert's, so that its prompts gave logits that were not finite on Metal (issue 237), and Qwen3-TTS 0.6B's code predictor reaches 188,823. Measured on the CPU over each family's own inputs (2026-11-29), those inputs reach 585 to 188,823 in the language models and token decoders, and the FFN down projections of the audio encoders, codecs and DiTs stay below 240. mul_mat_f32_activations() and mul_mat_id_f32_activations() in src/common/graph.h ask for GGML_PREC_F32 on src1, as SEMamba's own helper did, which they replace. The FFN down projections of Qwen3.5's decoder (Drama-3's experts, shared expert and Haru's dense layers), Qwen3's (Qwen3-TTS's talker and code predictor, Qwen3-ASR's decoder), Drama-3's audio decoder, Irodori-TTS's text encoders and Nemotron 3.5 Transcribe's experts and shared expert take them. The ggml fork's commit makes every backend keep such activations' range for every matrix type. The add-model skill says which products take them. Checked: Drama-3-Japanese Q4_K's twelve cases of the issue, without a voice and with one, speak on Metal (Apple M5), where five gave logits that were not finite before; the fork's cases and every MUL_MAT and MUL_MAT_ID case pass on Metal with and without the tensor API and on Vulkan through MoltenVK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ivations in float32's range The new record states the rule, the measurements behind it and the designs turned down: asking only on the reported products, asking on every product, scaling a family's activations in speech.cpp, turning fp16 off on Vulkan, and choosing the products by measuring each model's weights. The ggml fork's record gets the defect, the decision for every matrix type and backend, its row in the table, and the two designs of the fix turned down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ord the costs measured on Metal and Vulkan The fork's commit counted the shared memory of the F32 and F16 pipelines that keep their operands in float with a BK of 16, where mul_mm.comp takes 32 for those matrices whatever its constant says, so that a 128x128 tile needing 34,816 bytes was counted 18,432 and a device of 32 KiB could take a tile it cannot hold; it now counts 32 for every matrix. An RTX 2080's 48 KiB and MoltenVK's medium tiles hold every tile either way, so the pipelines there are the same. The records get the costs: on Metal the audio of Drama-3, Qwen3-TTS 0.6B and Irodori-TTS v4.1 stays the same bit for bit, and on an RTX 2080 the prompts of Qwen3-ASR 1.7B and Qwen3-TTS 0.6B slow by about a tenth, as their down projections leave the cooperative matrices. Checked: every MUL_MAT (2814) and MUL_MAT_ID (950) case passes on Vulkan0 through MoltenVK with the change. Found by the review of the ggml fork's commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #237.
What was wrong
Metal and Vulkan stage the activations of a matrix product in half precision, and the CPU those of an F16 matrix, so a
value past 65504 becomes inf. The inputs of a language model's FFN down projections pass that range at some tokens.
StudioYebisu's Drama-3-Japanese Q4_K (a fine-tune of fishaudio/drama-3) reaches 86,682 in its experts' down projection
and 66,927 in its shared expert's, and its prompts gave "logits that are not finite numbers" on Metal exactly where an
input passed 65504 (8 of 15 requests; the 7 below it spoke). ggml keeps a product's activations in range only where
ggml_prec_set_src(t, GGML_PREC_F32, 1)asks, and before this change only for an F32 matrix (the fork) and Metal'sMUL_MAT_ID (upstream); Vulkan refused such a MUL_MAT_ID, so asking for it on the experts would have moved them to the CPU.
Measured on the CPU over each family's own requests (a temporary probe in ggml-cpu, not part of this change):
Every other product's inputs stayed below 1,000 (but RE-USE's, which already ask).
What changed
metal, vulkan, cpu : keep activations that ask for GGML_PREC_F32 in their range in products of F16 and quantized matrices): Metal'skernel_mul_mmscales such activations by a power of two, as MUL_MAT_ID does, onboth paths (bit for bit unchanged within 32768); Vulkan keeps q8_1 for a matrix whose q8_1 kernel does not read the
blocks' sums and otherwise uses the float scalar shaders, for MUL_MAT and MUL_MAT_ID, and no longer refuses such a
MUL_MAT_ID; the CPU multiplies an F16 matrix in float (its F16 dot product summed in half on NEON).
mul_mat_f32_activations()/mul_mat_id_f32_activations()insrc/common/graph.h, which replaceSEMamba's own helper, on the FFN down projections of every transformer pretrained as a language model or that
predicts audio tokens one at a time: Qwen3.5 (Drama-3, Haru), Qwen3 (Qwen3-TTS, Qwen3-ASR), Drama-3's audio decoder,
Irodori-TTS's text encoders, Nemotron 3.5 Transcribe.
add-model skill.
Checked
quantized MUL_MAT of 64 rows or more, and every F16 case, whose CPU reference gave NaN), on Vulkan0 through MoltenVK
(every MUL_MAT of 12 rows or more; MUL_MAT_ID not supported), and on an RTX 2080 with the driver 610.88 from CI's
checks build (every quantized MUL_MAT of 12 rows or more, Q8_0 and Q6_K among them, since cooperative matrix 2 takes
no q8_1; MUL_MAT_ID not supported). With it, every MUL_MAT and MUL_MAT_ID case passes: 3004 and 872 on MTL0 either
way, 2814 and 950 on MoltenVK and on the RTX 2080.
logits that were not finite; after, all 15 speak, and three of them spoken in full are transcribed by Qwen3-ASR 1.7B as
their texts. On the RTX 2080 (default placement, most experts on the CPU) the request with a voice, whose shared
expert overflowed, failed before and speaks after.
checks/compare/same_audio.py, main against this branch, 7 prompts x 2 seeds: the sameaudio bit for bit for Drama-3 Q4_K, Qwen3-TTS 0.6B Q8_0, Irodori-TTS v4.1-Small F16 and v4.1-Small-MF Q8_0.
checks/run.py --devices cpu,gpuon the M5): haru F32 18 passed, semamba F32 10, qwen3-tts Q8_0 10,qwen3-asr Q8_0 18, irodori-tts F16 15, drama3 Q4_K 4 (the rest refuse quantized weights), none failed.
12.8 s in 0.55 s against 0.49 s (RTFx 23 against 26); Qwen3-TTS 0.6B Q8_0's first audio 31 ms against 28 ms;
Irodori-TTS v4.1 F16's 0.78 s against 0.77 s. The down projections leave the cooperative matrices on NVIDIA; the
README's RTX 2080 numbers are measured again for the release. A first run compiles the new pipelines once (Drama-3's
first audio took 16.7 s in it). Metal was not timed: its products stay as they were bit for bit within 32768, with two
small kernels before each down projection of more than 16 rows.
pipelines' shared memory counted with a BK of 16 where the shader takes 32, fixed in the fork's commit.
Not checked: Nemotron 3.5 Transcribe (no file on this machine), Irodori-TTS v4 Large, the small IQ3_XXS file (it needs a
third-party patch), Vulkan on AMD or Intel, and CUDA, which the fork does not change.
🤖 Generated with Claude Code