Repository navigation
fix: apply HF Llama text_config defaults for LLaVA-1.5 on OpenXLA - #3396
Merged
Merged
Conversation
llava-1.5-7b-4bit declares text_config.model_type "llama" and leaves hidden_size, layer and head counts implicit, so the XLA host preprocessor refused it. Eager recovers the same values from the checkpoint tensors; the XLA path reads only config.json. A new ungated mlxcel-xla module holds one table of the transformers LlamaConfig defaults, applied (explicit values win) in the text-graph emitter config, the IREE vision config and both LLaVA host preprocessors. Besides the architecture sizes it sets tie_word_embeddings to false: the emitter's fallback for an absent key is tied, which replaced lm_head with the embedding table and made the text garbage once loading succeeded. A text model type without a known table still fails closed, and the error now names the field and the model type. Verified on llava-1.5-7b-4bit (cuda, greedy, 16 tokens): the OpenXLA token ids equal eager's. llava-interleave-qwen-0.5b-bf16 is unchanged. Unit tests cover defaulting, explicit values, kv heads, and the unknown-type fail-closed case. Refs #3366
Member
Author
Implementation Review SummaryIntent
Checkpoint scan (tie flag vs safetensors headers)
No local LLaVA-wrapper checkpoint relies on the old "absent means tied" fallback. The only Verified
Remaining Items
The issue asked to reuse the eager helper. Eager infers these fields from the weights rather than from a table, so a config-only table is a reasonable alternative and the module doc says why. Verification
|
The host preprocessor applied the llama text_config defaults to llava_next wrappers while the XLA text-graph emitter and vision config applied them to llava only, so a llava-hf/llava-v1.6-vicuna-7b-hf style config (llava_next wrapper, llama text, no hidden_size, no tie flag) resolved differently on the two sides. Add is_llava_text_defaults_wrapper (llava or llava_next, matching HF LlavaConfig and LlavaNextConfig) and use it in the host resolver, emitter Config and LlavaVisionConfig. The untied default is the same everywhere. Checkpoints that spell text_config out, including the mistral llava-next ones, are unchanged. LlavaVisionConfig still rejects the llava_next wrapper itself because the IREE vision graph has no anyres support. Tests cover implicit llama text for llava and llava_next (hidden 4096, tie false), an explicit tie flag winning, and the predicate. Validation: cargo test -p mlxcel-xla --lib llava Refs #3366
…xla-text-config-defaults # Conflicts: # CHANGELOG.md
Name the (field, default constructor) row type so cargo clippy -p mlxcel-xla --lib --tests -- -D warnings passes. Refs #3366
inureyes
marked this pull request as ready for review
November 24, 2026 07:22
…xla-text-config-defaults # Conflicts: # CHANGELOG.md
`mlxcel-xla` is an optional dependency of the root crate, so the default-feature build (CI cargo-clippy) failed to resolve `mlxcel_xla` in `src/loading/vlm_llava.rs`. The defaults table is applied only with `xla-backend`; without it the host config is left as declared and the missing-field error names the field. Refs #3366
This was referenced Nov 28, 2026
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.
llava-1.5-7b-4bitdeclarestext_config.model_type = "llama"and leaves the Llama sizes implicit, so OpenXLA refused it withtext_config.hidden_size is required. The fix applies the HFLlamaConfigdefaults for the declared model type in one shared mlxcel-xla table, used by the text-graph emitter, the IREE vision config and both LLaVA host preprocessors. Explicit values win, and an unknown text model type still fails closed with an error naming the field and the model type.One predicate,
is_llava_text_defaults_wrapper(wrapperllavaorllava_next, text model typellamaor absent, as HFLlavaConfig/LlavaNextConfigdo), gates the defaults in all three places so the host and emitter resolve the same config.LlavaVisionConfigstill rejectsllava_next(no anyres in the IREE vision graph), now pinned by a test. A review scan of every local LLaVA-family checkpoint found none relying on the old absent-means-tied behaviour.The table also sets
tie_word_embeddings=false. Without it the emitter's tied fallback replacedlm_headwith the embedding table and the text came out as garbage once loading worked.-n 16,--image tests/fixtures/test_image.png): OpenXLA token ids450 1967 338 263 3802 29899 786 310 385 24841 3239 29892 10075 263 10090 470equal eager's (MLXCEL_SDPA_DETERMINISTIC=1).llava-interleave-qwen-0.5b-bf16on OpenXLA is unchanged.cargo test -p mlxcel-xla --lib llava(15 tests, includingConfigparsing for implicitllavaandllava_nexttext configs and an explicit tie flag winning),cargo check --features cuda,xla-iree --all-targets,cargo check --no-default-features --features xla-diagnostics --all-targetsand the license header check pass.Closes #3366