Skip to content

Commit 4d522da

Browse files
Merge branch 'main' into chenjiel/add_qwen_moe_test
2 parents 65a8889 + 4e33368 commit 4d522da

7 files changed

Lines changed: 35 additions & 8 deletions

File tree

.github/codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ coverage:
99
project:
1010
default:
1111
target: auto
12-
threshold: 2% # Allow atmost 2% coverage drop from main branch.
12+
threshold: 1% # Allow atmost 1% coverage drop from main branch.
1313
patch: false

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Changelog
3232
- [Experimental] Add support for transformers>=5.0, including generic PTQ and unified HF checkpoint export for fused MoE expert modules (Mixtral, Qwen2-MoE, Qwen3-MoE, Qwen3.5-MoE, DeepSeek-V3, Jamba, OLMoE, etc.).
3333
- Improve ``megatron_preprocess_data``: add ``--reasoning_content`` support for Nemotron v3 datasets, eliminate intermediate JSONL for HuggingFace datasets, return output file prefixes from the Python API, add gzip input support (``.jsonl.gz``), add ``--strip_newlines`` flag for plain-text pretraining data, add ``--hf_streaming`` for very large datasets (only consumed rows downloaded), and auto-shuffle when ``--hf_max_samples_per_split`` is set to avoid biased sampling.
3434

35-
0.43 (2026-04-09)
35+
0.43 (2026-04-16)
3636
^^^^^^^^^^^^^^^^^
3737

3838
**Bug Fixes**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
datasets>=2.14.5
2-
torch==2.9.0
3-
transformers==4.57.3
2+
torch
3+
transformers<5.0.0

modelopt/torch/utils/serialization.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ def safe_save(obj: Any, f: str | os.PathLike | BinaryIO, **kwargs) -> None:
5454

5555

5656
def safe_load(f: str | os.PathLike | BinaryIO | bytes, **kwargs) -> Any:
57-
"""Load a checkpoint securely using weights_only=True by default."""
58-
kwargs.setdefault("weights_only", True)
57+
"""Load a checkpoint securely using ``weights_only=True`` by default.
5958
59+
NOTE: We dont set default ``weights_only`` (interpret as True for torch>=2.6) so you can override it with
60+
``export TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1`` if you see ``pickle.UnpicklingError`` and trust the checkpoint.
61+
"""
6062
if isinstance(f, (bytes, bytearray)):
6163
f = BytesIO(f)
6264

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dependencies = [
4343
# modelopt.torch
4444
"PyYAML>=6.0",
4545
"omegaconf>=2.3.0",
46-
"pulp",
46+
"pulp<4.0", # breaking changes in upcoming 4.0 release
4747
"pydantic>=2.0",
4848
"regex",
4949
"rich",

tests/unit/torch/utils/test_serialization.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"""Tests for Modelopt's serialization utilities."""
1717

1818
from io import BytesIO
19+
from pickle import UnpicklingError
1920

21+
import pytest
2022
import torch
2123

2224
from modelopt.torch.opt.config import ModeloptBaseConfig
@@ -70,3 +72,25 @@ def test_safe_load_with_path(tmp_path):
7072
loaded_state = safe_load(file_path)
7173

7274
assert loaded_state["data"] == 42
75+
76+
77+
class _UnsafeObj:
78+
"""Not registered in torch safe globals — unpickling fails with weights_only=True."""
79+
80+
def __init__(self, v):
81+
self.v = v
82+
83+
84+
def test_safe_load_env_var_bypasses_weights_only(tmp_path, monkeypatch):
85+
"""Verify TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1 allows safe_load to load objects unsafe for weights_only."""
86+
file_path = tmp_path / "unsafe.pt"
87+
torch.save({"obj": _UnsafeObj(42)}, file_path)
88+
89+
# Always fails when weights_only is not set (default=True)
90+
with pytest.raises(UnpicklingError):
91+
safe_load(file_path)
92+
93+
# With the env var, safe_load (no explicit weights_only) defers to torch's default=False
94+
monkeypatch.setenv("TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD", "1")
95+
loaded = safe_load(file_path)
96+
assert loaded["obj"].v == 42

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ commands =
8282
[testenv:cuda13-gpu-megatron]
8383
commands_pre =
8484
# Install deps here so that it gets installed even in --current-env
85-
pip install -U megatron-core
85+
# Temporarily disable latest mcore until we fix its nvidia-resiliency-ext dependency
86+
pip install 'megatron-core<0.17.0'
8687
pip install --no-build-isolation git+https://github.com/state-spaces/mamba.git
8788
pip install --no-build-isolation git+https://github.com/Dao-AILab/causal-conv1d.git
8889
pip install -e .[hf,dev-test]

0 commit comments

Comments
 (0)