Skip to content

fix: make Nemotron-H import error adaption on Megatron-Core 0.16.1 - #171

Merged
hjh0119 merged 2 commits into
modelscope:mainfrom
hazelduan:gdn_model_hybrid
Aug 22, 2026
Merged

fix: make Nemotron-H import error adaption on Megatron-Core 0.16.1#171
hjh0119 merged 2 commits into
modelscope:mainfrom
hazelduan:gdn_model_hybrid

Conversation

@hazelduan

Copy link
Copy Markdown
Contributor

Make Nemotron-H registration conditional when the installed Megatron-Core does not provide megatron.core.models.hybrid. On Ascend A3 with Megatron-Core 0.16.1 and USE_MCORE_GDN=0, the training initialization import passed and Nemotron-H was correctly skipped.

@hjh0119

hjh0119 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix!

Instead of guarding the import at the init.py level, would it be cleaner to wrap the relevant imports inside nemotron_h.py itself with a try/except ImportError?

This way the file is self-contained — it won't break on import regardless of where it's imported from, and we don't need to maintain a whitelist in init.py every time a new model has optional dependencies.

@hazelduan

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestion — addressed in 04e21c5. The HybridModel availability check now lives in nemotron_h.py, while gpts/__init__.py keeps its regular import list. I kept the exception guard narrow so only failures originating from megatron.core.models.hybrid skip registration; unrelated import errors are still raised. Verified on A3 with Megatron-Core 0.16.1: package/direct module imports pass, Nemotron-H remains unregistered when HybridModel is absent, and lint passes.

@hjh0119
hjh0119 merged commit 18e992e into modelscope:main Aug 22, 2026
1 check passed
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