# megatron-memory-estimator

megatron-memory-estimator is a Claude Code skill that estimates GPU memory for dense and MoE Megatron models from HuggingFace configs. Compare parallelism and check model fit.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 158 repo stars
- Author: yzlnew
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/yzlnew/infra-skills/tree/HEAD/megatron-memory-estimator/SKILL.md
- Updated: 2026-07-09
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/megatron-memory-estimator

## What it does

The skill estimates memory from a HuggingFace model path or a local `config.json`. Its main script, `scripts/estimate_from_hf.py`, converts the model configuration to Megatron format and calculates memory for the chosen training settings. Results can include a detailed model breakdown or be emitted as JSON.

Set TP, PP, EP and CP along with the GPU count, micro-batch size and sequence length to compare configurations. The estimator also accepts activation recomputation through `--recompute-granularity` and reports peak memory per GPU. Expert parallelism can be included for MoE models.

When the layer count cannot be divided evenly across PP stages, specify the layer count for the first or last stage. Otherwise, the chosen pipeline layout may not match the model’s layer distribution.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add yzlnew/infra-skills --skill megatron-memory-estimator -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/megatron-memory-estimator/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/megatron-memory-estimator/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add yzlnew/infra-skills --skill megatron-memory-estimator -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/megatron-memory-estimator/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add yzlnew/infra-skills --skill megatron-memory-estimator -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/megatron-memory-estimator/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install yzlnew/infra-skills megatron-memory-estimator
```

2. **Manually: put the files in place**
- File: `.github/skills/megatron-memory-estimator/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add yzlnew/infra-skills --skill megatron-memory-estimator -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/yzlnew/infra-skills --path megatron-memory-estimator
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/megatron-memory-estimator/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/yzlnew/infra-skills/tree/HEAD/megatron-memory-estimator/SKILL.md

## When to use it
- Estimate GPU memory from a HuggingFace configuration
- Check whether a model fits the available GPU memory
- Compare TP, PP, EP and CP layouts
- Test training settings with activation recomputation

## Example prompts
- Estimate memory for `deepseek-ai/DeepSeek-V3` on 128 GPUs with TP 4, PP 4 and EP 8.
- Calculate memory for a local `config.json` using TP 2 and PP 2.
- Compare parallelism setups for `Qwen/Qwen3-235B-A22B` and return JSON.

## Similar
- [nemo-mbridge-perf-megatron-fsdp](https://affpapa.org/en/nevibecode/skills/nemo-mbridge-perf-megatron-fsdp.md) — skill · 1800 installs
- [nemo-mbridge-perf-moe-comm-overlap](https://affpapa.org/en/nevibecode/skills/nemo-mbridge-perf-moe-comm-overlap.md) — skill · 1800 installs
- [memory-dispose-geometry](https://affpapa.org/en/nevibecode/rules/memory-dispose-geometry.md) — rule · ★ 4719 repo stars
- [distributed-training-megatron-core](https://affpapa.org/en/nevibecode/skills/distributed-training-megatron-core.md) — skill · 88 installs
- [miles-rl-training](https://affpapa.org/en/nevibecode/skills/miles-rl-training.md) — skill · 1100 installs
- [amazon-sales-estimator](https://affpapa.org/en/nevibecode/skills/amazon-sales-estimator.md) — skill · 1300 installs

From the same set: [yzlnew/infra-skills](https://affpapa.org/en/nevibecode/by/yzlnew/infra-skills.md) — 8 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
