Repository navigation
[None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths - #21616
Merged
yizhang-nv merged 5 commits intoNov 4, 2026
Conversation
… the older-release fallbacks Mistral Large 4 needs mistral-common 1.13.0 (requirements.txt pins it for Python 3.11 and later). Check the installed version once, where the native config loader recognizes a Mistral Large 4 params.json, and raise an ImportError naming the required release. LLM initialization reads that config (ModelLoader._update_from_hf_quant_config) before it loads the tokenizer, so the check runs before any tekken.json is parsed. Remove the fallbacks that kept older releases working: - MistralTokenizer.from_pretrained no longer catches the pydantic ValidationError of a mistral-common without json_schema model settings, rewrites tekken.json into a temporary directory, or names the release for unknown reasoning efforts; __reduce__ loses its branch for that temporary copy. Added with Mistral Large 4 support (fece87e; internal history e899203965 and 3614ff7d23). The version check above replaces the reasoning-effort message. - _native_mistral_response_format imports JsonSchema directly instead of rendering without the response format when it is missing (internal history 47b02da413, for mistral-common 1.12.0). The tests that exercised only those fallbacks are removed, and the JsonSchema rendering test no longer skips. A CPU test covers the version check. requirements.txt keeps mistral-common>=1.10.0 on Python 3.10, which cannot load Mistral Large 4 and now gets the error above. A pre-release build also labelled 1.13.0 (c8cda03c) passes the check and still fails on the final checkpoint's tekken.json with a ValidationError; that environment issue is documented separately. Signed-off-by: Yi Zhang <[email protected]>
…behind Mistral Large 4 is served from the NVFP4 (ModelOpt MIXED_PRECISION) export only; the FP8 target was removed before this branch was created (internal history 87b26816af). Three pieces existed only for that target: - MistralNativeInputProcessor asked modeling_v2 routing whether the checkpoint's target encodes images and refused images otherwise (_serves_images, _check_images_served; internal history b6c67e5b2b). Every routed target is NVFP4 and encodes images, and the processor is only built for a checkpoint with a vision encoder, so the check never refuses anything; the runtime no longer imports modeling_v2 routing. - routing.serves_images also required the NVFP4 export. route() rejects any other quantization, so serves_images is now whether the config has a vision encoder. - adapt_config_dict refused a params.json `quantization` block (the FP8 export's format) for Mistral Large 4. Without it, such a checkpoint loads its config and is rejected where every other unsupported deployment is, when the model is built: with modeling_v2="require", "no target fits 'MistralLarge4ForCausalLM': ... quantization differs; the mistral_large4 targets are Mistral-Large-4-1T-A52B-NVFP4 (ModelOpt MIXED_PRECISION ...)". The other Mistral-native formats keep their mapping of that block. The tests of the removed checks go with them. Signed-off-by: Yi Zhang <[email protected]>
Mistral Large 4 support (fece87e) checked some chat request rules in more than one place. Keep one check per rule: - A request chat_template: the mistral_large_4 serving extension rejects it (HTTP 400) before rendering, and the server sets its own chat template aside for this format, so the native renderer in inputs/utils.apply_chat_template no longer rejects a chat_template (internal history e899203965). The server-level handling in openai_server stays: the extension sees only the request field. - Reasoning effort names: mistral-common validates the effort against the checkpoint's tekken.json when the chat renders, and the renderer turns its errors into ValueError (HTTP 400). The extension keeps only the check that a top-level reasoning_effort and chat_template_kwargs['reasoning_effort'] agree, and no longer compares the name with mistral-common's ReasoningEffort (internal history d30f426cd4, 3614ff7d23). An effort the final checkpoint does not declare, such as "none", is still a 400. The ChatCompletionRequest check that continue_final_message and add_generation_prompt are not both set stays: it covers every model, and the native renderers of other models (DeepSeek V3.2/V4/V4.1) ignore continue_final_message, so without it such a request would silently open a new assistant turn. Unknown efforts are asserted where they are now rejected, and the renderer's chat_template test is removed. Signed-off-by: Yi Zhang <[email protected]>
…s already guarantee modeling_v2 routing admits exactly one Mistral Large 4 layer structure and DSpark geometry, and the engine builds the model (and its cache manager) only after a target is routed. Several checks added with Mistral Large 4 support (fece87e) repeat what routing has already matched, or guard inputs their only callers never produce: - MistralLarge4CacheManager: the kv_source_layers validation, pp_size 1, num_layers, the SELFKONLY single-head latent, head_dim 512+64 and the indexer K-cache on every latent-sharing layer become one assert of the routed structure. The redundant `use_fp8_ds_mla = False` goes: the base class already sets it False because the manager hands it the "fp8" dtype. The dtype and pool-rebalance checks stay. (internal history 950911b13e, 696ed7fecc) - The native config loader no longer checks that kv_sharing and index_sharing have one entry per layer, or that the DSpark target_activation_layers are unique and ascending: routing matches both lists exactly ([1, 18, 36, 54, 71] for DSpark). (internal history e899203965, 4932efdc24) - DSparkWorker._apply_dspark_markov_bias no longer raises when a recurrent head gets no draft hidden states: its only caller always passes them. (internal history 4932efdc24) - RankState.deserialize no longer reads attention-DP payloads without the speculative-decoding fields: every rank runs the same build and serializes them. Payloads without the forward-work counters are still read, as before Mistral Large 4 support. - KVCacheManagerV2.get_layer_page_index_scale and DSACacheManagerV2.get_primary_pool_page_index_params no longer raise for a layer that owns no KEY buffer; the generic callers skip such layers and the Mistral Large 4 targets only address owner layers. The latter returns None for such a layer. (internal history 696ed7fecc) - _native_mistral_messages keeps its image-only check on the request's media and drops the per-part repeat of it, along with the image count invariants that the chat parser's per-message counts already ensure. (internal history e899203965) - LmEvalWrapper no longer validates the token ids it serialized itself. (internal history e899203965) The tests of the removed checks go with them; the cache layout test now expects None for a sharer layer's page-index params. Signed-off-by: Yi Zhang <[email protected]>
…cache algorithm A Mistral Large 4 params.json states its FP8 latent cache as dsa.fp8_kv_cache rather than as a kv_cache_quant_algo. ModelConfig and ModelLoader._update_from_hf_quant_config each mapped it with a branch on the architecture or checkpoint format (fece87e). The native config adapter now writes it into the checkpoint's ModelOpt quantization_config as kv_cache_quant_algo FP8 (unless that config already states one), and both generic readers take it from there like any other ModelOpt checkpoint. Neither keeps a Mistral Large 4 branch. Unchanged: kv_cache_config.dtype "auto" keeps FP8 and an explicit dtype overrides it; ModelConfig and llm.args report the same kv_cache_quant_algo for auto, fp8, fp8_ds_mla and nvfp4; routing still reads fp8_kv_cache; the cache manager is still MistralLarge4CacheManager. The per-module QuantConfigs of the MIXED_PRECISION map now also carry FP8 with dtype "auto", as they already did with an explicit "fp8"; nothing reads their KV-cache algorithm. This change is kept separate so that it can be reverted on its own. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
marked this pull request as ready for review
November 4, 2026 08:51
yizhang-nv
requested review from
a team,
Wanli-Jiang,
WeiHaocheng and
litaotju
as code owners
November 4, 2026 08:51
yizhang-nv
requested review from
BowenFu,
PerkzZheng,
eopXD,
liji-nv and
zhaoyangwang-nvidia
November 4, 2026 08:51
1 task
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 8, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main 19c1f46: - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - Per-rank spec-decoding stats travel in main's versioned rank-state frame (version -2 adds a spec snapshot); KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds render_needs_media, forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Warmup/ADP dummies keep the joint-KV-reuse draft allocation on main's dummy request arguments. - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python 0.7.2 and xgrammar 0.2.8 from main; llguidance 1.7.6 and mistral-common>=1.13.0 (Python >= 3.11) from the feature branch. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 12, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main 19c1f46: - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - Per-rank spec-decoding stats travel in main's versioned rank-state frame (version -2 adds a spec snapshot); KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds render_needs_media, forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Warmup/ADP dummies keep the joint-KV-reuse draft allocation on main's dummy request arguments. - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python 0.7.2 and xgrammar 0.2.8 from main; llguidance 1.7.6 and mistral-common>=1.13.0 (Python >= 3.11) from the feature branch. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 13, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main 19c1f46: - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the runtime fixes main took in NVIDIA#21788 (FlashMLA GIL release, attention-DP dummy paired draft KV, context warmup beside a capturable guided decoder, per-rank spec-decoding stats), and the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds render_needs_media, forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python 0.7.2 and xgrammar 0.2.8 from main; llguidance 1.7.6 and mistral-common>=1.13.0 (Python >= 3.11) from the feature branch. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 17, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main (first 19c1f46, now 3705333 with NVIDIA#22185): - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the runtime fixes main took in NVIDIA#21788 (FlashMLA GIL release, attention-DP dummy paired draft KV, context warmup beside a capturable guided decoder, per-rank spec-decoding stats), and the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python and xgrammar from main; llguidance and mistral-common from NVIDIA#22185. Stacked on NVIDIA#22185 (Mistral-native serving). The Mistral-native code that selection, the xgrammar and llguidance Tekken tokenizers, mistral-common chat rendering with images and the mistral_native serving extension, the KV-cache-aware router, trtllm-bench and lm-eval's deferred native chat, and passing history tool-call arguments to mistral-common as sent. On top of it, Mistral Large 4 keeps: - its model type among the native Mistral model types, with its placeholder metadata; - MistralLarge4ServingExtension as a subclass of the Mistral-native one (which now registers for mistral_common only), adding the output-budget check, the forced tool-call grammar and the raw structured-output grammar; - the llguidance JSON grammar that may open with a [THINK] section and the tool-call grammar, from mistral-common's grammar factory; - a Mistral Large 4 prompt's token ids with one [IMG] per image expanded to the image grids (other checkpoints keep NVIDIA#22185's check); - lm-eval's native chat token ids and scoring on the reasoning parser's content, and mistral-style tool-call ids. The feature branch's own copies of these paths, its native_chat processor branch and its coercion of malformed history tool-call arguments are dropped. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 20, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main (first 19c1f46, now 3705333 with NVIDIA#22185): - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the runtime fixes main took in NVIDIA#21788 (FlashMLA GIL release, attention-DP dummy paired draft KV, context warmup beside a capturable guided decoder, per-rank spec-decoding stats), and the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python and xgrammar from main; llguidance and mistral-common from NVIDIA#22185. Stacked on NVIDIA#22185 (Mistral-native serving). The Mistral-native code that selection, the xgrammar and llguidance Tekken tokenizers, mistral-common chat rendering with images and the mistral_native serving extension, the KV-cache-aware router, trtllm-bench and lm-eval's deferred native chat, and passing history tool-call arguments to mistral-common as sent. On top of it, Mistral Large 4 keeps: - its model type among the native Mistral model types, with its placeholder metadata; - MistralLarge4ServingExtension as a subclass of the Mistral-native one (which now registers for mistral_common only), adding the output-budget check, the forced tool-call grammar and the raw structured-output grammar; - the llguidance JSON grammar that may open with a [THINK] section and the tool-call grammar, from mistral-common's grammar factory; - a Mistral Large 4 prompt's token ids with one [IMG] per image expanded to the image grids (other checkpoints keep NVIDIA#22185's check); - lm-eval's native chat token ids and scoring on the reasoning parser's content, and mistral-style tool-call ids. The feature branch's own copies of these paths, its native_chat processor branch and its coercion of malformed history tool-call arguments are dropped. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 23, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main (first 19c1f46, now 3705333 with NVIDIA#22185): - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the runtime fixes main took in NVIDIA#21788 (FlashMLA GIL release, attention-DP dummy paired draft KV, context warmup beside a capturable guided decoder, per-rank spec-decoding stats), and the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python and xgrammar from main; llguidance and mistral-common from NVIDIA#22185. Stacked on NVIDIA#22185 (Mistral-native serving). The Mistral-native code that selection, the xgrammar and llguidance Tekken tokenizers, mistral-common chat rendering with images and the mistral_native serving extension, the KV-cache-aware router, trtllm-bench and lm-eval's deferred native chat, and passing history tool-call arguments to mistral-common as sent. On top of it, Mistral Large 4 keeps: - its model type among the native Mistral model types, with its placeholder metadata; - MistralLarge4ServingExtension as a subclass of the Mistral-native one (which now registers for mistral_common only), adding the output-budget check, the forced tool-call grammar and the raw structured-output grammar; - the llguidance JSON grammar that may open with a [THINK] section and the tool-call grammar, from mistral-common's grammar factory; - a Mistral Large 4 prompt's token ids with one [IMG] per image expanded to the image grids (other checkpoints keep NVIDIA#22185's check); - lm-eval's native chat token ids and scoring on the reasoning parser's content, and mistral-style tool-call ids. The feature branch's own copies of these paths, its native_chat processor branch and its coercion of malformed history tool-call arguments are dropped. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 23, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main (first 19c1f46, now 3705333 with NVIDIA#22185): - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the runtime fixes main took in NVIDIA#21788 (FlashMLA GIL release, attention-DP dummy paired draft KV, context warmup beside a capturable guided decoder, per-rank spec-decoding stats), and the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python and xgrammar from main; llguidance and mistral-common from NVIDIA#22185. Stacked on NVIDIA#22185 (Mistral-native serving). The Mistral-native code that selection, the xgrammar and llguidance Tekken tokenizers, mistral-common chat rendering with images and the mistral_native serving extension, the KV-cache-aware router, trtllm-bench and lm-eval's deferred native chat, and passing history tool-call arguments to mistral-common as sent. On top of it, Mistral Large 4 keeps: - its model type among the native Mistral model types, with its placeholder metadata; - MistralLarge4ServingExtension as a subclass of the Mistral-native one (which now registers for mistral_common only), adding the output-budget check, the forced tool-call grammar and the raw structured-output grammar; - the llguidance JSON grammar that may open with a [THINK] section and the tool-call grammar, from mistral-common's grammar factory; - a Mistral Large 4 prompt's token ids with one [IMG] per image expanded to the image grids (other checkpoints keep NVIDIA#22185's check); - lm-eval's native chat token ids and scoring on the reasoning parser's content, and mistral-style tool-call ids. The feature branch's own copies of these paths, its native_chat processor branch and its coercion of malformed history tool-call arguments are dropped. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 24, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main (first 19c1f46, now 3705333 with NVIDIA#22185): - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the runtime fixes main took in NVIDIA#21788 (FlashMLA GIL release, attention-DP dummy paired draft KV, context warmup beside a capturable guided decoder, per-rank spec-decoding stats), and the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python and xgrammar from main; llguidance and mistral-common from NVIDIA#22185. Stacked on NVIDIA#22185 (Mistral-native serving). The Mistral-native code that selection, the xgrammar and llguidance Tekken tokenizers, mistral-common chat rendering with images and the mistral_native serving extension, the KV-cache-aware router, trtllm-bench and lm-eval's deferred native chat, and passing history tool-call arguments to mistral-common as sent. On top of it, Mistral Large 4 keeps: - its model type among the native Mistral model types, with its placeholder metadata; - MistralLarge4ServingExtension as a subclass of the Mistral-native one (which now registers for mistral_common only), adding the output-budget check, the forced tool-call grammar and the raw structured-output grammar; - the llguidance JSON grammar that may open with a [THINK] section and the tool-call grammar, from mistral-common's grammar factory; - a Mistral Large 4 prompt's token ids with one [IMG] per image expanded to the image grids (other checkpoints keep NVIDIA#22185's check); - lm-eval's native chat token ids and scoring on the reasoning parser's content, and mistral-style tool-call ids. The feature branch's own copies of these paths, its native_chat processor branch and its coercion of malformed history tool-call arguments are dropped. Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv
added a commit
to yizhang-nv/TensorRT-LLM
that referenced
this pull request
Nov 26, 2026
Squash of the Mistral Large 4 work on feat/mistral-large-4 (3fb4be0), applied on main (first 19c1f46, now 3705333 with NVIDIA#22185): - fece87e [None][feat] Add Mistral Large 4 support - 9df1a00 [None][fix] Keep requirements installable on Python 3.10 - 5f00308 [None][doc] Mistral Large 4: install from the release container or wheel (NVIDIA#21425) - bed3750 [None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper (NVIDIA#21548) - 3fb4be0 [None][chore] Mistral Large 4: remove defensive checks and leftovers of removed paths (NVIDIA#21616) Not carried: the runtime fixes main took in NVIDIA#21788 (FlashMLA GIL release, attention-DP dummy paired draft KV, context warmup beside a capturable guided decoder, per-rank spec-decoding stats), and the six infra commits already on main (NVIDIA#21133, NVIDIA#19557, (cf7ae79, 1.4.0a0). Adapted to main: - modeling_v2 routing: the family registers its route with @routes("MistralLarge4ForCausalLM") and models/__init__.py imports it; route takes (model_config, llm_args, compute_capability). The routing tests use main's per-family sm_103 fixture; the engine-config tests record the route through registered_routes and resolve on one rank. - thop_attention call sites use main's argument names (workspace, spec_decoding_position_offsets); top_k kernels come from _torch/kernels/blackwell/top_k. - Catalog: the targets' cells move into each op test's TARGET_CELLS (comm ops keep them in CELLS, as main's comm ops do); bmm_out keeps main's op. - DSpark/DFlash: the native drafter's hooks sit on main's refactored worker (block placement, vocab-parallel drafting, Markov TP exchange); the recurrent Markov head takes its hidden states directly and the fused paged-latent path is not taken for drafters with their own block embedding. - KVCacheManagerV2 keeps has_buffer next to main's mixed-precision get_buffers. - Serving: the chat path runs on main's prompt pipeline and ServingExtension hooks; Mistral Large 4 adds forced_tool_call_decoding ("native" required-tool mode) and validate_chat_request. `store` follows main (accepted and ignored). - Tests follow main's engine/runner refactor (ModelEngine, filter_prefill_capture_num_tokens, removed validate_feature_combination), main's scoped reference precision (true_fp32_matmul) and scoped engine environments (scoped_env_overrides). - Dependencies: flashinfer-python and xgrammar from main; llguidance and mistral-common from NVIDIA#22185. Stacked on NVIDIA#22185 (Mistral-native serving). The Mistral-native code that selection, the xgrammar and llguidance Tekken tokenizers, mistral-common chat rendering with images and the mistral_native serving extension, the KV-cache-aware router, trtllm-bench and lm-eval's deferred native chat, and passing history tool-call arguments to mistral-common as sent. On top of it, Mistral Large 4 keeps: - its model type among the native Mistral model types, with its placeholder metadata; - MistralLarge4ServingExtension as a subclass of the Mistral-native one (which now registers for mistral_common only), adding the output-budget check, the forced tool-call grammar and the raw structured-output grammar; - the llguidance JSON grammar that may open with a [THINK] section and the tool-call grammar, from mistral-common's grammar factory; - a Mistral Large 4 prompt's token ids with one [IMG] per image expanded to the image grids (other checkpoints keep NVIDIA#22185's check); - lm-eval's native chat token ids and scoring on the reasoning parser's content, and mistral-style tool-call ids. The feature branch's own copies of these paths, its native_chat processor branch and its coercion of malformed history tool-call arguments are dropped. Signed-off-by: Yi Zhang <[email protected]>
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.
@coderabbitai summary
Summary
Part of merging Mistral Large 4 back into
main. This PR removes defensive code that Mistral Large 4 support (fece87edc4) added, and code that only served paths removed earlier: the FP8 target and mistral-common releases before 1.13.0. It reduces how much Mistral Large 4 code runs in shared files.Base:
feat/mistral-large-4atbed375052a(#21548). The modeling_v2 targets do not change; outsiderouting.serves_images, everything is runtime code. Five commits, each with its rationale in the commit message:Require mistral-common 1.13.0 and drop the older-release fallbacks. One version check in
checkpoints/mistral/config_loader.py, where a Mistral Large 4params.jsonis recognized. LLM initialization reaches that point (ModelLoader._update_from_hf_quant_config) before it loads the tokenizer. The check raisesImportError: Mistral-Large-4 requires mistral-common>=1.13.0 (Python 3.11 or later); the installed version is X. Removed:MistralTokenizer.from_pretrainedValidationError fallback, which rewrotetekken.jsoninto a temporary directory, together with its__reduce__branch and its reasoning-effort message;JsonSchemaImportError fallback in_native_mistral_response_format.The Tekken
__reduce__fix stays.requirements.txtis unchanged: Python 3.10 keepsmistral-common>=1.10.0and now gets this error for Mistral Large 4.Drop what the removed FP8 target left behind.
MistralNativeInputProcessor._serves_images/_check_images_served, which also removes the V1 → modeling_v2 routing import.routing.serves_imagesis now justvision_config is not None.adapt_config_dictno longer refuses a params.jsonquantizationblock.Check each chat request rule once.
chat_template. The serving extension still returns 400 for a request-levelchat_template.Drop checks that routing or the callers already guarantee.
MistralLarge4CacheManager: the structural checks become one assert, and the redundantuse_fp8_ds_mla = Falseis removed.RankState.deserializeno longer accepts payloads without the spec-decoding fields.KVCacheManagerV2.get_layer_page_index_scaleandDSACacheManagerV2.get_primary_pool_page_index_paramsare removed._native_mistral_messagesare removed.State
fp8_kv_cacheas the ModelOpt KV-cache algorithm (D3). The native config adapter writeskv_cache_quant_algo: FP8into the checkpoint'squantization_config(unless it already states one). The Mistral Large 4 branches inModelConfig.from_pretrainedandModelLoader._update_from_hf_quant_configare removed. This commit is kept separate so it can be dropped on its own.Kept on purpose (they looked like duplicates, but are not):
openai_serversets a server-level--chat_templateaside for this format and warns. The extension only sees the request field.BaseLLM._try_load_tokenizerselects mistral-common forcheckpoint_format="mistral_large_4". Without it, a directory that also shipsconfig.json+tokenizer.jsonwould get the HF tokenizer, which breaks the one-switch rule (test_the_native_format_loads_mistral_common_even_beside_a_config).ChatCompletionRequeststill rejectscontinue_final_messagetogether withadd_generation_prompt. It covers every model, and the DeepSeek V3.2/V4/V4.1 native renderers ignorecontinue_final_message. Without the check, those models would silently open a new assistant turn.BaseLLMstill skipsgeneration_config.jsonfor this format, because the final checkpoint ships one.What users see differently:
quantizationblock now fails when the model is built, not when the config loads. Withmodeling_v2="require"the error is:no target fits 'MistralLarge4ForCausalLM': ... quantization differs; the mistral_large4 targets are Mistral-Large-4-1T-A52B-NVFP4 (ModelOpt MIXED_PRECISION ...).chat_template_kwargs(for exampleturbo) still gets HTTP 400, now with mistral-common's validation message instead of the extension's. An effort the checkpoint does not declare is rejected as before; fornonethe message isreasoning_effort should be one of ['low', 'medium', 'high'], got none.Validation
Environment: one B200 node (umbriel-b200-034), dev container, CPU only (
CUDA_VISIBLE_DEVICES=), mistral-common 1.13.1 and llguidance 1.7.6 from PyPI. The same commands ran onbed375052aand on this branch.L0 (frontend CPU tests, run with
pytest -m cpu_only):bed375052amodeling_v2/models/mistral_large4,models/checkpoints,test_model_config.py,test_modeling_v2_{routing,claims}.pyMISTRAL_LARGE4_CHECKPOINT_DIR= final checkpoint (v3) metadatabed375052a. Those tests hard-codereasoning_effort="low", which the earlier checkpoint does not declare. This PR does not change them.tekken.json/params.json,openai_chatthrough FastAPI's TestClient), compared before and after:ModelConfigandllm.argsresolve the samekv_cache_quant_algoand select the same cache manager (MistralLarge4CacheManager) for KV dtypeauto/fp8/fp8_ds_mla/nvfp4, and rejectbf16the same way. Routing picks the same target.auto, the per-module QuantConfigs of the MIXED_PRECISION map now carry FP8, as they already did with an explicitfp8. Nothing reads them.unset/low/none/max/minimal/unknown/conflicting, requestchat_template, continuation flags, andjson_object.pre-commit run --fileson every changed file: passed.Not run, so INCONCLUSIVE until run:
rank_state,kv_cache_manager_v2/ DSA cache manager, the native image path;test_mistral_large4_cache_layout.pychanged (sharer layers now expectNonepage-index params). It was only collected, not run.Deviations from the workflow
Runtime changes outside modeling_v2, per commit:
_torch/models/checkpoints/mistral/config_loader.py,_torch/models/checkpoints/mistral/tokenizer.py,inputs/utils.py_torch/models/checkpoints/mistral/config_loader.py,_torch/models/modeling_mistral.py(plusmodeling_v2/models/mistral_large4/routing.pyinside modeling_v2)inputs/utils.py,serve/extensions/mistral_large_4.py_torch/attention/backends/sparse/dsa/cache_manager.py,_torch/attention/backends/sparse/mistral_large4/cache_manager.py,_torch/models/checkpoints/mistral/config_loader.py,_torch/pyexecutor/kv_cache/kv_cache_manager_v2.py,_torch/pyexecutor/scheduler/rank_state.py,_torch/speculative/dspark.py,evaluate/lm_eval.py,inputs/utils.py_torch/model_config.py,_torch/models/checkpoints/mistral/config_loader.py,llmapi/llm_utils.pyShared files that other models run through:
KVCacheManagerV2.get_layer_page_index_scaleis back to itsmainform.DSACacheManagerV2.get_primary_pool_page_index_paramsreturnsNoneinstead of raising; only Mistral Large 4 managers have layers without a KEY buffer.RankState.deserializestill reads payloads without the forward-work counters, as onmain.model_config.pyandllm_utils.pyonly lose Mistral Large 4 branches.No other model's behavior changes, and no other target's gates were re-run.
Commit messages cite the internal development history by SHA, because
fece87edc4squashed it.GitHub only, per the merge-back task; the internal GitLab is not used.
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.🤖 Generated with Claude Code