Repository navigation
mtmd: enforce no_realloc - #33377
Open
ngxson wants to merge 12 commits into
Open
mtmd: enforce no_realloc#33377ngxson wants to merge 12 commits into
ngxson wants to merge 12 commits into
Conversation
Member
ServeurpersoCom
self-requested a review
December 2, 2026 17:17
… tensors A ggml_new_tensor scaled by 0 is not zero: the buffer is never written, so a NaN left by a previous graph comes out as NaN. Use ggml_pad_ext for the paddings and ggml_repeat_4d for img_break.
The pulse train turns a small F0 difference between backends into a phase drift, CUDA vs CPU gave NMSE 5.7e-2. Only the F0 bias is set so that F0 clamps the same everywhere, voicing and energy stay random.
ServeurpersoCom
approved these changes
Dec 2, 2026
ServeurpersoCom
left a comment
Contributor
There was a problem hiding this comment.
Tested on RTX PRO 6000 (CUDA) and Vulkan on the same card: with the two commits I pushed (uninitialized padding / img_break tensors, tiny_voca F0), every case not marked TODO passes on CUDA, and real-weights e2e on Qwen3.8-27B, Mistral Small 4 and Nemotron-3.5-Super-VL with a 4000x4000 image reads the text correctly under the new default cap.
Nits / improvements:
- test-mtmd-model is labeled "behavior backend" without "main", so no CI job runs it (GPU jobs use ctest -L main, behavior-check excludes backend): you could use "main behavior backend" like test-llama-archs, and since the branch is upstream the self-hosted runners would show the backends nobody ran yet before the merge.
- Forcing the TODO cases on CUDA (-t): deepseekocr, kimik25, kimik31, nemotron_omni and granite4_vision still grow the compute buffer after the warmup (kimik25 2122 -> 2255 MiB), so a NO_REALLOC build would abort on them.
- nemotron_omni is a one-liner: replacing warmup_image_size = image_size with set_default_max_patches() removes the realloc (checked on CPU, CUDA and the real Nemotron-3.5-Super-VL), but it also caps the model from 3328 to 2116 image tokens by default; warming up at the model max instead would keep the master output with a bigger buffer, your call.
- voxtral aborts on a 30 s clip (graph 188 tokens, n_output_tokens() 187), and master has the same count: avgpool then stack-by-4 on 1500 frames gives 188. The current HF VoxtralEncoder also defines avg_pooler without calling it, could you double check the pooling against the real weights?
- On Vulkan, dots3note_v is just over the threshold (NMSE 1.022e-4 vs 1e-4) with coopmat F16 matmuls, it passes with GGML_VK_DISABLE_COOPMAT=1 or GGML_VK_DISABLE_F16=1: you could give that case a precise TODO or a looser threshold.
- mimo_audio also fails on CUDA (NMSE 1e-3, RVQ argmax flips), its TODO only mentions Metal.
- The drama3 tower attention now always reads the 4096 slot rows: llama-tts goes from 5.88x to 5.44x realtime (146 -> 136 frames/s) on the Q8_0, you could bucket n_kv if that matters.
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.
Overview
Important
Side effect of this change: max image size will be set to a lower value by default, user need to explicitly raise the limit via CLI argument
Enforce no_realloc in mtmd
Mtmd was initially designed to take very arbitrary input: vision (dynamic image size), audio, and most recently many inner-stages embeddings shapes for TTS pipeline
This makes it hard to keep track of memory usage, and now it's a good time to finally refactor it.
Related: ngxson/wllama#319 --> copy device-to-host make the wasm run out of memory
Follow-up:
Requirements