Skip to content

[https://nvbugs/6185234][fix] route load_hf_model_config via AutoConfig - #14410

Merged
Hudayday merged 1 commit into
NVIDIA:mainfrom
Hudayday:tianruih/v32-load-hf-config-autoconfig
May 22, 2026
Merged

[https://nvbugs/6185234][fix] route load_hf_model_config via AutoConfig#14410
Hudayday merged 1 commit into
NVIDIA:mainfrom
Hudayday:tianruih/v32-load-hf-config-autoconfig

Conversation

@Hudayday

@Hudayday Hudayday commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #14293. ModelLoader.load_hf_model_config in
tensorrt_llm/llmapi/llm_utils.py was still calling
transformers.PretrainedConfig.from_pretrained directly, which bypasses
the transformers.models.auto.configuration_auto.CONFIG_MAPPING that
#14293 registers deepseek_v32 / kimi_k2 into. On transformers 5.5.x
the base-class from_pretrained returns a bare PretrainedConfig that
lacks max_position_embeddings. Route through AutoConfig.from_pretrained
so the #14293 mapping applies.

Symptom and CI history

L0_PostMerge stage
GB200-36_GPUs-9_Nodes-PyTorch-Disagg-PerfSanity-CTX1-NODE1-GPU4-GEN1-NODE8-GPU32-Post-Merge-9,
test perf/test_perf_sanity.py::test_e2e[disagg_upload-gen_only-gb200_deepseek-v32-fp4_8k1k_con1024_ctx1_dep4_gen1_dep 32_eplb256_mtp3_ccb-NIXL]:

GEN_0.0.log:35 at build 2726 still shows:

[TRT-LLM] [W] [llmapi] Failed to load hf model config from
.../DeepSeek-V3.2-Exp-FP4-v2, encountered error:
'PreTrainedConfig' object has no attribute 'max_position_embeddings'

— because PretrainedConfig.from_pretrained doesn't consult CONFIG_MAPPING,
so #14293's registration is moot for this call path. The function returns
None, downstream uses a fallback path that doesn't match the V3.2 config
shape, and on 9-node MPI weight-load workers eventually die mid-load with
PMIX -61 LOST_CONNECTION_TO_PEER.

Mechanism

transformers.PretrainedConfig.from_pretrained (base class) does not
dispatch through CONFIG_MAPPING. AutoConfig.from_pretrained does.
Routing the call through AutoConfig is what _torch/configs/__init__.py
already assumes for the rest of the codebase; this was the only remaining
direct call to the base class in tensorrt_llm/.

Verified standalone on transformers 5.5.3:

  • PretrainedConfig.from_pretrained → bare PreTrainedConfig (the bypass)
  • AutoConfig.from_pretrained → registered subclass with all attributes
    (the fix)

Test plan

  • Extended tests/unittest/_torch/test_custom_config_registration.py
    with test_load_hf_model_config_uses_autoconfig_dispatch that
    asserts ModelLoader.load_hf_model_config returns a
    DeepseekV3Config instance (not bare PretrainedConfig) for
    deepseek_v32 and kimi_k2 model_types.
  • Standalone mechanism reproducer run on transformers 5.5.3 inside
    the post-merge container (srun job 2265026): both PretrainedConfig
    bypass and AutoConfig dispatch behavior confirmed.

PR NVIDIA#14293 registered `deepseek_v32` and `kimi_k2` in
`transformers.models.auto.configuration_auto.CONFIG_MAPPING` so that
`AutoConfig.from_pretrained` / `AutoTokenizer.from_pretrained` dispatch
to TRT-LLM-local `DeepseekV3Config` for those model_types on
transformers 5.5.x, fixing the `benchmark_serving` client crash on
DeepSeek-V3.2.

`ModelLoader.load_hf_model_config` in `tensorrt_llm/llmapi/llm_utils.py`
was still calling `transformers.PretrainedConfig.from_pretrained`
directly. That bypasses `CONFIG_MAPPING` entirely (the base class
`from_pretrained` does not consult the mapping), so on transformers
5.5.x it falls through to a bare `PretrainedConfig` that lacks
`max_position_embeddings`. The warning shows up at trtllm-serve startup
on V3.2:

  [W] [llmapi] Failed to load hf model config from
      .../DeepSeek-V3.2-Exp-FP4-v2, encountered error:
      'PreTrainedConfig' object has no attribute 'max_position_embeddings'

The L0_PostMerge `disagg_upload-gen_only-gb200_deepseek-v32-fp4_...`
perf-sanity test on GB200 (36 GPUs / 9 nodes) PASSED at builds
2719/2721 (transformers 5.3.x), FAILED at 2722/2723 with the original
`benchmark_serving` client `max_position_embeddings` AttributeError
right after PR NVIDIA#13994 (5.5.3 upgrade) landed, and at 2726 (with NVIDIA#14293
in main) now fails differently with a 5400s
`Endpoint /health did not become ready` GEN-side timeout while the
warning above is still emitted at GEN_0.0.log:35.

Fix: route through `transformers.AutoConfig.from_pretrained` so the
NVIDIA#14293 `CONFIG_MAPPING.register` mapping applies. Other call sites of
`PretrainedConfig.from_pretrained` in `tensorrt_llm/` were grepped and
the only non-comment hit is this one.

Verified via standalone reproducer on transformers 5.5.3:
- `PretrainedConfig.from_pretrained` returns bare `PreTrainedConfig`
  (the bypass)
- `AutoConfig.from_pretrained` returns the registered subclass

Pre-merge regression coverage extended in
`tests/unittest/_torch/test_custom_config_registration.py`:
`test_load_hf_model_config_uses_autoconfig_dispatch` asserts that
`ModelLoader.load_hf_model_config` returns a `DeepseekV3Config`
instance for both `deepseek_v32` and `kimi_k2` model_types.

Signed-off-by: tianruih <tianruih@nvidia.com>
@Hudayday
Hudayday requested a review from a team as a code owner May 21, 2026 12:19
@Hudayday
Hudayday requested a review from hchings May 21, 2026 12:19
@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e6f83335-ddf9-46e3-8bd4-5aaa0a6689ca

📥 Commits

Reviewing files that changed from the base of the PR and between ac0be47 and cf302d3.

📒 Files selected for processing (2)
  • tensorrt_llm/llmapi/llm_utils.py
  • tests/unittest/_torch/test_custom_config_registration.py

📝 Walkthrough

Walkthrough

The PR updates HuggingFace model config loading to use AutoConfig.from_pretrained() instead of PretrainedConfig.from_pretrained(), enabling model-type-specific config dispatch through CONFIG_MAPPING. A regression test validates this behavior for deepseek_v32 and kimi_k2 models.

Changes

AutoConfig dispatch for HuggingFace model configuration

Layer / File(s) Summary
Use AutoConfig dispatch and validate registration behavior
tensorrt_llm/llmapi/llm_utils.py, tests/unittest/_torch/test_custom_config_registration.py
load_hf_model_config now routes through AutoConfig.from_pretrained() to enable CONFIG_MAPPING dispatch for model-type-specific config classes; regression test verifies the behavior works correctly for deepseek_v32 and kimi_k2 models, including preservation of max_position_embeddings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#14293: Main PR switches load_hf_model_config to use HuggingFace AutoConfig dispatch and adds regression test for deepseek_v32/kimi_k2, directly depending on this PR's CONFIG_MAPPING registration for those same model types.

Suggested reviewers

  • liji-nv
  • symphonylyh
  • VALLIS-NERIA
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title '[https://nvbugs/6185234][fix] route load_hf_model_config via AutoConfig' accurately describes the main change: routing the load_hf_model_config function through AutoConfig instead of PretrainedConfig.
Description check ✅ Passed The PR description provides clear explanation of the issue, mechanism, symptom, test plan, and CI history. However, it does not include a dedicated 'Description' section header or formal 'Test Coverage' section as specified in the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@Hudayday

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --extra-stage "DGX_B200-8_GPUs-PyTorch-1, DGX_B200-8_GPUs-PyTorch-2, DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1, DGX_B200-8_GPUs-PyTorch-PerfSanity-Post-Merge-4, GB200-36_GPUs-9_Nodes-PyTorch-Disagg-PerfSanity-CTX1-NODE1-GPU4-GEN1-NODE8-GPU32-Post-Merge-9"

@Hudayday
Hudayday enabled auto-merge (squash) May 21, 2026 12:26
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49696 [ run ] triggered by Bot. Commit: cf302d3 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49696 [ run ] completed with state SUCCESS. Commit: cf302d3
/LLM/main/L0_MergeRequest_PR pipeline #39302 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@Hudayday

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast --extra-stage "DGX_B200-8_GPUs-PyTorch-1, DGX_B200-8_GPUs-PyTorch-2, DGX_B200-8_GPUs-AutoDeploy-Post-Merge-1, DGX_B200-8_GPUs-PyTorch-PerfSanity-Post-Merge-4, GB200-36_GPUs-9_Nodes-PyTorch-Disagg-PerfSanity-CTX1-NODE1-GPU4-GEN1-NODE8-GPU32-Post-Merge-9"

@Hudayday
Hudayday requested a review from VALLIS-NERIA May 22, 2026 02:14
@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49816 [ run ] triggered by Bot. Commit: cf302d3 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49816 [ run ] completed with state SUCCESS. Commit: cf302d3
/LLM/main/L0_MergeRequest_PR pipeline #39401 completed with status: 'SUCCESS'

CI Report

Link to invocation

@Hudayday
Hudayday merged commit 5de99b6 into NVIDIA:main May 22, 2026
13 of 15 checks passed

@Superjomn Superjomn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on the llmapi changes.

KleinBlueC pushed a commit to KleinBlueC/TensorRT-LLM that referenced this pull request May 26, 2026
bmarimuthu-nv pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request May 28, 2026
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.

4 participants