From add1e7e40c714f0eea9ee6c93fed044c08c57593 Mon Sep 17 00:00:00 2001 From: Y-T-G <32206511+Y-T-G@users.noreply.github.com> Date: Wed, 26 Aug 2026 00:33:14 -0500 Subject: [PATCH 1/2] fix: make huggingface_hub plugin import optional modelopt/torch/opt/plugins/__init__.py imported .huggingface unconditionally, and since 0.44 that module imports huggingface_hub at module scope. As huggingface_hub is only declared under the optional 'hf' extra, importing anything under modelopt.torch raised ModuleNotFoundError on a clean install. Guard it with import_plugin, matching the transformers, diffusers, peft and megatron plugins in the same file. Signed-off-by: Y-T-G <32206511+Y-T-G@users.noreply.github.com> --- CHANGELOG.rst | 1 + modelopt/torch/opt/plugins/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6687ebd31ea..029dfc26dc7 100755 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -43,6 +43,7 @@ Changelog - Update HuggingFace checkpoint export to use name-based tied-weight deduplication instead of the previous address-based approach. The address-based deduplication could incorrectly drop an untied weight that happened to share memory with a tied one, producing an incomplete checkpoint (observed as a false positive on MiniMax-M2.7). - Fix EAGLE-3 training with context parallelism (``--cp_size > 1`` in ``examples/speculative_decoding``), which failed to start on ``accelerate >= 1.13`` and then raised ``got mixed torch.Tensor and DTensor``. - Polygraphy minimum dependency upgraded to ``0.53.4`` to solve ONNX AutoCast failures when marking optional graph outputs. +- Fix ``ModuleNotFoundError: No module named 'huggingface_hub'`` on any ``modelopt.torch`` import when the optional ``hf`` extra is not installed. ``modelopt.torch.opt.plugins`` imported the HuggingFace checkpointing plugin unconditionally; it is now guarded by ``import_plugin`` like the other third-party plugins. Affects 0.44 through 0.46. 0.46 (2026-08-17) ^^^^^^^^^^^^^^^^^ diff --git a/modelopt/torch/opt/plugins/__init__.py b/modelopt/torch/opt/plugins/__init__.py index b86ef1eb7f3..bd74fd76a97 100644 --- a/modelopt/torch/opt/plugins/__init__.py +++ b/modelopt/torch/opt/plugins/__init__.py @@ -17,7 +17,8 @@ from modelopt.torch.utils import import_plugin -from .huggingface import * +with import_plugin("huggingface_hub"): + from .huggingface import * with import_plugin("megatron core dist checkpointing"): from .mcore_dist_checkpointing import * From 32c0d7ff94e3d164dacbe8d27fce713f60ae9405 Mon Sep 17 00:00:00 2001 From: Y-T-G <32206511+Y-T-G@users.noreply.github.com> Date: Wed, 26 Aug 2026 00:56:06 -0500 Subject: [PATCH 2/2] docs: drop implementation detail from changelog entry Signed-off-by: Y-T-G <32206511+Y-T-G@users.noreply.github.com> --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 029dfc26dc7..742c0d71525 100755 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -43,7 +43,7 @@ Changelog - Update HuggingFace checkpoint export to use name-based tied-weight deduplication instead of the previous address-based approach. The address-based deduplication could incorrectly drop an untied weight that happened to share memory with a tied one, producing an incomplete checkpoint (observed as a false positive on MiniMax-M2.7). - Fix EAGLE-3 training with context parallelism (``--cp_size > 1`` in ``examples/speculative_decoding``), which failed to start on ``accelerate >= 1.13`` and then raised ``got mixed torch.Tensor and DTensor``. - Polygraphy minimum dependency upgraded to ``0.53.4`` to solve ONNX AutoCast failures when marking optional graph outputs. -- Fix ``ModuleNotFoundError: No module named 'huggingface_hub'`` on any ``modelopt.torch`` import when the optional ``hf`` extra is not installed. ``modelopt.torch.opt.plugins`` imported the HuggingFace checkpointing plugin unconditionally; it is now guarded by ``import_plugin`` like the other third-party plugins. Affects 0.44 through 0.46. +- Fix ``ModuleNotFoundError: No module named 'huggingface_hub'`` when importing ``modelopt.torch`` without the optional ``hf`` extra. Install the ``hf`` extra to use Hugging Face checkpointing. Affects 0.44 through 0.46. 0.46 (2026-08-17) ^^^^^^^^^^^^^^^^^