Skip to content

fix: NVFP4 direct transcode leaves gemma-4 vision-tower keys unmapped, so gemma-4-31b-it-nvfp4 rejects image input #749

Closed

Description

@inureyes

Summary

gemma-4-31b-it-nvfp4 loads and generates correctly on the text path (2026-07-12 GB10 sweep: 76.38 prefill / 4.88 decode tok/s), but any request with an image fails with Images provided but model is not a vision-language model. The checkpoint is a genuine multimodal export: config.json has vision_config (plus audio_config), model_type is gemma4 exactly like the working gemma-4-31b-it-4bit sibling, and the safetensors index contains 356 vision-related tensors (model.vision_tower.*, model.embed_vision.*). The NVFP4 key remapper appears to process only the text decoder: the loader log reports remapping 1372 keys out of 1728 total in the index, and 1728 - 1372 = 356, exactly the number of vision keys. The unmapped vision tower never binds, the model registers as non-VLM, and image requests are rejected at the vlm_runtime gate.

Environment

Repro

./target/release/mlxcel generate -m models/gemma-4-31b-it-nvfp4 \
    -p "What is in this image?" --image tests/fixtures/test_image.png -n 8

Observed output:

Remapping 1372 NVFP4-style weight keys to MLX-community convention...
Repacking 180 ModelOpt NVFP4 weight groups to MLX native NVFP4 via direct triplet transcode...
Model loaded in 90.895s (resident: 29.32 GB, peak: 34.34 GB).
Loaded 1 image(s).
Error: Images provided but model is not a vision-language model

The control gemma-4-31b-it-4bit (same model_type: gemma4) passes the same image prompt (2026-07-12 VLM sweep: 277 prompt tokens, 24 generated tokens, 422.29 prefill / 8.79 decode tok/s; exact row in benchmarks/cuda_gb10_vlm_2026-07-12.csv).

Analysis

  • Error site: should_prepare_vlm_embeddings in src/multimodal/vlm_runtime.rs (the is_vlm == false branch). This gate is behaving correctly; the defect is upstream in load.
  • The ModelOpt export nests projection weights one level deeper than the MLX-community convention (for example model.vision_tower.encoder.layers.0.mlp.down_proj.linear.weight, note the extra .linear segment), and the vision keys also carry the model. prefix. The NVFP4-style key remapper does not translate these, so the gemma4 vision tower construction finds no usable weights and the model is registered text-only.
  • Key arithmetic from the checkpoint: safetensors index has 1728 tensors; the loader remaps 1372; the 356 difference matches the count of vision/embed_vision tensors exactly.
  • The 2026-06-17 sweep never exercised this path (the nvfp4 checkpoint was entirely non-functional before the direct-transcode work fix(cuda): repack ModelOpt NVFP4 to native MLX layout #692/perf(nvfp4): direct-transcode ModelOpt triplets to MLX native #693/perf(nvfp4): direct-transcode ModelOpt triplets to MLX native #697), and the 2026-07-09 subset was text-only, so 2026-07-12 is the first time the NVFP4 image path was tested at all.
  • Open sub-question for the fix: whether the vision tower in this export is quantized (NVFP4 groups needing transcode) or kept in bf16/fp16; the loader repacked 180 NVFP4 groups which may or may not include vision tensors. The fix needs to handle whichever layout ModelOpt actually emits (inspect the dtypes of the vision tensors in the index).

Expected behavior

The NVFP4 direct-transcode path remaps and binds the vision tower (and the audio tower, given audio_config is present, or explicitly documents audio as out of scope), so gemma-4-31b-it-nvfp4 serves image input like its 4-bit sibling.

Acceptance criteria

  • Vision keys from the ModelOpt NVFP4 export are remapped/bound, and the model registers as a VLM.
  • The repro command above generates tokens for the image prompt.
  • A VLM benchmark row for gemma-4-31b-it-nvfp4 lands in benchmarks/ and in the VLM table of docs/benchmark_results/model_tests_gb10.md, which currently carries a FAIL row and a note that this needs a follow-up issue (update that note to reference this issue number).
  • A regression test covering vision-key remapping on an NVFP4-style key set (a unit test on the remapper is fine; no 31 GB fixture required).

References

Activity

  1. added
    status:ready
    type:bug
    priority:high
    area:models
    on Jul 12, 2026
  2. added
    status:in-progress
    status:review
    and removed
    status:ready
    status:in-progress
    on Jul 12, 2026
  3. added
    status:done
    and removed
    status:review
    on Jul 12, 2026
  4. self-assigned this
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:modelspriority:highstatus:donetype:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions