mcore-testing
Test system for Megatron-LM. Covers test layout, recipe YAML structure, adding and running unit and functional tests, golden values, marker filters, and CI parity.
Security Assessment
About mcore-testing
The mcore-testing skill documents the test system for the Megatron-LM repository, covering test layout, recipe YAML structure, how to add and run unit and functional tests, golden values, marker filters, and CI parity. It solves the onboarding and day-to-day friction of a complex, GPU-and-container-based test harness where the right way to run, disable, or reproduce a test is non-obvious.
The guide leads with answer-first facts, such as how to disable a test without deleting it: functional recipe entries stay in YAML and are disabled by suffixing their scope with -broken, while unit-test skips use pytest markers (flaky_in_dev skips in dev, flaky skips in LTS). It maps the tests/ directory (unit_tests, functional_tests with test_cases, and test_utils with recipes and python_scripts), explains how tests execute via launch_nemo_run_workload.py using nemo-run to launch a DockerExecutor container with the repo bind-mounted, and documents rank logging, artifact upload, and up-to-3 automatic retries for known transient failures like NCCL timeouts and ECC errors. It details the recipe YAML structure with its cartesian products expansion and runtime placeholders, and shows how to run unit tests locally through torch.distributed.run since every test initializes a distributed group and requires GPU access.
Target users are developers and engineers contributing to Megatron-LM who need to add, run, or debug unit and functional tests and match CI behavior locally. It is a read-and-reference guide rather than an executable tool, keeping the source repo's conventions authoritative.
FAQ
How do I disable a test without deleting it?
For functional tests, suffix the recipe's scope value with -broken (for example mr-github becomes mr-github-broken) and keep the entry. For unit tests, use pytest markers: flaky_in_dev skips in the default dev environment and flaky skips in LTS.
How do I run unit tests locally?
Every unit test initializes a torch.distributed group, so each invocation requires GPU access and goes through torch.distributed.run, for example uv run python -m torch.distributed.run --nproc-per-node 8 -m pytest -q on the full suite, a single file, a single test, or a name-filtered subset.
How do tests execute in CI?
A GitHub Actions runner invokes launch_nemo_run_workload.py, which uses nemo-run to launch a DockerExecutor container with the repo bind-mounted at /opt/megatron-lm and training data at /mnt/artifacts. Unit tests dispatch through torch.distributed.run and per-rank logs are uploaded as artifacts.
What is a recipe YAML?
Recipes live under tests/test_utils/recipes/ and are parsed by recipe_parser.py. Each file expands a cartesian products block into individual workload specs with fields like model, build, nodes, gpus, platforms, and time_limit, plus runtime placeholders such as {assets_dir} and {test_case}.
Does the harness retry flaky failures?
Yes. launch_nemo_run_workload.py retries up to 3 times for known transient patterns such as NCCL timeout, ECC error, segfault, and HuggingFace connectivity issues before declaring a genuine failure.
Install mcore-testing
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
nvidia/skills