Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/megatron/bridge/recipes/ministral3/h100/ministral3.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def ministral3_3b_sft_1gpu_h100_bf16_config() -> ConfigContainer:
# Dataset configuration
cfg.dataset.seq_length = 4096
cfg.dataset.hf_processor_path = hf_path
cfg.dataset.enable_in_batch_packing = False

# DDP settings
cfg.ddp.overlap_grad_reduce = False
Expand Down Expand Up @@ -225,6 +226,7 @@ def ministral3_8b_sft_2gpu_h100_bf16_config() -> ConfigContainer:
# Dataset configuration
cfg.dataset.seq_length = 4096
cfg.dataset.hf_processor_path = hf_path
cfg.dataset.enable_in_batch_packing = False

# DDP settings
cfg.ddp.overlap_grad_reduce = False
Expand Down Expand Up @@ -340,6 +342,7 @@ def ministral3_14b_sft_4gpu_h100_bf16_config() -> ConfigContainer:
# Dataset configuration
cfg.dataset.seq_length = 4096
cfg.dataset.hf_processor_path = hf_path
cfg.dataset.enable_in_batch_packing = False

# DDP settings
cfg.ddp.overlap_grad_reduce = False
Expand Down Expand Up @@ -464,6 +467,7 @@ def ministral3_3b_peft_1gpu_h100_bf16_config(peft_scheme: str | PEFT = "lora") -
# Dataset configuration
cfg.dataset.seq_length = 4096
cfg.dataset.hf_processor_path = hf_path
cfg.dataset.enable_in_batch_packing = False

# DDP settings
cfg.ddp.overlap_grad_reduce = False
Expand Down Expand Up @@ -588,6 +592,7 @@ def ministral3_8b_peft_1gpu_h100_bf16_config(peft_scheme: str | PEFT = "lora") -
# Dataset configuration
cfg.dataset.seq_length = 4096
cfg.dataset.hf_processor_path = hf_path
cfg.dataset.enable_in_batch_packing = False

# DDP settings
cfg.ddp.overlap_grad_reduce = False
Expand Down Expand Up @@ -712,6 +717,7 @@ def ministral3_14b_peft_2gpu_h100_bf16_config(peft_scheme: str | PEFT = "lora")
# Dataset configuration
cfg.dataset.seq_length = 4096
cfg.dataset.hf_processor_path = hf_path
cfg.dataset.enable_in_batch_packing = False

# DDP settings
cfg.ddp.overlap_grad_reduce = False
Expand Down
12 changes: 12 additions & 0 deletions tests/unit_tests/recipes/test_ministral3_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
_ministral3_module.ministral3_14b_peft_config,
]

_MINISTRAL3_FUNCS = _MINISTRAL3_SFT_FUNCS + _MINISTRAL3_PEFT_FUNCS


class _FakeModelCfg:
"""Fake model configuration for testing."""
Expand Down Expand Up @@ -138,6 +140,16 @@ def test_each_ministral3_sft_recipe_uses_recommended_learning_rate(
assert cfg.optimizer.min_lr == pytest.approx(5e-7)


@pytest.mark.parametrize("recipe_func", _MINISTRAL3_FUNCS)
def test_each_ministral3_recipe_defaults_validate(recipe_func: Callable, monkeypatch: pytest.MonkeyPatch):
"""Test that every Ministral3 recipe has runnable default batch settings."""
patch_recipe_module_global(monkeypatch, _ministral3_module, "AutoBridge", _FakeAutoBridge)

cfg = recipe_func()

assert not cfg.dataset.enable_in_batch_packing or cfg.train.micro_batch_size > 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion is a tautology given the recipes as written: every recipe sets enable_in_batch_packing = False and micro_batch_size = 1, so the left disjunct (not False) is always True and the right operand is never evaluated. The test passes regardless of the recipe values and would not catch a future regression where someone enables packing while leaving micro_batch_size = 1.

Consider asserting the intended invariant more directly, e.g. explicitly checking the current expected defaults, or — if the goal is to guard packing+mbs consistency — parametrizing a case that actually sets enable_in_batch_packing = True so the micro_batch_size > 1 branch is exercised.



@pytest.mark.parametrize("recipe_func", _MINISTRAL3_PEFT_FUNCS)
def test_each_ministral3_peft_recipe_builds_config(recipe_func: Callable, monkeypatch: pytest.MonkeyPatch):
"""Test that each Ministral3 PEFT recipe function builds a valid configuration."""
Expand Down
Loading