|
17 | 17 | import importlib |
18 | 18 |
|
19 | 19 | import pytest |
| 20 | +from megatron.training.determinism import DETERMINISM_ENV_VAR_DEFAULTS |
20 | 21 |
|
21 | 22 | from megatron.bridge.perf_recipes.environment import HYBRID_EP_ENV_NAMES |
22 | 23 | from tests.unit_tests.recipes.recipe_test_utils import patch_recipe_construction_dependencies |
|
25 | 26 | pytestmark = pytest.mark.unit |
26 | 27 |
|
27 | 28 | _NCCL_EP_ENV = {"NCCL_EP_HT_EM_PULL_PUSH": 1} |
| 29 | +_SSM_DETERMINISM_ENV = {"MAMBA_DETERMINISTIC": "1", "CAUSAL_CONV1D_DETERMINISTIC": "1"} |
28 | 30 |
|
29 | 31 | # (module under megatron.bridge.perf_recipes, recipe factory) for the GB300 recipes defaulted to NCCL EP. |
30 | 32 | _GB300_NCCLEP_RECIPES = ( |
@@ -131,3 +133,22 @@ def test_vr200_aliases_do_not_inherit_nccl_ep(module_name: str, factory_name: st |
131 | 133 | assert cfg.env_vars.keys() >= HYBRID_EP_ENV_NAMES |
132 | 134 | else: |
133 | 135 | assert cfg.model.moe_token_dispatcher_type == "alltoall" |
| 136 | + |
| 137 | + |
| 138 | +def test_deepseek_v3_gb300_fp8mx_deterministic_is_base_plus_determinism_overrides() -> None: |
| 139 | + module = "deepseek.gb300.deepseek_v3" |
| 140 | + base = _build(module, "deepseek_v3_pretrain_256gpu_gb300_fp8mx_config") |
| 141 | + cfg = _build(module, "deepseek_v3_pretrain_256gpu_gb300_fp8mx_deterministic_config") |
| 142 | + |
| 143 | + assert cfg.model.deterministic_mode is True |
| 144 | + assert cfg.model.cross_entropy_loss_fusion is False |
| 145 | + assert cfg.model.moe_router_aux_loss_fusion is False |
| 146 | + assert cfg.model.moe_router_fusion == base.model.moe_router_fusion |
| 147 | + # HybridEP with the legacy grouped MLP until the NCCL EP path is deterministic. |
| 148 | + assert cfg.model.moe_flex_dispatcher_backend == "hybridep" |
| 149 | + assert cfg.model.moe_use_grouped_tensor is False |
| 150 | + assert cfg.env_vars.keys() >= HYBRID_EP_ENV_NAMES |
| 151 | + assert cfg.env_vars.keys().isdisjoint(_NCCL_EP_ENV) |
| 152 | + expected_env = {name: value for name, value in base.env_vars.items() if name not in _NCCL_EP_ENV} |
| 153 | + expected_env.update({name: cfg.env_vars[name] for name in HYBRID_EP_ENV_NAMES}) |
| 154 | + assert cfg.env_vars == {**expected_env, **DETERMINISM_ENV_VAR_DEFAULTS, **_SSM_DETERMINISM_ENV} |
0 commit comments