Skip to content

Commit 6696b2e

Browse files
Merge commit '624aa14c0bafe494074a9ba74a0c5ba0861f652c' into chore/bump-mcore-dev-260812
2 parents 4fff7d3 + 624aa14 commit 6696b2e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎tests/unit_tests/recipes/test_gpt_oss_recipes.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
from collections.abc import Callable
2929

3030
import pytest
31+
from transformers import GptOssConfig
32+
33+
from megatron.bridge import AutoBridge
3134

3235

3336
_gpt_oss_module = importlib.import_module("megatron.bridge.recipes.gpt_oss")
@@ -42,6 +45,25 @@
4245
_ALL_FP8_RECIPE_CASES = _MXFP8_RECIPE_CASES + _HOPPER_FP8_RECIPE_CASES
4346
_BASE_RECIPE_CASES = [(name, f) for name, f in _ALL_RECIPE_CASES if "fp8" not in name]
4447

48+
_GPT_OSS_CONFIGS = {
49+
"openai/gpt-oss-20b": GptOssConfig(
50+
architectures=["GptOssForCausalLM"], num_hidden_layers=24, num_local_experts=32
51+
),
52+
"openai/gpt-oss-120b": GptOssConfig(
53+
architectures=["GptOssForCausalLM"], num_hidden_layers=36, num_local_experts=128
54+
),
55+
}
56+
57+
58+
@pytest.fixture(autouse=True)
59+
def mock_gpt_oss_configs(monkeypatch: pytest.MonkeyPatch):
60+
"""Build GPT-OSS recipes without depending on Hugging Face Hub."""
61+
62+
def from_hf_pretrained(path: str):
63+
return AutoBridge.from_hf_config(_GPT_OSS_CONFIGS[path])
64+
65+
monkeypatch.setattr(AutoBridge, "from_hf_pretrained", from_hf_pretrained)
66+
4567

4668
def _recipe_ids(recipe_cases):
4769
return [name for name, _ in recipe_cases]

0 commit comments

Comments
 (0)