amd-agi/primus/primus-projection
Claude Code and agent skill by amd-agi/primus
- community
Checking that the SKILL.md file is still in the repository.
Opinionated guide for using Primus Projection to choose parallelism (TP/PP/EP/CP/DP) and pipeline schedules, validate memory fit on target nodes, reason about communication collectives, and explore optimization trade-offs with minimal compute. Use when the user asks how to pick a parallelism strategy or pipeline schedule, whether a model fits in memory, which optimizations such as DeepEP, SyncFree, zero-bubble, FP8, recomputation, or FSDP2 matter most, or how to run primus projection commands. Read-only planning guidance; no large multi-node training runs required.
Install
npx vskill@latest install amd-agi/primus/primus-projectionSKILL.md
Primus Projection Skill
Purpose
Provide a quick, opinionated guide for using Primus Projection to:
- Choose parallelism and pipeline schedules
- Validate memory fit on target nodes
- Understand communication collectives/algorithms
- Explore optimization trade-offs with minimal compute
- Run the right commands fast
Scope
- Docs:
docs/02-user-guide/projection.md - Projection code:
primus/core/projection/ - Projection performance entrypoints:
primus/core/projection/performance_projection/ - Projection memory entrypoints:
primus/core/projection/memory_projection/ - Pipeline schedulers:
primus/core/pipeline_parallel/scheduler/ - Backend config adapters:
primus/core/projection/frameworks/ - Example configs:
examples/megatron/configs/,examples/torchtitan/configs/,examples/maxtext/configs/ - Hardware configs:
examples/hardware_configs/
Training Backends
Projection reads the framework field of the experiment's pre_trainer module and adapts that backend's own config into the shapes and parallel degrees it models. All language-model backends share one profiler tree, so every recommendation below applies whichever backend trains the model.
framework | Benchmark modes | Simulate mode | |
|---|---|---|---|
megatron, torchtitan, maxtext (alias jax), torchrec_dlrm | Yes | Yes |
TorchTitan benchmarks through the same torch harness as Megatron. MaxText measures itself: it times a compiled vjp and takes activation sizes from XLA's compile-time accounting, so its attention/MLP split is apportioned analytically and its output head and loss are analytical. Expert all-to-all is not timed on either and is restored analytically. Architecture comes from the installed backend when present (TorchTitan's flavor table, MaxText's model YAMLs) and otherwise from the transcribed table in primus/core/projection/frameworks/model_specs.py, so no GPU or training checkout is needed to size a cluster in simulate mode.
Note the vocabulary differences when reading a config: TorchTitan states parallelism as parallelism.*_parallel_degree (with -1 meaning "the leftover ranks") and MaxText as orthogonal ici_* / dcn_* mesh axes (with -1 meaning the same). MaxText's per_device_batch_size counts every device, not every data-parallel rank.
Projection Advisor (What users want to know)
1) Best parallelism strategy
- Evaluate TP/PP/EP/CP/DP for the target cluster using performance projection.
- Guidance:
- Prefer keeping TP intra-node (for faster AR); scale EP and DP across nodes.
- For MoE, use EP that avoids inter-node A2A when possible; otherwise enable DeepEP.
- Use CP only when sequence length forces it; in MoE, CP may be folded into EP.
- Increase DP last (weak scaling) once a minimal viable PP×EP×TP is established.
2) Best pipeline schedule
- Compare (for the chosen PP/VPP):
- 1F1B
- Interleaved 1F1B (VPP > 1)
- Zero-Bubble (B/W split, VPP = 1)
- ZBV Formatted (VPP = 2)
- ZBV Greedy (VPP = 2, memory modes: min/half)
- Megatron ILP (VPP = 1, where available)
- Recommendation pattern:
- Dense models: interleaved or ZB depending on VPP feasibility and memory.
- MoE (e.g., Mixtral): VPP=2 with ZBV Formatted often wins, especially with DeepEP ON.
3) Memory fit at target nodes
- Run memory projection first. Review:
- Parameters + optimizer (sharded by DP)
- Activations (attention vs MoE MLP; MoE often dominates)
- Pipeline scaling: peak activations scale with PP and VPP schedule
- If not fitting:
- Enable recomputation (full or partial)
- Adjust microbatch size and PP/VPP
- Reduce top-k or expert sizes for MoE if acceptable
4) Communication collectives and algorithms
- In use (typical):
- AllReduce: TP and DP gradients (best-of Ring/Hypercube/Bruck/Single-shot)
- All-to-All: EP token dispatch/combine (pairwise, topology-aware)
- Reduce-Scatter / All-Gather: optimizer/activation sharding (if configured)
- P2P Send/Recv: PP stage activations/gradients
- Distinguish intra-node (xGMI/NVLink/UALink) vs inter-node (IB/RoCE). Provide
--hardware-configto model your network accurately.
5) Sample command lines
Optimization Space Exploration
Primus can project throughput and memory across dozens of optimization combinations from a single-node benchmark (8 GPUs), eliminating the need for expensive multi-node runs. This was validated on DeepSeek V2 (236B MoE) across 17 configurations on 4-node MI355X — the projection tracked measured results across all optimization combinations and correctly identified the highest-impact optimizations.
Category 1: MoE Communication Optimizations (CLI flags)
| Optimization | CLI Flag / Config Key | What It Does | Projection Impact | |
|---|---|---|---|---|
| DeepEP | --enable-deepep / use_turbo_deepep: true | Async A2A overlap with compute for MoE. Pipelining A2A dispatch/combine behind expert GEMM. | High — largest single-optimization throughput gain (35%+ for DeepSeek V2). A2A critical-path reduced by 65–85%. | |
| SyncFree MoE | --sync-free-stage {1,2,3} | Progressive fusion: 1=fused router, 2=+DeepEP+grouped GEMM, 3=+fused activations. Auto-enables DeepEP. | Medium–High — stage 3 achieves 85% A2A overlap (vs. 65% baseline). Each stage adds more fusion. | |
| Target EP size | --target-ep-size N | Override EP for projection (test EP=4 vs EP=8 without changing config). | High — EP determines A2A volume and whether A2A stays intra-node or crosses nodes. |
Category 2: Pipeline Schedule & Layout (CLI flags + config)
| Optimization | CLI Flag / Config Key | What It Does | Projection Impact | |||
|---|---|---|---|---|---|---|
| Pipeline schedule | --pipeline-schedule {auto,zerobubble,zerobubble-heuristic,zbv-formatted,zbv-greedy-half,zbv-greedy-min,seaailab-ilp,all} | Select pipeline scheduling algorithm. Use all to compare every algorithm in one run. | Medium — +8–13% for dense models (ZB vs 1F1B); less for MoE with small PP. | |||
| Zero-Bubble enable | --enable-zero-bubble / enable_zero_bubble: true | Enable B/W split zero-bubble scheduling. | Medium — near-zero pipeline idle time, at higher peak memory. | |||
| VPP (interleaving) | --num-virtual-stages-per-pipeline-rank N | Virtual pipeline stages per rank, reduces bubble ratio. | Medium — VPP=2–4 reduces bubble; higher VPP adds P2P overhead and memory. | |||
| Pipeline layout (uneven) | `pipeline_model_parallel_layout: "Et*4\ | t*4\ | ..."` (config) | String encoding of per-stage layer assignments. E.g., put embedding on first stage with fewer transformer layers. | Medium — balances stage compute times; reduces bubble from stage imbalance. | |
| First/last stage layers | decoder_first_pipeline_num_layers: N / decoder_last_pipeline_num_layers: N (config) | Override layer count for first/last PP stages (simpler than full layout string). | Medium — simpler way to handle embedding/output imbalance. |
Category 3: Memory Optimizations (config)
| Optimization | Config Key | What It Does | Projection Impact | |
|---|---|---|---|---|
| Full recomputation | recompute_granularity: full + recompute_num_layers: N | Recompute all activations for the first N layers per virtual chunk. Saves peak activation memory at the cost of extra forward pass. | Memory: High — dramatic HBM reduction (up to 60%+ activation savings). Performance: slight decrease from recompute overhead. | |
| Selective recomputation | recompute_granularity: selective | Recompute only expensive activations (e.g., attention softmax) while keeping cheap ones. Note: memory projection currently models full only; selective is a config hint for the runtime. | Memory: Medium — partial savings without full recompute cost. | |
| Loss fusion | cross_entropy_loss_fusion: true | Fuses cross-entropy into output GEMM pipeline; eliminates full logits materialisation. | Memory: Medium — logits activation → 0 bytes. Compute: removes separate softmax/CE pass. | |
| FSDP2 | use_torch_fsdp2: true | Fully Sharded DP: replaces gradient AllReduce with ReduceScatter/AllGather. Enables per-layer overlap model for FSDP comm. | Memory: High — shards optimizer state + gradients across DP ranks. Performance: overlap model hides most FSDP comm behind compute. | |
| Distributed optimizer | use_distributed_optimizer: true | ZeRO-1-style optimizer sharding across DP ranks. | Memory: Medium — shards optimizer state (Adam moments). Less aggressive than FSDP2. |
Category 4: Parallelism Configuration (config + env)
| Optimization | Config Key / Env Var | What It Does | Projection Impact | |
|---|---|---|---|---|
| Tensor parallelism | tensor_model_parallel_size: N | Shard attention/MLP across N GPUs within a node. Adds TP AllReduce per layer. | Perf — reduces per-GPU compute; adds intra-node comm. Keep TP ≤ node_size. | |
| Pipeline parallelism | pipeline_model_parallel_size: N | Distribute layers across N stages. Adds pipeline bubbles + P2P comm. | Perf + Memory — reduces per-GPU layers/activations; adds bubble overhead. | |
| Expert parallelism | expert_model_parallel_size: N / --target-ep-size N | Distribute MoE experts across N ranks. Adds A2A dispatch/combine. | Perf — EP intra-node is fast; inter-node EP is expensive (use DeepEP). | |
| Context parallelism | context_parallel_size: N (or context_model_parallel_size) | Split sequence length across N ranks for long-context training. | Perf + Memory — reduces per-GPU sequence length and activation memory. Use only when seq_len forces it. | |
| Data parallelism | data_parallel_size: N (derived from world_size / (TP×PP×CP)) | Replicate model across N groups. Adds gradient AllReduce. | Perf — weak scaling; increase last after TP/PP/EP are set. | |
| Env overrides | PRIMUS_TP, PRIMUS_PP, PRIMUS_EP, NNODES, GPUS_PER_NODE | Override parallelism and cluster size from environment. | — |
Category 5: Precision & Attention (config)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/primus-projection/SKILL.md
Popularity
- Repository stars
- 120
- Repository forks
- 46
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/amd-agi/primus/primus-projection)