Repository navigation
fix(xla): read eos_token_id from config.json when generation_config is absent - #3313
Conversation
…s absent The XLA backend read EOS only from generation_config.json. Checkpoints such as qwen2.5-vl-3b-instruct-4bit ship none, so the decode loop ran past EOS 151645 while the eager path stopped. read_eos now resolves through a pure resolve_eos_ids: generation_config.json eos_token_id, else config.json eos_token_id, else config.json text_config.eos_token_id, accepting an int or a list. Missing or malformed files count as absent, and ids outside i32 are skipped instead of wrapping. The resolver is not iree-gated, so its unit tests run without the IREE link. Verified on qwen2.5-vl-3b-instruct-4bit (CUDA, test_image.png, -n 64 --temp 0): XLA now stops at EOS with the same 8-token output as eager. cargo check passes for cuda,xla-iree and for xla-diagnostics. Refs #3292
The first fix took the first non-empty of generation_config, config.json and text_config, while eager stops on the de-duplicated union of generation_config, the tokenizer's eos_token (tokenizer_config.json, falling back to tokenizer.json) and config.json. A checkpoint whose sources disagree let the XLA loop run past a token eager stops on. mlxcel-xla now resolves the union of its three config sources through a public config_eos_token_ids, and its sessions, batch engines and bucket sets gain set_eos_token_ids. The root crate passes the eager stop set (merged_eos_token_ids over those ids, as the LLaVA loader does for text_config) into both production paths: the single-session builder and the XLA serving worker's bucket set. Callers that set nothing keep the crate's own config ids. Root tests pin the XLA stop set to read_eos_token_ids on fixtures whose generation_config, tokenizer_config and config.json declare different ids, including the tokenizer.json lookup. Refs #3292
Implementation Review SummaryIntent
Findings Addressed
Remaining Items
Verification
|
|
Security and performance review of the EOS id resolution (#3292): no CRITICAL or HIGH findings, no code changes pushed.
MEDIUM (not fixed, matches eager): the sidecar files are read with LOW: the Tests run: |
Summary
The XLA backend read EOS only from
generation_config.json, so checkpoints without one (qwen2.5-vl-3b-instruct-4bit) generated past EOS 151645 while eager stopped.mlxcel_xla::config_eos_token_ids(union ofgeneration_config.json,config.jsonandtext_configeos_token_id) withread_eos_token_ids(which also resolves the tokenizer'seos_tokenviatokenizer_config.jsonortokenizer.json) and passes it through the newset_eos_token_idsin both production paths: the single-session builder and the XLA serving worker.Test plan
cargo test -p mlxcel-xla --lib --profile test-fast eos_resolution: 8 passed (generation_config present, only config.json, only text_config, neither, union and de-dup, malformed file). The resolver is not iree-gated because the iree lib test build fails to linkiree_runtime_*on main.cargo test --profile test-fast --lib --features cuda,xla-backend backend::xla::eos_parity_tests: 3 passed; the XLA stop set equalsread_eos_token_idson fixtures where generation_config, tokenizer_config and config.json declare different ids, including the tokenizer.json lookup.test_image.png, "Describe this image.",-n 64 --temp 0: XLA and eager both print "The image is a solid orange color." and stop after 8 tokens.cargo check --features cuda,xla-iree --all-targets,cargo check --no-default-features --features xla-diagnostics --all-targets, clippy-D warningson mlxcel-xla (with and withoutiree) and the root lib.Closes #3292