build-and-dependency
Skill976 starsChanged 22 days agoApache-2.0View on GitHub
Dev environment setup for Megatron Bridge — container-based development, uv package management, lockfile regeneration, adding dependencies, Slurm container usage, and common build pitfalls.
- Installs packages
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 73
If you bind-mount a custom source tree into the container, only rank 0 should sync while others wait:
- Distinctive: line 114
Commit both modified files:
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Build and Dependency
Two core principles: build and develop inside containers, and always use uv.
Why Containers
Megatron Bridge depends on CUDA, NCCL, PyTorch with GPU support, Transformer Engine, and optional components like TRT-LLM, vLLM, and DeepEP. Installing these on a bare host is fragile and hard to reproduce. The project ships production-quality Dockerfiles that pin every dependency.
Use the container as your development environment. This guarantees:
- Identical CUDA / NCCL / cuDNN versions across developers and CI.
uv.lockresolves the same way locally and in CI (the lockfile is Linux-only; it cannot be regenerated on macOS).- GPU-dependent operations work out of the box.
Container Options
Option 1: NeMo Framework Container (fastest)
Find available tags at https://catalog.ngc.nvidia.com/orgs/nvidia/containers/nemo/tags
skopeo list-tags docker://nvcr.io/nvidia/nemo \
| python3 -c "import sys,json,re; tags=json.load(sys.stdin)['Tags']; [print(t) for t in sorted((t for t in tags if re.match(r'^\d{2}\.\d{2}', t)), reverse=True)]"docker run --rm -it --gpus all --shm-size=24g \
nvcr.io/nvidia/nemo:<tag> \
bashOption 2: Build the Megatron Bridge Container
See @docker/README.md for build commands, build arguments, and the full NeMo-FW image stack.
Running the Container
docker run --rm -it -w /opt/Megatron-Bridge \
-v $(pwd):/opt/Megatron-Bridge \
-v $HOME/.cache/uv:/root/.cache/uv \
--gpus all \
--shm-size=24g \
--ulimit memlock=-1 \
--ulimit stack=67108864 \
megatron-bridge:latest \
bashMounting $HOME/.cache/uv avoids re-downloading wheels on every run.
Containers on Slurm
On Slurm clusters with Enroot/Pyxis, pass containers directly to srun:
srun --mpi=pmix \
--container-image="$CONTAINER_IMAGE" \
--container-mounts="$CONTAINER_MOUNTS" \
--no-container-mount-home \
bash -c "cd /opt/Megatron-Bridge && uv run --no-sync python ..."If you bind-mount a custom source tree into the container, only rank 0 should sync while others wait:
if [ "$SLURM_LOCALID" -eq 0 ]; then uv sync; else sleep 10; fiNote: --no-container-mount-home is an srun flag, not an #SBATCH directive.
Set UV_CACHE_DIR to shared storage to avoid filling /root/.cache/.
Always Use uv
Never use pip install, conda, or bare python — always go through uv.
All uv commands must be run inside a container. Never install or upgrade
dependencies outside the CI container.
Essential Commands
| Task | Command |
| Install all deps from lockfile | uv sync --locked |
| Install with all extras and dev groups | uv sync --locked --all-extras --all-groups |
| Run a Python command | uv run python script.py |
| Run distributed training | uv run python -m torch.distributed.run --nproc_per_node=N script.py |
| Add a new dependency | uv add <package> |
| Add an optional dependency | uv add --optional --extra <group> <package> |
| Regenerate the lockfile | uv lock (Linux/container only) |
| Install pre-commit hooks | uv run --group dev pre-commit install |
Adding Dependencies
Submit dependency changes as a separate PR before the feature PR:
# Optional dependency (preferred)
uv add --optional --extra <group> <package>
# Required dependency (needs strong justification — affects all downstream)
uv add <package>Commit both modified files:
git add pyproject.toml uv.lock
git commit -s -m "build: add <package>"Regenerating uv.lock
The lockfile is Linux-only (resolves CUDA wheels). Run inside Docker:
docker run --gpus all --rm \
-v $(pwd):/opt/Megatron-Bridge \
megatron-bridge:latest \
bash -c 'cd /opt/Megatron-Bridge && uv lock'Switching MCore Branches
# Switch to dev branch
./scripts/switch_mcore.sh dev
uv sync # without --locked
# Switch back to main
./scripts/switch_mcore.sh main
uv sync --locked # lockfile matches againQuick Start
# 1. Clone and init submodules
git clone https://github.com/NVIDIA-NeMo/Megatron-Bridge megatron-bridge
cd megatron-bridge
git submodule update --init 3rdparty/Megatron-LM
# 2. Build the container
docker build -f docker/Dockerfile.ci --target megatron_bridge -t megatron-bridge:latest .
# 3. Start a dev shell
docker run --rm -it -v $(pwd):/opt/Megatron-Bridge --gpus all --shm-size=24g megatron-bridge:latest bash
# 4. Install pre-commit hooks (inside container)
uv run --group dev pre-commit install
# 5. Sanity check
uv run python -m torch.distributed.run --nproc_per_node=1 \
scripts/training/run_recipe.py \
--recipe vanilla_gpt_pretrain_config \
train.train_iters=5 train.global_batch_size=8 train.micro_batch_size=4 \
scheduler.lr_warmup_iters=1 scheduler.lr_decay_iters=5 \
logger.log_interval=1Common Pitfalls
| Problem | Cause | Fix |
uv sync --locked fails on macOS | Lockfile resolves CUDA wheels that don't exist on macOS | Run inside Docker or on a Linux machine |
ModuleNotFoundError after pip install | pip installed outside uv-managed venv | Use uv add + uv sync, never bare pip install |
uv sync --locked fails after MCore branch switch | Lockfile generated against main MCore | Use uv sync (without --locked) on dev |
uv: command not found inside container | Container doesn't have uv | Use the megatron-bridge image built from Dockerfile.ci |
No space left on device during uv ops | Cache fills container's /root/.cache/ | Set UV_CACHE_DIR to shared/persistent storage |
| Pre-commit fails with ruff errors | Code style violations | Run uv run ruff check --fix . && uv run ruff format . |
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- NVIDIA-NeMo/RL★ 2.1ksame name
- NVIDIA-NeMo/Automodel★ 1.1ksame name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adding-model-supportSkill
- bump-dependencySkill
- cicdSkill
- create-model-verification-cardSkill
- linting-and-formattingSkill
- nemo-mbridge-memory-snapshot-analysisSkill
- nemo-mbridge-mlm-bridge-trainingSkill
- nemo-mbridge-multi-node-slurmSkill
- nemo-mbridge-perf-activation-recomputeSkill
- nemo-mbridge-perf-cpu-offloadingSkill
- nemo-mbridge-perf-cuda-graphsSkill
- nemo-mbridge-perf-expert-parallel-overlapSkill
- nemo-mbridge-perf-hierarchical-context-parallelSkill
- nemo-mbridge-perf-megatron-fsdpSkill
- nemo-mbridge-perf-memory-tuningSkill
- nemo-mbridge-perf-moe-comm-overlapSkill
- nemo-mbridge-perf-moe-dispatcher-selectionSkill
- nemo-mbridge-perf-moe-hardware-configsSkill
- nemo-mbridge-perf-moe-long-contextSkill
- nemo-mbridge-perf-moe-optimization-workflowSkill
- nemo-mbridge-perf-moe-vlm-trainingSkill
- nemo-mbridge-perf-nsys-analysisSkill
- nemo-mbridge-perf-parallelism-strategiesSkill
- nemo-mbridge-perf-sequence-packingSkill
- nemo-mbridge-perf-tp-dp-comm-overlapSkill
- nemo-mbridge-perf-vision-dp-over-cpSkill
- nemo-mbridge-recipe-recommenderSkill
- nemo-mbridge-resiliencySkill
- nemo-rl-e2e-testingSkill
- parity-testingSkill
- pr-reviewSkill
- review-prSkill
- testingSkill
- verl-e2e-testingSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

