AGENT SKILL

distributed

Composer distributed launch, rank, device, sampler, auto microbatching, and parallelism workflows.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
distributed
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Composer distributed launch, rank, device, sampler, auto microbatching, and parallelism workflows.
disable-model-invocation
true

02 资源文件 5

03 SKILL.md 正文

Composer Distributed

Use this sub-skill when a task needs Composer-specific distributed launch, rank or world-size reasoning, sampler wiring, device/backend selection, auto microbatching caveats, or FSDP/FSDP2/tensor-parallel configuration basics.

Route here

  • Convert a single-process training script into a composer launcher command.
  • Choose --nproc, --world_size, --node_rank, --base_rank, --master_addr, and --master_port for single-node or multi-node runs.
  • Capture non-rank-zero stdout/stderr with filename placeholders such as {rank} or {local_rank}.
  • Read rank values through composer.utils.dist instead of parsing environment variables by hand.
  • Add dist.get_sampler(dataset, shuffle=True) for map-style datasets.
  • Decide between device="cpu", device="gpu", MPS, TPU, HPU, and Neuron device helpers.
  • Understand when device_train_microbatch_size="auto" can recover from CUDA OOMs.
  • Prepare basic parallelism_config for DDP/FSDP/FSDP2/tensor-parallel work.

Reroute

  • Core Trainer fit/eval loops, optimizer stepping, checkpoint scheduling, or non-distributed resume: use ../training/SKILL.md.
  • Algorithm/method behavior and method-specific side effects: use ../methods/SKILL.md.
  • Loggers, profiler setup, tracing, and performance-analysis tooling: use ../observability/SKILL.md.
  • Export-only, inference, ONNX, TorchScript, or deployment flows: use ../inference-export/SKILL.md.

Read first

  • Launcher and ranks: CLI launcher, rank environment variables, output capture, and sampler wiring.
  • Parallelism and backends: device selection, FSDP/FSDP2/TP configuration, auto microbatching, and backend prerequisites.
  • Troubleshooting: launch/backend/distributed failures and concrete recovery checks.
  • Device probe: safe local Composer/Torch device surface check.
  • Launcher help: safe launcher usage printer that does not start training.

Quick launch patterns

Single node with every visible GPU:

composer -n 8 train.py --config config.yaml

Single node with rank-specific child logs:

composer -n 8 --stdout stdout_{rank}.log --stderr stderr_{rank}.log train.py

Module mode, useful when the training entry point is importable:

composer -n 4 -m package.train --arg value

Multi-node requires explicit topology:

composer -n 8 --world_size 16 --node_rank 1 --master_addr host0 --master_port 29500 train.py

If world_size > nproc, provide enough information for Composer to infer the global ranks on this node.

In-script distributed pattern

from torch.utils.data import DataLoader
from composer.utils import dist

sampler = dist.get_sampler(dataset, shuffle=True)
loader = DataLoader(dataset, batch_size=32, sampler=sampler)

if dist.get_global_rank() == 0:
    print("rank zero logs once")

Use get_world_size(), get_local_rank(), get_global_rank(), get_node_rank(), and get_local_world_size() for diagnostics that also work in non-distributed runs.

Device and backend rules

  1. Start CPU-only if the issue is model logic, dataloader schema, or loss/metric behavior.
  2. Move to device="gpu" only after PyTorch reports CUDA availability and the requested precision is supported.
  3. Treat MPS/TPU/HPU/Neuron as backend-specific paths; verify the vendor runtime before claiming support.
  4. For FSDP/FSDP2/tensor parallelism, align the world size with the requested sharding/replication/tensor degrees.
  5. CPU importability is not proof that GPU launch, FSDP, or auto-microbatching is healthy.

Auto microbatching decision guide

Set device_train_microbatch_size="auto" when a CUDA training run OOMs during forward/backward and the full batch should be split dynamically. It does not fix dataloader memory, CPU OOM, model construction OOM, callback OOM, or algorithm work that runs outside the Trainer forward/backward path. Be careful with BatchNorm when auto microbatching makes microbatches very small.

Safe workflow

  1. Run python scripts/device_probe.py to inspect import/device availability.
  2. Run python scripts/launcher_help.py before composing launch commands.
  3. Verify the training script works as python train.py or python -m package.train before multi-rank launch.
  4. Add dist.get_sampler for map-style datasets.
  5. Add rank-specific file placeholders before increasing ranks.
  6. Add FSDP/FSDP2/TP only after ordinary DDP launch works.
  7. Keep a tiny synthetic job for backend smoke; do not debug distributed launch on a full production run first.

Ask or stop before proceeding

  • The user asks for multi-node launch but cannot provide master address, rank topology, scheduler details, or network reachability.
  • Required accelerator hardware or vendor runtime is unavailable.
  • The task would launch a long training run, write to shared storage, or consume all GPUs without explicit approval.
  • A sharded checkpoint must be loaded on a different world size and the checkpoint format/backends are unknown.
  • FSDP/TP degrees conflict with visible world size or model architecture.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351