[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CPR3PZRGP7X8FJB3GVP7XM":3,"skill-same:01M7CPR3PZRGP7X8FJB3GVP7XM":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":6,"ownerDescription":36,"updatedAt":37,"install":38,"resources":51},"01M7CPR3PZRGP7X8FJB3GVP7XM","nemo-automodel-distributed-training",null,"Guide for selecting and configuring distributed training strategies in NeMo AutoModel, including FSDP2, Megatron FSDP, DDP, and parallelism settings.","om-scogo\u002Fskillsh-scraper","om-scogo","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160466840?v=4","01M79AWB6DFVCQ7RK70CS34B96","Om Achrekar","01M79AWB6ZM9SKR8KDH1WSSM22",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fnvidia-skills\u002Fnemo-automodel-distributed-training\u002Fskills\u002Fnemo-automodel-distributed-training\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: nemo-automodel-distributed-training\ndescription: Guide for selecting and configuring distributed training strategies in NeMo AutoModel, including FSDP2, Megatron FSDP, DDP, and parallelism settings.\nwhen_to_use: Adding or modifying distributed training strategies (FSDP2, HSDP, DDP), debugging multi-GPU or multi-node failures, configuring context or tensor parallelism, or tuning sharding settings.\nlicense: Apache-2.0\nmetadata:\n  author: NVIDIA\n  tags:\n    - nemo-automodel\n    - distributed-training\n---\n\n# Distributed Training in NeMo AutoModel\n\n## Purpose\n\nNeMo AutoModel uses PyTorch-native distributed training.\nAll parallelism is orchestrated through a single `MeshContext` object that\nholds device meshes, strategy configs, and axis names.\n\u003C!-- NVSkills signature refresh requested for AM-519. -->\n\n## Instructions\n\nFor conceptual distributed-training questions, answer directly from the quick\npatterns in this skill without inspecting the repository. Start with the\nstrategy choice, then list only the YAML fields and constraints relevant to the\nquestion.\n\nUse direct action verbs in the final answer: recommend the strategy, show the\nminimal YAML, state the sizing constraint, and name the unsupported strategies.\nDo not discuss model onboarding, recipes, Slurm, SkyPilot, or checkpointing\nunless the user asks.\n\n## Examples\n\n### TP plus PP for a large multi-node model\n\nRecommend `strategy: fsdp2`. Mention `tp_size`, `pp_size`, `cp_size`,\n`ep_size`, and the `pipeline` sub-config. State that `dp_size` is inferred from\n`world_size \u002F (tp_size * pp_size * cp_size)`.\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  tp_size: 8\n  pp_size: 4\n  cp_size: 1\n  ep_size: 1\n  pipeline:\n    pp_schedule: interleaved1f1b\n    pp_microbatch_size: 1\n```\n\n### MoE expert parallelism\n\nRecommend `strategy: fsdp2` with `ep_size > 1`. Say this creates a separate\n`moe_mesh`; include the `moe` sub-config when relevant; state that `ep_size`\nmust divide `dp_size * cp_size`. Do not recommend `megatron_fsdp` or `ddp`.\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  ep_size: 8\n  moe:\n    reshard_after_forward: false\n```\n\n### MegatronFSDP limitations\n\nSay no for pipeline parallelism, expert parallelism, and `sequence_parallel`.\nRecommend `fsdp2` for PP, EP, or `sequence_parallel`; mention that DDP is only\nsimple data parallelism.\n\n## Strategy Selection\n\nThree strategies are available, selected via the `distributed.strategy` YAML key:\n\n| Strategy | YAML value | Best for |\n|---|---|---|\n| FSDP2 | `fsdp2` | General use, recommended default. Supports TP, PP, CP, EP, HSDP. |\n| MegatronFSDP | `megatron_fsdp` | NVIDIA Megatron-style FSDP. No PP, no EP, no sequence_parallel. |\n| DDP | `ddp` | Simple data parallelism only. No TP, PP, CP, or EP. |\n\nDecision tree:\n\n- Single GPU: no distributed config needed (FSDP2Manager skips parallelization when world_size=1).\n- Multi-GPU single node: `fsdp2` (default). Use `ddp` only if you need the simplest possible setup.\n- Multi-node: `fsdp2` with appropriate TP\u002FPP sizing.\n- MoE models with expert parallelism: `fsdp2` with `ep_size > 1` (creates a separate `moe_mesh`).\n- Large models (70B+): `fsdp2` with PP + TP.\n- Long sequences (8K+): add CP (`cp_size > 1`).\n\nWhen answering strategy-selection questions, state the chosen `distributed.strategy`\nfirst, then enumerate the YAML fields the user must set.\n\nQuick TP + PP answer:\n\n- Use `strategy: fsdp2`; do not use `megatron_fsdp` when pipeline parallelism is required.\n- Set `tp_size` for tensor parallelism and `pp_size` for pipeline parallelism.\n- Add a `pipeline:` sub-config with `pp_schedule` and `pp_microbatch_size`.\n- Leave `dp_size` unset or `none`; it is inferred as `world_size \u002F (tp_size * pp_size * cp_size)`.\n- Keep TP inside a fast intra-node domain when possible, and use PP across model depth for 70B+ models.\n\nQuick MoE expert-parallel answer:\n\n- Start with `strategy: fsdp2` and `ep_size > 1`.\n- Include a `moe:` sub-config only when `ep_size > 1`; it maps to `MoEParallelizerConfig`.\n- Expect a separate `moe_mesh` for expert parallelism in addition to the main `device_mesh`.\n- Do not recommend `megatron_fsdp` or `ddp` for expert parallelism; `megatron_fsdp` has no EP support.\n- Before finishing an MoE EP answer, explicitly state that `ep_size` must divide `dp_size * cp_size` and that `megatron_fsdp` does not support EP, PP, or `sequence_parallel`.\n\n## YAML Config Structure\n\nThe `distributed` section in the recipe YAML maps directly to\n`parse_distributed_section()` in `recipes\u002F_dist_utils.py`:\n\n```yaml\ndistributed:\n  strategy: fsdp2           # fsdp2 | megatron_fsdp | ddp\n  dp_size: none             # auto-calculated from world_size \u002F (tp * pp * cp)\n  dp_replicate_size: none   # FSDP2-only, for HSDP\n  tp_size: 1\n  pp_size: 1\n  cp_size: 1\n  ep_size: 1\n\n  # Strategy-specific flags (forwarded to the strategy dataclass):\n  sequence_parallel: false\n  activation_checkpointing: false\n  defer_fsdp_grad_sync: true   # FSDP2 only\n\n  # Sub-configs (optional):\n  pipeline:\n    pp_schedule: 1f1b\n    pp_microbatch_size: 1\n    # ... see PipelineConfig fields\n\n  moe:\n    reshard_after_forward: false\n    # ... see MoEParallelizerConfig fields\n```\n\nThe `dp_size` is always inferred:\n\n```\ndp_size = world_size \u002F (tp_size * pp_size * cp_size)\n```\n\n## Infrastructure Flow\n\n```\ninitialize_distributed()                       [components\u002Fdistributed\u002Finit_utils.py]\n    -> initializes torch.distributed process group and returns DistInfo\nYAML distributed section + DistInfo.world_size\n    -> parse_distributed_section()          [recipes\u002F_dist_utils.py]\n    -> create_distributed_setup_from_config()              [recipes\u002F_dist_utils.py]\n        -> DistributedSetup.build()         [components\u002Fdistributed\u002Fconfig.py]\n    -> instantiate_infrastructure()         [_transformers\u002Finfrastructure.py]\n        -> _instantiate_distributed()       -> FSDP2Manager \u002F MegatronFSDPManager \u002F DDPManager\n        -> _instantiate_pipeline()          -> AutoPipeline (if pp_size > 1)\n        -> parallelize_fn                   -> MoE parallelizer (if ep_size > 1) or PP wrapper\n    -> apply_model_infrastructure()         [_transformers\u002Finfrastructure.py]\n        -> _shard_pp() or _shard_ep_fsdp()  (applies sharding to the model)\n```\n\n## FSDP2 Configuration\n\n### Basic FSDP2 (data parallelism only)\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  tp_size: 1\n  cp_size: 1\n```\n\nThis auto-calculates `dp_size = world_size` and applies `fully_shard()` per\ntransformer block via DTensor-based sharding.\n\n### FSDP2 with Tensor Parallelism\n\nKeep TP within a single NVLink domain (typically one node):\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  tp_size: 4        # 2, 4, or 8 -- must divide GPUs per node\n  sequence_parallel: true\n```\n\nThe TP plan is auto-selected based on the model type. Pass a custom plan via\nthe Python API if needed:\n\n```python\nconfig = FSDP2Config(sequence_parallel=True, tp_plan=my_custom_plan)\n```\n\n### FSDP2 with Pipeline Parallelism\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  pp_size: 2\n  pipeline:\n    pp_schedule: interleaved1f1b   # 1f1b, gpipe, interleaved_1f1b, etc.\n    pp_microbatch_size: 4\n    scale_grads_in_schedule: false\n```\n\nThe model must have a `_pp_plan` attribute (set on the HF model class) for\n`AutoPipeline` to know how to split layers across stages. Models without\n`_pp_plan` are not compatible with PP.\n\n### FSDP2 with HSDP (Hybrid Sharded Data Parallel)\n\nIntra-node full sharding + inter-node replication via a 2D DeviceMesh:\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  dp_replicate_size: 2   # must divide dp_size\n```\n\nConstraint: `dp_replicate_size \u003C dp_size` (pure replication with no sharding\nis not supported by FSDP2).\n\n### Activation Checkpointing\n\nTrades compute for memory by recomputing activations during backward:\n\n```yaml\ndistributed:\n  activation_checkpointing: true\n```\n\nThis is a model-build\u002Ftraining behavior flag, not mesh topology. Dense\nstrategies read it from the strategy config; EP\u002FMoE paths pass the recipe-level\nflag directly into model infrastructure.\n\n### Gradient Sync Deferral\n\nFSDP2 defers gradient sync to the final micro-batch by default for\ncommunication overlap:\n\n```yaml\ndistributed:\n  defer_fsdp_grad_sync: true   # default\n```\n\n### Mixed Precision\n\nFSDP2Config defaults to bfloat16 for all three precision knobs via\n`MixedPrecisionPolicy(param_dtype=bf16, reduce_dtype=bf16, output_dtype=bf16,\ncast_forward_inputs=True)`. Override via the Python API:\n\n```python\nfrom torch.distributed.fsdp import MixedPrecisionPolicy\nconfig = FSDP2Config(\n    mp_policy=MixedPrecisionPolicy(param_dtype=torch.float16, reduce_dtype=torch.float32),\n)\n```\n\n## Pipeline Parallelism\n\n### Requirements\n\n1. Model class must define `_pp_plan` (a dict mapping module FQNs to stages).\n2. `pp_size > 1` in the distributed section.\n3. A `pipeline` sub-config with schedule and microbatch size.\n\n### Supported schedules\n\nDefined in `PipelineConfig.pp_schedule`:\n\n- `1f1b` (one-forward-one-backward, default)\n- `gpipe`\n- `interleaved_1f1b` \u002F `interleaved1f1b`\n- `looped_bfs`\n- `dfs`\n- `v_schedule`\n- `zero_bubble`\n\n### Example (8B model on 8 GPUs, PP=2 + DP=4)\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  pp_size: 2\n\n  pipeline:\n    pp_schedule: interleaved1f1b\n    pp_microbatch_size: 4\n    scale_grads_in_schedule: false\n\ncheckpoint:\n  model_save_format: safetensors\n  save_consolidated: final\n```\n\n### How it works\n\n`AutoPipeline.build()` calls `pipeline_model()` which splits the model into\nstages using the model's `_pp_plan`, creates `PipelineStage` objects, and\nbuilds the schedule. During training, `schedule.step()` drives forward and\nbackward through the pipeline.\n\n## Context Parallelism\n\nUse CP for long sequences (8K+). CP shards Q\u002FK\u002FV on the sequence dimension\nas DTensors.\n\n### Config\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  cp_size: 2   # or 4, 8\n```\n\n### Requirements\n\n- SDPA (Flash Attention or Efficient Attention backend) or Transformer Engine\n  attention. SDPBackend.MATH is not compatible with DTensor.\n- Attention masks are automatically stripped; `is_causal=True` is set via\n  forward pre-hooks registered by `attach_context_parallel_hooks()`.\n\n### How it works\n\n1. After model sharding, `apply_model_infrastructure()` calls\n   `attach_context_parallel_hooks()` on each model part (for non-TE models).\n2. At each training step, `make_cp_batch_and_ctx()` creates a CP context\n   manager that shards the batch along the sequence dimension and sets up\n   `context_parallel()` from `torch.distributed.tensor.experimental`.\n3. For TE attention models, `make_cp_batch_for_te()` uses THD format and\n   TE's `thd_get_partitioned_indices` for sharding.\n\n### CP with Sequence Packing\n\nCP works with packed sequences. The `packed_sequence_size` must be divisible\nby `cp_size`. When using TE, chunks are sharded per-chunk via\n`_shard_thd_chunk_for_te()`.\n\n## Sequence Packing\n\nPacking multiple sequences into a single training sample for efficiency.\n\n### Config\n\n```yaml\npacked_sequence:\n  packed_sequence_size: 4096   # 0 = disabled\n\nstep_scheduler:\n  local_batch_size: 1          # must be 1 for packed sequences\n```\n\nWhen `packed_sequence_size > 0`, the dataset collator packs sequences up to\nthat length. `local_batch_size` must be 1 because each \"sample\" is already a\npacked batch.\n\n## MoE Distributed Training\n\n### Expert Parallelism\n\nSet `ep_size > 1` to distribute experts across GPUs. This creates a separate\n`moe_mesh` alongside the main `device_mesh`:\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  ep_size: 8\n  activation_checkpointing: true\n```\n\nThe `moe_mesh` shape is `(pp_size, ep_shard_size, ep_size)` with dimension\nnames `(\"pp\", \"ep_shard\", \"ep\")`.\n\nConstraint: `dp_cp_size` (= `dp_size * cp_size`) must be divisible by\n`ep_size`.\n\n### MoE sub-config\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  ep_size: 8\n  activation_checkpointing: true\n\n  moe:\n    reshard_after_forward: false\n    ignore_router_for_ac: false\n    wrap_outer_model: true\n```\n\nThe `moe` sub-section maps to `MoEParallelizerConfig` and is only\ninstantiated when `ep_size > 1`.\n\n### Full MoE example (Qwen3-30B-A3B on 8 GPUs)\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  tp_size: 1\n  cp_size: 1\n  pp_size: 1\n  ep_size: 8\n  sequence_parallel: false\n  activation_checkpointing: true\n```\n\n### MegatronFSDP limitations\n\nDespite its name, `megatron_fsdp` does **not** support expert parallelism\n(`ep_size > 1`), pipeline parallelism (`pp_size > 1`), or\n`sequence_parallel`. Use `fsdp2` for these features.\n\n## Parallelism Sizing Guidelines\n\n### Dense models\n\n| Model size | TP | PP | CP | Strategy |\n|---|---|---|---|---|\n| \u003C 3B | 1 | 1 | 1 | FSDP2 (DP only) |\n| 3-13B | 2-4 | 1 | 1 | FSDP2 + TP |\n| 13-70B | 4-8 | 2-4 | 1 | FSDP2 + TP + PP |\n| 70B+ | 8 | 4-8 | 1 | FSDP2 + TP + PP |\n| Any + long seq (8K+) | as above | as above | 2-8 | add CP |\n\n### MoE models\n\nMoE models need less TP than dense models of similar total parameter count\nbecause only a fraction of parameters are active per token. EP is the primary\nscaling dimension:\n\n| Model | TP | PP | EP | Notes |\n|---|---|---|---|---|\n| Small MoE (\u003C10B total) | 1 | 1 | 8 | EP only |\n| Medium MoE (10-30B total) | 1-2 | 1 | 8 | small TP for shared layers |\n| Large MoE (100B+ total) | 1-2 | 4+ | 8-64 | PP for depth, EP for experts |\n\n### Hardware topology rules\n\n- TP must stay within a single NVLink domain (one node, typically 8 GPUs).\n- Use PP or DP for cross-node scaling.\n- TP across InfiniBand degrades throughput severely.\n\n## Programmatic API (from_pretrained \u002F from_config)\n\nWhen not using YAML recipes, configure distributed training via Python:\n\n```python\nfrom nemo_automodel.components.distributed import (\n    DistributedSetup,\n    FSDP2Config,\n    ParallelismSizes,\n    initialize_distributed,\n)\n\ndist_env = initialize_distributed(\"nccl\")\ndistributed_setup = DistributedSetup.build(\n    strategy=FSDP2Config(sequence_parallel=True),\n    parallelism_sizes=ParallelismSizes(tp_size=2),\n    activation_checkpointing=True,\n    world_size=dist_env.world_size,\n)\n```\n\nOr pass directly to `from_pretrained`:\n\n```python\nfrom nemo_automodel import NeMoAutoModelForCausalLM\n\nmodel = NeMoAutoModelForCausalLM.from_pretrained(\n    \"meta-llama\u002FLlama-3.2-1B\",\n    distributed_setup=distributed_setup,\n)\n```\n\n## Code Anchors\n\nStrategy config dataclasses:\n\n```\ncomponents\u002Fdistributed\u002Fconfig.py\n    FSDP2Config       -- sequence_parallel, tp_plan, mp_policy, offload_policy,\n                         activation_checkpointing, defer_fsdp_grad_sync\n    MegatronFSDPConfig -- zero_dp_strategy, overlap_grad_reduce, overlap_param_gather, etc.\n    DDPConfig          -- activation_checkpointing only\n```\n\nMeshContext (single source of truth for parallelism):\n\n```\ncomponents\u002Fdistributed\u002Fmesh.py\n    MeshContext  -- device_mesh, moe_mesh\n                    Properties: tp_size, pp_size, cp_size, ep_size, dp_size, dp_replicate_size\n    MeshAxisName -- PP, DP, DP_REPLICATE, DP_SHARD, DP_SHARD_CP, DP_CP, CP, TP, EP, EP_SHARD\n```\n\nMesh context and raw mesh creation:\n\n```\ncomponents\u002Fdistributed\u002Fconfig.py\n    DistributedSetup.build()      -- builds MeshContext from strategy + parallelism\ncomponents\u002Fdistributed\u002Fmesh_utils.py\n    _create_device_meshes()       -- routes to FSDP2\u002FMegatronFSDP\u002FDDP raw mesh creation\n    _create_fsdp2_device_mesh()   -- shape (pp, dp_replicate, dp_shard, cp, tp) + flattened submeshes\n    _create_megatron_fsdp_device_mesh() -- shape (dp, cp, tp)\n```\n\nDistributed managers:\n\n```\ncomponents\u002Fdistributed\u002Ffsdp2.py          -- FSDP2Manager.parallelize()\ncomponents\u002Fdistributed\u002Fmegatron_fsdp.py  -- MegatronFSDPManager.parallelize()\ncomponents\u002Fdistributed\u002Fddp.py            -- DDPManager\n```\n\nPipeline parallelism:\n\n```\ncomponents\u002Fdistributed\u002Fpipelining\u002Fconfig.py        -- PipelineConfig dataclass\ncomponents\u002Fdistributed\u002Fpipelining\u002Fautopipeline.py  -- AutoPipeline orchestrator\ncomponents\u002Fdistributed\u002Fpipelining\u002Ffunctional.py    -- pipeline_model(), schedule creation\ncomponents\u002Fdistributed\u002Fpipelining\u002Fhf_utils.py      -- HF model validation for PP\n```\n\nContext parallelism:\n\n```\ncomponents\u002Fdistributed\u002Fcp_utils.py\n    make_cp_batch_and_ctx()            -- creates CP context manager + shards batch\n    create_context_parallel_ctx()      -- wraps torch.distributed.tensor.experimental.context_parallel\n    attach_context_parallel_hooks()    -- strips attention_mask, sets is_causal=True\n    make_cp_batch_for_te()             -- TE-specific CP batch sharding (THD format)\n```\n\nInfrastructure orchestration:\n\n```\n_transformers\u002Finfrastructure.py\n    instantiate_infrastructure()    -- config objects -> runtime objects\n    apply_model_infrastructure()    -- applies sharding, PEFT, checkpoints to model\n    _shard_pp()                     -- pipeline parallel path\n    _shard_ep_fsdp()                -- EP + FSDP path (non-PP)\n```\n\nYAML parsing:\n\n```\nrecipes\u002F_dist_utils.py\n    parse_distributed_section()  -- YAML dict -> typed configs + sizes\n    create_distributed_setup_from_config()  -- recipe adapter: parse + create DistributedSetup; does not init process group\n```\n\nMoE config:\n\n```\ncomponents\u002Fdistributed\u002Fconfig.py\n    MoEParallelizerConfig  -- reshard_after_forward, ignore_router_for_ac, wrap_outer_model, etc.\ncomponents\u002Fmoe\u002Fconfig.py\n    MoEConfig              -- n_routed_experts, n_activated_experts, score_func, etc.\n```\n\n## Pitfalls\n\n1. **TP across nodes destroys throughput.** Always keep TP within a single\n   NVLink domain. Use PP or DP for cross-node scaling.\n\n2. **PP requires `_pp_plan` on the model class.** Not all HF models have this.\n   Check `validate_hf_model_for_pipeline_support()` before enabling PP.\n\n3. **PP bubbles reduce GPU utilization.** Use interleaved schedules\n   (`interleaved_1f1b`) and smaller microbatches to reduce bubble time.\n\n4. **FSDP2 requires DTensor-aware state dict saving.** Use `safetensors` with\n   `save_consolidated: final` for final HF export, or `save_consolidated: false`\n   plus the generated `model\u002Fconsolidate.sh` helper for offline export.\n\n5. **CP requires compatible attention.** SDPA (Flash Attention or Efficient\n   Attention) or TE attention only. `SDPBackend.MATH` is not compatible with\n   DTensor.\n\n6. **MoE EP size must evenly divide `dp_size * cp_size`.** The device mesh\n   creation asserts `dp_cp_size % ep_size == 0`.\n\n7. **MegatronFSDP is more limited than FSDP2.** It does not support PP\n   (`pp_size > 1`), EP (`ep_size > 1`), or `sequence_parallel`. The\n   `MeshContext` validation raises on these combinations.\n\n8. **DDP supports nothing beyond data parallelism.** No TP, PP, CP, EP, or\n   HSDP. Validation raises on any of these.\n\n9. **Activation checkpointing increases compute.** It saves memory by\n   recomputing activations during backward, but adds ~30% compute overhead.\n\n10. **Mixed precision policy must match model expectations.** The default\n    bfloat16 policy works for most models. FP16 models may need a custom\n    `MixedPrecisionPolicy`.\n\n11. **`packed_sequence_size` must be divisible by `cp_size`** when using CP\n    with packed sequences.\n\n12. **`dp_replicate_size` is FSDP2-only.** Passing it with `megatron_fsdp`\n    or `ddp` raises a `ValueError`.\n\n## Verification\n\nRun the smallest recipe that exercises the requested strategy. Success means\nexit code 0, finite loss, no NCCL timeout, and log output matching the expected\nTP\u002FPP\u002FCP\u002FEP sizes.\n","# Distributed Training in NeMo AutoModel\n\n## Purpose\n\nNeMo AutoModel uses PyTorch-native distributed training.\nAll parallelism is orchestrated through a single `MeshContext` object that\nholds device meshes, strategy configs, and axis names.\n\u003C!-- NVSkills signature refresh requested for AM-519. -->\n\n## Instructions\n\nFor conceptual distributed-training questions, answer directly from the quick\npatterns in this skill without inspecting the repository. Start with the\nstrategy choice, then list only the YAML fields and constraints relevant to the\nquestion.\n\nUse direct action verbs in the final answer: recommend the strategy, show the\nminimal YAML, state the sizing constraint, and name the unsupported strategies.\nDo not discuss model onboarding, recipes, Slurm, SkyPilot, or checkpointing\nunless the user asks.\n\n## Examples\n\n### TP plus PP for a large multi-node model\n\nRecommend `strategy: fsdp2`. Mention `tp_size`, `pp_size`, `cp_size`,\n`ep_size`, and the `pipeline` sub-config. State that `dp_size` is inferred from\n`world_size \u002F (tp_size * pp_size * cp_size)`.\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  tp_size: 8\n  pp_size: 4\n  cp_size: 1\n  ep_size: 1\n  pipeline:\n    pp_schedule: interleaved1f1b\n    pp_microbatch_size: 1\n```\n\n### MoE expert parallelism\n\nRecommend `strategy: fsdp2` with `ep_size > 1`. Say this creates a separate\n`moe_mesh`; include the `moe` sub-config when relevant; state that `ep_size`\nmust divide `dp_size * cp_size`. Do not recommend `megatron_fsdp` or `ddp`.\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  ep_size: 8\n  moe:\n    reshard_after_forward: false\n```\n\n### MegatronFSDP limitations\n\nSay no for pipeline parallelism, expert parallelism, and `sequence_parallel`.\nRecommend `fsdp2` for PP, EP, or `sequence_parallel`; mention that DDP is only\nsimple data parallelism.\n\n## Strategy Selection\n\nThree strategies are available, selected via the `distributed.strategy` YAML key:\n\n| Strategy | YAML value | Best for |\n|---|---|---|\n| FSDP2 | `fsdp2` | General use, recommended default. Supports TP, PP, CP, EP, HSDP. |\n| MegatronFSDP | `megatron_fsdp` | NVIDIA Megatron-style FSDP. No PP, no EP, no sequence_parallel. |\n| DDP | `ddp` | Simple data parallelism only. No TP, PP, CP, or EP. |\n\nDecision tree:\n\n- Single GPU: no distributed config needed (FSDP2Manager skips parallelization when world_size=1).\n- Multi-GPU single node: `fsdp2` (default). Use `ddp` only if you need the simplest possible setup.\n- Multi-node: `fsdp2` with appropriate TP\u002FPP sizing.\n- MoE models with expert parallelism: `fsdp2` with `ep_size > 1` (creates a separate `moe_mesh`).\n- Large models (70B+): `fsdp2` with PP + TP.\n- Long sequences (8K+): add CP (`cp_size > 1`).\n\nWhen answering strategy-selection questions, state the chosen `distributed.strategy`\nfirst, then enumerate the YAML fields the user must set.\n\nQuick TP + PP answer:\n\n- Use `strategy: fsdp2`; do not use `megatron_fsdp` when pipeline parallelism is required.\n- Set `tp_size` for tensor parallelism and `pp_size` for pipeline parallelism.\n- Add a `pipeline:` sub-config with `pp_schedule` and `pp_microbatch_size`.\n- Leave `dp_size` unset or `none`; it is inferred as `world_size \u002F (tp_size * pp_size * cp_size)`.\n- Keep TP inside a fast intra-node domain when possible, and use PP across model depth for 70B+ models.\n\nQuick MoE expert-parallel answer:\n\n- Start with `strategy: fsdp2` and `ep_size > 1`.\n- Include a `moe:` sub-config only when `ep_size > 1`; it maps to `MoEParallelizerConfig`.\n- Expect a separate `moe_mesh` for expert parallelism in addition to the main `device_mesh`.\n- Do not recommend `megatron_fsdp` or `ddp` for expert parallelism; `megatron_fsdp` has no EP support.\n- Before finishing an MoE EP answer, explicitly state that `ep_size` must divide `dp_size * cp_size` and that `megatron_fsdp` does not support EP, PP, or `sequence_parallel`.\n\n## YAML Config Structure\n\nThe `distributed` section in the recipe YAML maps directly to\n`parse_distributed_section()` in `recipes\u002F_dist_utils.py`:\n\n```yaml\ndistributed:\n  strategy: fsdp2           # fsdp2 | megatron_fsdp | ddp\n  dp_size: none             # auto-calculated from world_size \u002F (tp * pp * cp)\n  dp_replicate_size: none   # FSDP2-only, for HSDP\n  tp_size: 1\n  pp_size: 1\n  cp_size: 1\n  ep_size: 1\n\n  # Strategy-specific flags (forwarded to the strategy dataclass):\n  sequence_parallel: false\n  activation_checkpointing: false\n  defer_fsdp_grad_sync: true   # FSDP2 only\n\n  # Sub-configs (optional):\n  pipeline:\n    pp_schedule: 1f1b\n    pp_microbatch_size: 1\n    # ... see PipelineConfig fields\n\n  moe:\n    reshard_after_forward: false\n    # ... see MoEParallelizerConfig fields\n```\n\nThe `dp_size` is always inferred:\n\n```\ndp_size = world_size \u002F (tp_size * pp_size * cp_size)\n```\n\n## Infrastructure Flow\n\n```\ninitialize_distributed()                       [components\u002Fdistributed\u002Finit_utils.py]\n    -> initializes torch.distributed process group and returns DistInfo\nYAML distributed section + DistInfo.world_size\n    -> parse_distributed_section()          [recipes\u002F_dist_utils.py]\n    -> create_distributed_setup_from_config()              [recipes\u002F_dist_utils.py]\n        -> DistributedSetup.build()         [components\u002Fdistributed\u002Fconfig.py]\n    -> instantiate_infrastructure()         [_transformers\u002Finfrastructure.py]\n        -> _instantiate_distributed()       -> FSDP2Manager \u002F MegatronFSDPManager \u002F DDPManager\n        -> _instantiate_pipeline()          -> AutoPipeline (if pp_size > 1)\n        -> parallelize_fn                   -> MoE parallelizer (if ep_size > 1) or PP wrapper\n    -> apply_model_infrastructure()         [_transformers\u002Finfrastructure.py]\n        -> _shard_pp() or _shard_ep_fsdp()  (applies sharding to the model)\n```\n\n## FSDP2 Configuration\n\n### Basic FSDP2 (data parallelism only)\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  tp_size: 1\n  cp_size: 1\n```\n\nThis auto-calculates `dp_size = world_size` and applies `fully_shard()` per\ntransformer block via DTensor-based sharding.\n\n### FSDP2 with Tensor Parallelism\n\nKeep TP within a single NVLink domain (typically one node):\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  tp_size: 4        # 2, 4, or 8 -- must divide GPUs per node\n  sequence_parallel: true\n```\n\nThe TP plan is auto-selected based on the model type. Pass a custom plan via\nthe Python API if needed:\n\n```python\nconfig = FSDP2Config(sequence_parallel=True, tp_plan=my_custom_plan)\n```\n\n### FSDP2 with Pipeline Parallelism\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  pp_size: 2\n  pipeline:\n    pp_schedule: interleaved1f1b   # 1f1b, gpipe, interleaved_1f1b, etc.\n    pp_microbatch_size: 4\n    scale_grads_in_schedule: false\n```\n\nThe model must have a `_pp_plan` attribute (set on the HF model class) for\n`AutoPipeline` to know how to split layers across stages. Models without\n`_pp_plan` are not compatible with PP.\n\n### FSDP2 with HSDP (Hybrid Sharded Data Parallel)\n\nIntra-node full sharding + inter-node replication via a 2D DeviceMesh:\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  dp_replicate_size: 2   # must divide dp_size\n```\n\nConstraint: `dp_replicate_size \u003C dp_size` (pure replication with no sharding\nis not supported by FSDP2).\n\n### Activation Checkpointing\n\nTrades compute for memory by recomputing activations during backward:\n\n```yaml\ndistributed:\n  activation_checkpointing: true\n```\n\nThis is a model-build\u002Ftraining behavior flag, not mesh topology. Dense\nstrategies read it from the strategy config; EP\u002FMoE paths pass the recipe-level\nflag directly into model infrastructure.\n\n### Gradient Sync Deferral\n\nFSDP2 defers gradient sync to the final micro-batch by default for\ncommunication overlap:\n\n```yaml\ndistributed:\n  defer_fsdp_grad_sync: true   # default\n```\n\n### Mixed Precision\n\nFSDP2Config defaults to bfloat16 for all three precision knobs via\n`MixedPrecisionPolicy(param_dtype=bf16, reduce_dtype=bf16, output_dtype=bf16,\ncast_forward_inputs=True)`. Override via the Python API:\n\n```python\nfrom torch.distributed.fsdp import MixedPrecisionPolicy\nconfig = FSDP2Config(\n    mp_policy=MixedPrecisionPolicy(param_dtype=torch.float16, reduce_dtype=torch.float32),\n)\n```\n\n## Pipeline Parallelism\n\n### Requirements\n\n1. Model class must define `_pp_plan` (a dict mapping module FQNs to stages).\n2. `pp_size > 1` in the distributed section.\n3. A `pipeline` sub-config with schedule and microbatch size.\n\n### Supported schedules\n\nDefined in `PipelineConfig.pp_schedule`:\n\n- `1f1b` (one-forward-one-backward, default)\n- `gpipe`\n- `interleaved_1f1b` \u002F `interleaved1f1b`\n- `looped_bfs`\n- `dfs`\n- `v_schedule`\n- `zero_bubble`\n\n### Example (8B model on 8 GPUs, PP=2 + DP=4)\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  pp_size: 2\n\n  pipeline:\n    pp_schedule: interleaved1f1b\n    pp_microbatch_size: 4\n    scale_grads_in_schedule: false\n\ncheckpoint:\n  model_save_format: safetensors\n  save_consolidated: final\n```\n\n### How it works\n\n`AutoPipeline.build()` calls `pipeline_model()` which splits the model into\nstages using the model's `_pp_plan`, creates `PipelineStage` objects, and\nbuilds the schedule. During training, `schedule.step()` drives forward and\nbackward through the pipeline.\n\n## Context Parallelism\n\nUse CP for long sequences (8K+). CP shards Q\u002FK\u002FV on the sequence dimension\nas DTensors.\n\n### Config\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  cp_size: 2   # or 4, 8\n```\n\n### Requirements\n\n- SDPA (Flash Attention or Efficient Attention backend) or Transformer Engine\n  attention. SDPBackend.MATH is not compatible with DTensor.\n- Attention masks are automatically stripped; `is_causal=True` is set via\n  forward pre-hooks registered by `attach_context_parallel_hooks()`.\n\n### How it works\n\n1. After model sharding, `apply_model_infrastructure()` calls\n   `attach_context_parallel_hooks()` on each model part (for non-TE models).\n2. At each training step, `make_cp_batch_and_ctx()` creates a CP context\n   manager that shards the batch along the sequence dimension and sets up\n   `context_parallel()` from `torch.distributed.tensor.experimental`.\n3. For TE attention models, `make_cp_batch_for_te()` uses THD format and\n   TE's `thd_get_partitioned_indices` for sharding.\n\n### CP with Sequence Packing\n\nCP works with packed sequences. The `packed_sequence_size` must be divisible\nby `cp_size`. When using TE, chunks are sharded per-chunk via\n`_shard_thd_chunk_for_te()`.\n\n## Sequence Packing\n\nPacking multiple sequences into a single training sample for efficiency.\n\n### Config\n\n```yaml\npacked_sequence:\n  packed_sequence_size: 4096   # 0 = disabled\n\nstep_scheduler:\n  local_batch_size: 1          # must be 1 for packed sequences\n```\n\nWhen `packed_sequence_size > 0`, the dataset collator packs sequences up to\nthat length. `local_batch_size` must be 1 because each \"sample\" is already a\npacked batch.\n\n## MoE Distributed Training\n\n### Expert Parallelism\n\nSet `ep_size > 1` to distribute experts across GPUs. This creates a separate\n`moe_mesh` alongside the main `device_mesh`:\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  ep_size: 8\n  activation_checkpointing: true\n```\n\nThe `moe_mesh` shape is `(pp_size, ep_shard_size, ep_size)` with dimension\nnames `(\"pp\", \"ep_shard\", \"ep\")`.\n\nConstraint: `dp_cp_size` (= `dp_size * cp_size`) must be divisible by\n`ep_size`.\n\n### MoE sub-config\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  ep_size: 8\n  activation_checkpointing: true\n\n  moe:\n    reshard_after_forward: false\n    ignore_router_for_ac: false\n    wrap_outer_model: true\n```\n\nThe `moe` sub-section maps to `MoEParallelizerConfig` and is only\ninstantiated when `ep_size > 1`.\n\n### Full MoE example (Qwen3-30B-A3B on 8 GPUs)\n\n```yaml\ndistributed:\n  strategy: fsdp2\n  tp_size: 1\n  cp_size: 1\n  pp_size: 1\n  ep_size: 8\n  sequence_parallel: false\n  activation_checkpointing: true\n```\n\n### MegatronFSDP limitations\n\nDespite its name, `megatron_fsdp` does **not** support expert parallelism\n(`ep_size > 1`), pipeline parallelism (`pp_size > 1`), or\n`sequence_parallel`. Use `fsdp2` for these features.\n\n## Parallelism Sizing Guidelines\n\n### Dense models\n\n| Model size | TP | PP | CP | Strategy |\n|---|---|---|---|---|\n| \u003C 3B | 1 | 1 | 1 | FSDP2 (DP only) |\n| 3-13B | 2-4 | 1 | 1 | FSDP2 + TP |\n| 13-70B | 4-8 | 2-4 | 1 | FSDP2 + TP + PP |\n| 70B+ | 8 | 4-8 | 1 | FSDP2 + TP + PP |\n| Any + long seq (8K+) | as above | as above | 2-8 | add CP |\n\n### MoE models\n\nMoE models need less TP than dense models of similar total parameter count\nbecause only a fraction of parameters are active per token. EP is the primary\nscaling dimension:\n\n| Model | TP | PP | EP | Notes |\n|---|---|---|---|---|\n| Small MoE (\u003C10B total) | 1 | 1 | 8 | EP only |\n| Medium MoE (10-30B total) | 1-2 | 1 | 8 | small TP for shared layers |\n| Large MoE (100B+ total) | 1-2 | 4+ | 8-64 | PP for depth, EP for experts |\n\n### Hardware topology rules\n\n- TP must stay within a single NVLink domain (one node, typically 8 GPUs).\n- Use PP or DP for cross-node scaling.\n- TP across InfiniBand degrades throughput severely.\n\n## Programmatic API (from_pretrained \u002F from_config)\n\nWhen not using YAML recipes, configure distributed training via Python:\n\n```python\nfrom nemo_automodel.components.distributed import (\n    DistributedSetup,\n    FSDP2Config,\n    ParallelismSizes,\n    initialize_distributed,\n)\n\ndist_env = initialize_distributed(\"nccl\")\ndistributed_setup = DistributedSetup.build(\n    strategy=FSDP2Config(sequence_parallel=True),\n    parallelism_sizes=ParallelismSizes(tp_size=2),\n    activation_checkpointing=True,\n    world_size=dist_env.world_size,\n)\n```\n\nOr pass directly to `from_pretrained`:\n\n```python\nfrom nemo_automodel import NeMoAutoModelForCausalLM\n\nmodel = NeMoAutoModelForCausalLM.from_pretrained(\n    \"meta-llama\u002FLlama-3.2-1B\",\n    distributed_setup=distributed_setup,\n)\n```\n\n## Code Anchors\n\nStrategy config dataclasses:\n\n```\ncomponents\u002Fdistributed\u002Fconfig.py\n    FSDP2Config       -- sequence_parallel, tp_plan, mp_policy, offload_policy,\n                         activation_checkpointing, defer_fsdp_grad_sync\n    MegatronFSDPConfig -- zero_dp_strategy, overlap_grad_reduce, overlap_param_gather, etc.\n    DDPConfig          -- activation_checkpointing only\n```\n\nMeshContext (single source of truth for parallelism):\n\n```\ncomponents\u002Fdistributed\u002Fmesh.py\n    MeshContext  -- device_mesh, moe_mesh\n                    Properties: tp_size, pp_size, cp_size, ep_size, dp_size, dp_replicate_size\n    MeshAxisName -- PP, DP, DP_REPLICATE, DP_SHARD, DP_SHARD_CP, DP_CP, CP, TP, EP, EP_SHARD\n```\n\nMesh context and raw mesh creation:\n\n```\ncomponents\u002Fdistributed\u002Fconfig.py\n    DistributedSetup.build()      -- builds MeshContext from strategy + parallelism\ncomponents\u002Fdistributed\u002Fmesh_utils.py\n    _create_device_meshes()       -- routes to FSDP2\u002FMegatronFSDP\u002FDDP raw mesh creation\n    _create_fsdp2_device_mesh()   -- shape (pp, dp_replicate, dp_shard, cp, tp) + flattened submeshes\n    _create_megatron_fsdp_device_mesh() -- shape (dp, cp, tp)\n```\n\nDistributed managers:\n\n```\ncomponents\u002Fdistributed\u002Ffsdp2.py          -- FSDP2Manager.parallelize()\ncomponents\u002Fdistributed\u002Fmegatron_fsdp.py  -- MegatronFSDPManager.parallelize()\ncomponents\u002Fdistributed\u002Fddp.py            -- DDPManager\n```\n\nPipeline parallelism:\n\n```\ncomponents\u002Fdistributed\u002Fpipelining\u002Fconfig.py        -- PipelineConfig dataclass\ncomponents\u002Fdistributed\u002Fpipelining\u002Fautopipeline.py  -- AutoPipeline orchestrator\ncomponents\u002Fdistributed\u002Fpipelining\u002Ffunctional.py    -- pipeline_model(), schedule creation\ncomponents\u002Fdistributed\u002Fpipelining\u002Fhf_utils.py      -- HF model validation for PP\n```\n\nContext parallelism:\n\n```\ncomponents\u002Fdistributed\u002Fcp_utils.py\n    make_cp_batch_and_ctx()            -- creates CP context manager + shards batch\n    create_context_parallel_ctx()      -- wraps torch.distributed.tensor.experimental.context_parallel\n    attach_context_parallel_hooks()    -- strips attention_mask, sets is_causal=True\n    make_cp_batch_for_te()             -- TE-specific CP batch sharding (THD format)\n```\n\nInfrastructure orchestration:\n\n```\n_transformers\u002Finfrastructure.py\n    instantiate_infrastructure()    -- config objects -> runtime objects\n    apply_model_infrastructure()    -- applies sharding, PEFT, checkpoints to model\n    _shard_pp()                     -- pipeline parallel path\n    _shard_ep_fsdp()                -- EP + FSDP path (non-PP)\n```\n\nYAML parsing:\n\n```\nrecipes\u002F_dist_utils.py\n    parse_distributed_section()  -- YAML dict -> typed configs + sizes\n    create_distributed_setup_from_config()  -- recipe adapter: parse + create DistributedSetup; does not init process group\n```\n\nMoE config:\n\n```\ncomponents\u002Fdistributed\u002Fconfig.py\n    MoEParallelizerConfig  -- reshard_after_forward, ignore_router_for_ac, wrap_outer_model, etc.\ncomponents\u002Fmoe\u002Fconfig.py\n    MoEConfig              -- n_routed_experts, n_activated_experts, score_func, etc.\n```\n\n## Pitfalls\n\n1. **TP across nodes destroys throughput.** Always keep TP within a single\n   NVLink domain. Use PP or DP for cross-node scaling.\n\n2. **PP requires `_pp_plan` on the model class.** Not all HF models have this.\n   Check `validate_hf_model_for_pipeline_support()` before enabling PP.\n\n3. **PP bubbles reduce GPU utilization.** Use interleaved schedules\n   (`interleaved_1f1b`) and smaller microbatches to reduce bubble time.\n\n4. **FSDP2 requires DTensor-aware state dict saving.** Use `safetensors` with\n   `save_consolidated: final` for final HF export, or `save_consolidated: false`\n   plus the generated `model\u002Fconsolidate.sh` helper for offline export.\n\n5. **CP requires compatible attention.** SDPA (Flash Attention or Efficient\n   Attention) or TE attention only. `SDPBackend.MATH` is not compatible with\n   DTensor.\n\n6. **MoE EP size must evenly divide `dp_size * cp_size`.** The device mesh\n   creation asserts `dp_cp_size % ep_size == 0`.\n\n7. **MegatronFSDP is more limited than FSDP2.** It does not support PP\n   (`pp_size > 1`), EP (`ep_size > 1`), or `sequence_parallel`. The\n   `MeshContext` validation raises on these combinations.\n\n8. **DDP supports nothing beyond data parallelism.** No TP, PP, CP, EP, or\n   HSDP. Validation raises on any of these.\n\n9. **Activation checkpointing increases compute.** It saves memory by\n   recomputing activations during backward, but adds ~30% compute overhead.\n\n10. **Mixed precision policy must match model expectations.** The default\n    bfloat16 policy works for most models. FP16 models may need a custom\n    `MixedPrecisionPolicy`.\n\n11. **`packed_sequence_size` must be divisible by `cp_size`** when using CP\n    with packed sequences.\n\n12. **`dp_replicate_size` is FSDP2-only.** Passing it with `megatron_fsdp`\n    or `ddp` raises a `ValueError`.\n\n## Verification\n\nRun the smallest recipe that exercises the requested strategy. Success means\nexit code 0, finite loss, no NCCL timeout, and log output matching the expected\nTP\u002FPP\u002FCP\u002FEP sizes.\n",{"name":5,"license":15,"metadata":24,"description":7,"when_to_use":29},{"tags":25,"author":28},[26,27],"nemo-automodel","distributed-training","NVIDIA","Adding or modifying distributed training strategies (FSDP2, HSDP, DDP), debugging multi-GPU or multi-node failures, configuring context or tensor parallelism, or tuning sharding settings.","main","8859218955d9504cd18b59e7892100718039d3b4","data\u002Fskills\u002Fnvidia-skills\u002Fnemo-automodel-distributed-training\u002Fskills\u002Fnemo-automodel-distributed-training",1,"https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper","https:\u002F\u002Fgithub.com\u002Fom-scogo","SDE-1 @ Scogo ","2026-07-18 12:22:46",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add om-scogo\u002Fskillsh-scraper --skill nemo-automodel-distributed-training",{"tool":44,"command":45},"bunx","bunx skills add om-scogo\u002Fskillsh-scraper --skill nemo-automodel-distributed-training",{"tool":47,"command":48},"pnpm","pnpm dlx skills add om-scogo\u002Fskillsh-scraper --skill nemo-automodel-distributed-training","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fnvidia-skills\u002Fnemo-automodel-distributed-training\u002Fskills\u002Fnemo-automodel-distributed-training\u002FSKILL.md",true,[],[53,61,66,73,78,85],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7D6MC9FAAEV4CMNYX8W7JTG","arxiv-search","Search arXiv physics, math, and computer science preprints using natural language queries. Powered by Valyu semantic search.","MIT","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002Fskills\u002Farxiv-search\u002FSKILL.md",[],[],{"skillNo":62,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7D6M85CKKN87TA98VCQV4H7","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fyorkeccak-scientific-skills\u002Farxiv-search\u002FSkill.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7D4ZTCS4DR3CE4JY06X84T2","working-with-legacy-code","Safely change and test untested codebases using Feathers' \"Working Effectively with Legacy Code\". Use when the user mentions \"legacy code\", \"no tests\", \"untested codebase\", \"how do I test this\", \"seams\", \"characterization tests\", \"golden master\", \"sprout method\", \"afraid to change this code\", \"monster method\", \"dependency breaking\", or \"inherited a messy codebase\". Also trigger when changing code without tests safely, getting a class under test when constructors, statics, or singletons block it, adding features to tangled modules, or planning incremental test coverage for an old codebase. Covers the legacy-code change algorithm, seams, characterization tests, sprout\u002Fwrap, and dependency-breaking techniques. For refactoring code that already has tests, see refactoring-patterns. For day-to-day code quality, see clean-code.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002Fworking-with-legacy-code\u002FSKILL.md",[],[],{"skillNo":74,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7D4ZHZKJD2RSNGAF63V14P4","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fworking-with-legacy-code\u002FSkill.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7D4ZB4CJBFW5JE67CPH2QRV","web-typography","Select, pair, and implement typefaces for web projects. Use when the user mentions \"font pairing\", \"which typeface\", \"line height\", \"responsive typography\", \"web font loading\", \"type hierarchy\", \"variable fonts\", \"FOUT\u002FFOIT\", \"typographic scale\", or \"the text is hard to read\". Also trigger when choosing between system fonts and web fonts, optimizing font-loading performance, or designing readable long-form content. Covers readability evaluation, CSS implementation, and performance optimization. For overall UI design systems, see refactoring-ui. For dramatic typographic experiences, see top-design.","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002Fweb-typography\u002FSKILL.md",[],[],{"skillNo":86,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7D4Z4MVYVY3NMJ18BNV6WNA","https:\u002F\u002Fgithub.com\u002Fom-scogo\u002Fskillsh-scraper\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwondelai-skills\u002Fweb-typography\u002FSkill.md",[],[]]