Skip to content

[https://nvbugs/6185248][fix] In model_loader.py, resolve llm_backbone = getattr(model, "llm", model) and - #14389

Closed
tensorrt-cicd wants to merge 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6185248
Closed

[https://nvbugs/6185248][fix] In model_loader.py, resolve llm_backbone = getattr(model, "llm", model) and #14389
tensorrt-cicd wants to merge 1 commit into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6185248

Conversation

@tensorrt-cicd

@tensorrt-cicd tensorrt-cicd commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: KimiK25ForConditionalGeneration is a VLM wrapper holding the LLM as self.llm, so MTP's draft_config/draft_model/load_draft_weights live on model.llm, not model; the loader dereferenced them on model directly.
  • Fix: In model_loader.py, resolve llm_backbone = getattr(model, "llm", model) and use it for draft_config/draft_model/load_draft_weights (both HF and DUMMY paths). In modeling_kimi_k25.py, forward extra kwargs (filtered to drop multimodal-only keys) into self.llm.forward(...).
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Summary by CodeRabbit

  • Bug Fixes
    • Corrected parameter handling in Kimi K25 model forward pass to improve multimodal inference reliability
    • Enhanced draft weight loader compatibility with Vision-Language Model wrapper models featuring nested backbone components

Review Change Stack

…d kwargs in Kimi-K2.5

Kimi-K2.5 is a VLM wrapper that holds the LLM as ``self.llm =
DeepseekV3ForCausalLM(...)``, so the speculative-decoding attributes
(``draft_config``, ``draft_model``, ``load_draft_weights``) live on
``model.llm`` rather than on ``model``. Two issues:

1. ``ModelLoader._load_weights`` dereferenced ``model.draft_config`` /
   ``model.draft_model`` / ``model.load_draft_weights`` directly, which
   raised ``AttributeError: 'KimiK25ForConditionalGeneration' object has
   no attribute 'draft_config'`` on MTP runs. Resolve the LLM backbone
   via ``getattr(model, "llm", model)`` for both ``HF`` and ``DUMMY``
   load formats.

2. ``KimiK25ForConditionalGeneration.forward`` dropped extra kwargs
   (``spec_metadata``, ``resource_manager``) when calling
   ``self.llm.forward(...)`` positionally. Forward through the relevant
   kwargs so MTP receives ``spec_metadata`` and warmup no longer fails
   with ``'NoneType' object has no attribute 'gather_ids'``.

Signed-off-by: tensorrt-cicd <90828364+tensorrt-cicd@users.noreply.github.com>
@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: cd3a12f2-e2dd-40a2-8680-d35d1e537633

📥 Commits

Reviewing files that changed from the base of the PR and between e64c92b and 0aaadc9.

📒 Files selected for processing (2)
  • tensorrt_llm/_torch/models/modeling_kimi_k25.py
  • tensorrt_llm/_torch/pyexecutor/model_loader.py

📝 Walkthrough

Walkthrough

This PR introduces VLM wrapper model support by filtering multimodal-specific parameters during KimiK25 forward execution and adjusting draft-weight loading to route operations through the LLM backbone instead of the wrapper model.

Changes

VLM Wrapper Model Support

Layer / File(s) Summary
KimiK25 multimodal parameter filtering
tensorrt_llm/_torch/models/modeling_kimi_k25.py
multimodal_params is extracted from kwargs via pop to prevent forwarding. Forward kwargs are filtered to exclude mm_token_indices and text_token_indices before passing to self.llm.forward.
Draft weight loading for VLM LLM backbone
tensorrt_llm/_torch/pyexecutor/model_loader.py
Draft-weight loading extracts the LLM backbone via getattr(model, "llm", model) and routes draft checkpoint initialization and loading through the backbone in both LoadFormat.AUTO and LoadFormat.DUMMY paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • syuoni
  • lowsfer
  • Wanli-Jiang
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title references a specific NVBugs ticket and fix type, but is incomplete (ends with 'and') and doesn't fully convey the complete change involving both model_loader.py and modeling_kimi_k25.py updates. Complete the title to clearly summarize both changes: resolve llm_backbone path for draft weights and forward kwargs to llm.forward in KimiK25.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description adequately covers the root cause, fixes applied to both files, test verification, and links to the bug, meeting the template requirements despite using an automated summary format.
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.

@tianyuxbear

Copy link
Copy Markdown
Collaborator

Closing in favor of #14379 which has been verified via /bot run (PR_Github #49557 and PR_Github #49659 both SUCCESS, including the original failing stage GB200-4_GPUs-PyTorch-PerfSanity-Post-Merge-1).

Both PRs fix the same root cause. #14379 keeps the fix on the model side; #14389 changes model_loader.py. K2.5 follows the same composition-with-self.llm pattern as Qwen2VL/Qwen3VL/Gemma3VL/ LlavaNext/VILA, but is the first VLM in the codebase to need spec_dec, so it's also the first to need the draft_config/draft_model forwarders that #14379 adds. Containing this within the model class keeps framework code unchanged.

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.

3 participants