Skip to content

Attach hf_config metadata to AutoBridge#1890

Merged
yaoyu-33 merged 3 commits intomainfrom
feature/autobridge-hf-config
Feb 4, 2026
Merged

Attach hf_config metadata to AutoBridge#1890
yaoyu-33 merged 3 commits intomainfrom
feature/autobridge-hf-config

Conversation

@yaoyu-33
Copy link
Contributor

@yaoyu-33 yaoyu-33 commented Jan 9, 2026

Summary

  • ensure AutoBridge passes hf_config into bridge dispatch
  • allow model bridges to persist hf_config when instantiated via dispatcher

Testing

  • not run (not requested)

Summary by CodeRabbit

  • Bug Fixes
    • Improved model bridge configuration handling to better preserve and apply configuration settings during model conversion.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jan 9, 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.

@yaoyu-33
Copy link
Contributor Author

yaoyu-33 commented Feb 2, 2026

/ok to test 49ff815

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

The changes extend the bridge factory to accept and propagate an optional hf_config parameter. The auto_bridge module now resolves hf_config from the pretrained model and passes it through to the bridge factory, enabling more complete configuration initialization during bridge instantiation.

Changes

Cohort / File(s) Summary
Auto Bridge Configuration Resolution
src/megatron/bridge/models/conversion/auto_bridge.py, src/megatron/bridge/models/conversion/model_bridge.py
Extended bridge factory to accept optional hf_config parameter. Auto_bridge now resolves hf_config from self.hf_pretrained (prioritizing hf_config attribute, then config attribute for PreTrainedCausalLM, then the object itself) and passes it through get_model_bridge, which assigns it to the bridge instance before returning.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Attach hf_config metadata to AutoBridge' clearly and concisely describes the main change: adding hf_config metadata handling to the AutoBridge mechanism.
Test Results For Major Changes ✅ Passed Minor internal changes (~12 net lines) for metadata passing through bridge dispatch mechanism with full backward compatibility and no algorithmic impact.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/autobridge-hf-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@yaoyu-33
Copy link
Contributor Author

yaoyu-33 commented Feb 4, 2026

/ok to test f42142a

@yaoyu-33 yaoyu-33 merged commit 8544020 into main Feb 4, 2026
50 checks passed
@yaoyu-33 yaoyu-33 deleted the feature/autobridge-hf-config branch February 4, 2026 20:57
sowmen pushed a commit to sowmen/Megatron-Bridge that referenced this pull request Feb 11, 2026
Signed-off-by: sowmen <sowmendipta@gmail.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