Skip to content

fix: register kimi_k25 and kimi_vl configs eagerly in lazy registry#1579

Merged
akoumpa merged 3 commits intomainfrom
huiyingl/fix-kimi-trust-remote-code
Mar 20, 2026
Merged

fix: register kimi_k25 and kimi_vl configs eagerly in lazy registry#1579
akoumpa merged 3 commits intomainfrom
huiyingl/fix-kimi-trust-remote-code

Conversation

@HuiyingLi
Copy link
Copy Markdown
Contributor

Summary

  • Add kimi_k25 and kimi_vl to _CUSTOM_CONFIG_REGISTRATIONS so their config classes are registered in CONFIG_MAPPING at import time, avoiding trust_remote_code=True errors when loading local checkpoints with auto_map in config.json.
  • Add KimiK25ForConditionalGeneration as an architecture alias in MODEL_ARCH_MAPPING (the checkpoint uses this name, while the NeMo implementation is KimiK25VLForConditionalGeneration).
  • The new lazy registry (_LazyArchMapping) does not import model modules at startup, so _register_*_with_transformers() never fires before AutoConfig.from_pretrained is called. The old eager registry (pkgutil.walk_packages) imported all model modules on startup which masked this issue.

Test plan

  • Added test_custom_config_registrations_in_config_mapping — verifies all entries in _CUSTOM_CONFIG_REGISTRATIONS are registered in CONFIG_MAPPING
  • Added test_kimi_k25_arch_alias_in_model_arch_mapping — verifies KimiK25ForConditionalGeneration maps to KimiK25VLForConditionalGeneration
  • All 18 registry unit tests pass (pytest tests/unit_tests/_transformers/test_registry.py)
  • E2E: torchrun --nproc_per_node=8 with kimi25vl_cordv2_2layer.yaml (kimi_k25) trains successfully
  • E2E: torchrun --nproc_per_node=8 with kimi2vl_cordv2.yaml (kimi_vl) trains successfully

🤖 Generated with Claude Code

…ote_code errors

The new lazy registry (MODEL_ARCH_MAPPING + _LazyArchMapping) does not
import model modules at startup, so _register_*_with_transformers()
never fires before AutoConfig.from_pretrained is called. This causes
local checkpoints with auto_map in config.json to require
trust_remote_code=True even though we have custom implementations.

Changes:
- Add kimi_k25 and kimi_vl to _CUSTOM_CONFIG_REGISTRATIONS so their
  config classes are registered in CONFIG_MAPPING at import time.
- Add KimiK25ForConditionalGeneration as an architecture alias in
  MODEL_ARCH_MAPPING (the checkpoint uses this name, while the NeMo
  implementation is KimiK25VLForConditionalGeneration).

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Mar 19, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@HuiyingLi
Copy link
Copy Markdown
Contributor Author

/ok to test bf3d2cc

@HuiyingLi
Copy link
Copy Markdown
Contributor Author

/claude review

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

LGTM

@HuiyingLi
Copy link
Copy Markdown
Contributor Author

/ok to test d033405

@HuiyingLi
Copy link
Copy Markdown
Contributor Author

/ok to test cb02151

@akoumpa akoumpa merged commit 222f487 into main Mar 20, 2026
52 checks passed
@akoumpa akoumpa deleted the huiyingl/fix-kimi-trust-remote-code branch March 20, 2026 01:56
torsli pushed a commit that referenced this pull request Mar 24, 2026
…1579)

fix: register kimi_k25 and kimi_vl configs eagerly to avoid trust_remote_code errors

The new lazy registry (MODEL_ARCH_MAPPING + _LazyArchMapping) does not
import model modules at startup, so _register_*_with_transformers()
never fires before AutoConfig.from_pretrained is called. This causes
local checkpoints with auto_map in config.json to require
trust_remote_code=True even though we have custom implementations.

Changes:
- Add kimi_k25 and kimi_vl to _CUSTOM_CONFIG_REGISTRATIONS so their
  config classes are registered in CONFIG_MAPPING at import time.
- Add KimiK25ForConditionalGeneration as an architecture alias in
  MODEL_ARCH_MAPPING (the checkpoint uses this name, while the NeMo
  implementation is KimiK25VLForConditionalGeneration).

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
linnanwang pushed a commit that referenced this pull request Apr 24, 2026
…1579)

fix: register kimi_k25 and kimi_vl configs eagerly to avoid trust_remote_code errors

The new lazy registry (MODEL_ARCH_MAPPING + _LazyArchMapping) does not
import model modules at startup, so _register_*_with_transformers()
never fires before AutoConfig.from_pretrained is called. This causes
local checkpoints with auto_map in config.json to require
trust_remote_code=True even though we have custom implementations.

Changes:
- Add kimi_k25 and kimi_vl to _CUSTOM_CONFIG_REGISTRATIONS so their
  config classes are registered in CONFIG_MAPPING at import time.
- Add KimiK25ForConditionalGeneration as an architecture alias in
  MODEL_ARCH_MAPPING (the checkpoint uses this name, while the NeMo
  implementation is KimiK25VLForConditionalGeneration).

Signed-off-by: HuiyingLi <willwin.lee@gmail.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants