Skip to content

[None][refactor] Mistral Large 4: own the checkpoint weight loader and mapper - #21548

Merged
yizhang-nv merged 1 commit into
NVIDIA:feat/mistral-large-4from
yizhang-nv:codex/ml4-mergeback-weights
Nov 4, 2026
Merged

yizhang-nv merged 1 commit into
NVIDIA:feat/mistral-large-4from
yizhang-nv:codex/ml4-mergeback-weights

Conversation

@yizhang-nv

@yizhang-nv yizhang-nv commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

@coderabbitai summary

Description

Part of merging Mistral Large 4 back into main. This narrows how much of the shared checkpoint code ML4 support changes.

On feat/mistral-large-4, the mistral_large_4 checkpoint format reuses the generic HF classes:

  • HfWeightLoader and HfWeightMapper are registered for mistral_large_4.
  • HfWeightLoader._requires_lazy_safetensors reads params.json in every checkpoint directory. If the file describes a Mistral-native ML4 checkpoint, it forces lazy SafeTensors.

This PR moves both into checkpoints/mistral/:

  • MistralLarge4WeightLoader(HfWeightLoader) lives in the new mistral/weight_loader.py and is registered for mistral_large_4. Its _requires_lazy_safetensors always returns True, and it is the default weight loader of MistralLarge4CheckpointLoader.
  • MistralLarge4WeightMapper(HfWeightMapper) is registered for mistral_large_4. As before, it renames nothing, because the modeling_v2 targets read the Mistral-native tensor names themselves.
  • hf/weight_loader.py and hf/weight_mapper.py are back to their state at the merge base with main (59eab99). They no longer conflict with what main has since changed in those files.

Behavior:

  • With checkpoint_format="mistral_large_4", the checkpoint stays mmapped (lazy SafeTensors), and the mapper still renames nothing.
  • With any other format, HfWeightLoader no longer opens params.json for each checkpoint it loads.
  • model_loader._construct_checkpoint_loader passes checkpoint_io_policy and partial_model_loading only to an exact HfWeightLoader, so the ML4 loader now gets the defaults. Loading does not change: an ML4 checkpoint requires lazy SafeTensors, so a requested read-ahead policy already fell back to native. Only the checkpoint I/O status log differs, now reporting requested=native.
  • An ML4 directory loaded under a different checkpoint_format is no longer read lazily. That combination was already unsupported, and it still fails: the HF/default formats are rejected while the config loads, and mistral/mistral_large_3 prefix tensor names that the ML4 targets do not know.

The three modeling_v2 targets' weights.py files are unchanged.

Test Coverage

  • tests/unittest/_torch/test_model_config.py::test_mistral_large4_native_checkpoint is extended. It checks that mistral_large_4 resolves to MistralLarge4WeightLoader (lazy) and MistralLarge4WeightMapper, and that HfWeightLoader no longer treats a directory with only params.json as lazy.

  • The HF lazy-SafeTensors tests in tests/unittest/_torch/models/checkpoints/hf/test_weight_loader.py are unchanged and pass.

  • I ran the following locally on a B200 node with GPUs hidden (CUDA_VISIBLE_DEVICES=):

    pytest -m cpu_only tests/unittest/_torch/modeling_v2/models/mistral_large4 tests/unittest/_torch/models/checkpoints tests/unittest/_torch/test_model_config.py tests/unittest/_torch/modeling_v2/test_modeling_v2_routing.py tests/unittest/_torch/modeling_v2/test_modeling_v2_claims.py

    Result: 1201 passed, 481 skipped, 0 failed. The skipped cases need the ML4 checkpoint under LLM_MODELS_ROOT, which that node does not have.

  • Not run: GPU/sm_103 tests, and an end-to-end load of the real checkpoint on GB300.

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-compatible or api-breaking. For api-breaking, include BREAKING in 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

…d mapper

The mistral_large_4 checkpoint format registered the generic HF weight
loader and mapper, and HfWeightLoader._requires_lazy_safetensors sniffed
every checkpoint directory for a Mistral-native params.json to force lazy
SafeTensors for Mistral Large 4.

Move both into checkpoints/mistral/:
- MistralLarge4WeightLoader subclasses HfWeightLoader, always keeps the
  checkpoint mmapped, and is the default weight loader of
  MistralLarge4CheckpointLoader.
- MistralLarge4WeightMapper subclasses HfWeightMapper and renames
  nothing, as before.

hf/weight_loader.py and hf/weight_mapper.py return to their state before
Mistral Large 4 support was added.

Signed-off-by: Yi Zhang <[email protected]>
@yizhang-nv
yizhang-nv marked this pull request as ready for review November 4, 2026 07:06
@yizhang-nv
yizhang-nv requested review from a team as code owners November 4, 2026 07:06
@yizhang-nv
yizhang-nv merged commit bed3750 into NVIDIA:feat/mistral-large-4 Nov 4, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant