[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78J3MHQQTKECDMJZXNV9J0H":3,"skill-same:01M78J3MHQQTKECDMJZXNV9J0H":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":13,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M78J3MHQQTKECDMJZXNV9J0H","nemo-mbridge-perf-hierarchical-context-parallel",null,"Operational guide for enabling hierarchical context parallelism in Megatron-Bridge, including config knobs, code anchors, pitfalls, and verification.","matheussluzz\u002FZeuZ-Agent","matheussluzz","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F209255758?v=4","01M78HKHH1D1ASC9KC9BG583DH","01M78HKHHP6W7XRXQM2SBCAM3R",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: nemo-mbridge-perf-hierarchical-context-parallel\ndescription: Operational guide for enabling hierarchical context parallelism in Megatron-Bridge, including config knobs, code anchors, pitfalls, and verification.\nlicense: Apache-2.0\nwhen_to_use: Scaling context parallelism beyond KV heads, or investigating a commit that changed CP config and caused OOM or a regression; 'hierarchical_context_parallel_sizes', 'a2a+p2p', 'hierarchical CP', 'CP beyond KV heads', 'multi-level CP'.\n---\n\n# Hierarchical Context Parallel Skill\n\nThis skill covers hierarchical context parallelism: nested context-parallel process\ngroups used by `cp_comm_type=\"a2a+p2p\"` and configured with\n`hierarchical_context_parallel_sizes`.\n\nFor what hierarchical CP is, when to use it, and the decision tree\n(`a2a+p2p` vs pure `a2a` vs `p2p`), see:\n\n- @docs\u002Ftraining\u002Fhierarchical-context-parallel.md\n- @skills\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fcard.yaml\n\n## Enablement\n\nMinimal Bridge override:\n\n```python\ncfg.model.context_parallel_size = 4\ncfg.model.cp_comm_type = \"a2a+p2p\"\ncfg.model.hierarchical_context_parallel_sizes = [2, 2]\ncfg.dist.use_decentralized_pg = False\n```\n\nRequired constraints:\n\n- `prod(hierarchical_context_parallel_sizes) == context_parallel_size`\n- `seq_length % (2 * context_parallel_size) == 0`\n- Transformer Engine `>= 1.12.0`\n\n## Code Anchors\n\nUpstream config and validation:\n\n```45:54:3rdparty\u002FMegatron-LM\u002Fmegatron\u002Fcore\u002Fmodel_parallel_config.py\ncontext_parallel_size: int = 1\n\"\"\"Splits network input along sequence dimension across GPU ranks.\"\"\"\n\nhierarchical_context_parallel_sizes: Optional[list[int]] = None\n\"\"\"Degrees of the hierarchical context parallelism. Users should provide a list to specify \n   the sizes for different levels. Taking the a2a+p2p cp comm type as example, it contains\n   groups of two levels, so the first value of the list indicates the group size of the a2a\n   communication type, and the second value indicates the group size of the p2p communication\n   type.\n\"\"\"\n```\n\n```428:433:3rdparty\u002FMegatron-LM\u002Fmegatron\u002Ftraining\u002Farguments.py\nif args.hierarchical_context_parallel_sizes:\n    from numpy import prod\n    assert args.context_parallel_size == prod(args.hierarchical_context_parallel_sizes)\nif \"a2a+p2p\" in args.cp_comm_type:\n    assert args.hierarchical_context_parallel_sizes is not None, \\\n    \"--hierarchical-context-parallel-sizes must be set when a2a+p2p is used in cp comm\"\n```\n\nBridge MPU path:\n\n```613:648:src\u002Fmegatron\u002Fbridge\u002Ftraining\u002Finitialize.py\nparallel_state.initialize_model_parallel(\n    ...\n    context_parallel_size=model_config.context_parallel_size,\n    hierarchical_context_parallel_sizes=model_config.hierarchical_context_parallel_sizes,\n    ...\n)\n...\nreturn ProcessGroupCollection.use_mpu_process_groups()\n```\n\nBridge decentralized-PG path:\n\n```503:524:src\u002Fmegatron\u002Fbridge\u002Ftraining\u002Finitialize.py\npg_collection = ProcessGroupCollection(\n    ...\n    cp=cp_pg,\n    tp_cp=tp_cp_pg,\n    hcp=None,\n    ep=ep_pg,\n    ...\n)\n```\n\n## Implementation Map\n\nThe code anchors above show the config declarations and argument validation.\n\n### Validation (MCore)\n\n`TransformerConfig.__post_init__` enforces that `a2a+p2p` requires HCP sizes and the product matches CP.\n\n### Process group creation\n\n`parallel_state.initialize_model_parallel` creates hierarchical CP sub-groups\nwhen HCP sizes are provided via `create_hierarchical_groups`. Bridge currently\ngets those groups through the MPU-backed `ProcessGroupCollection`.\n\n### TE integration\n\n`TEDotProductAttention` passes the hierarchical groups to Transformer Engine\nwhen `a2a+p2p` is used. Requires **Transformer Engine >= 1.12.0**.\n\n## Pitfalls\n\n1. **Bridge HCP is MPU-only today**: If `use_decentralized_pg=True`, Bridge initializes flat CP groups and leaves HCP unset.\n2. **No checked-in Bridge recipe** currently exercises HCP directly.\n3. **Single-GPU load helpers** clear `hierarchical_context_parallel_sizes`.\n4. **Silent broken training on old stacks**: If you use `a2a+p2p` without setting `hierarchical_context_parallel_sizes`, MCore now asserts. Older versions would silently disable CP communication, so each rank attended only to its local chunk and produced artificially high throughput with broken gradients.\n5. **Product must match**: `prod(hierarchical_context_parallel_sizes)` must exactly equal `context_parallel_size`. A mismatch triggers an assertion.\n6. **Verify in logs**: Look for the process group initialization output. You should see `HIERARCHICAL_CONTEXT_PARALLEL_GROUPS` being created. If you only see `CONTEXT_PARALLEL_GROUP`, HCP is not active.\n\n## Verification\n\nNo dedicated Bridge end-to-end test exists yet for HCP (see @skills\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fcard.yaml\n`follow_up_validation`). Use the existing unit tests and log inspection instead.\n\nRun the decentralized-PG unit test to confirm the flat-CP behavior is preserved:\n\n```bash\nuv run python -m pytest tests\u002Funit_tests\u002Ftraining\u002Ftest_decentralized_pg.py -q\n```\n\nFor a manual smoke check, launch a 4-GPU run with a small recipe and\n`cp_comm_type=a2a+p2p` plus `hierarchical_context_parallel_sizes=[2,2]`:\n\n```bash\nCUDA_VISIBLE_DEVICES=0,1,2,3 uv run python -m torch.distributed.run --nproc_per_node=4 \\\n  scripts\u002Ftraining\u002Frun_recipe.py \\\n  --recipe llama32_1b_pretrain_config \\\n  model.context_parallel_size=4 \\\n  model.cp_comm_type=a2a+p2p \\\n  \"model.hierarchical_context_parallel_sizes=[2,2]\" \\\n  train.train_iters=2\n```\n\nSuccess criteria:\n\n- Logs show `HIERARCHICAL_CONTEXT_PARALLEL_GROUPS` being created\n- Training completes at least one step without error\n- If you only see `CONTEXT_PARALLEL_GROUP`, HCP is not active\n","# Hierarchical Context Parallel Skill\n\nThis skill covers hierarchical context parallelism: nested context-parallel process\ngroups used by `cp_comm_type=\"a2a+p2p\"` and configured with\n`hierarchical_context_parallel_sizes`.\n\nFor what hierarchical CP is, when to use it, and the decision tree\n(`a2a+p2p` vs pure `a2a` vs `p2p`), see:\n\n- @docs\u002Ftraining\u002Fhierarchical-context-parallel.md\n- @skills\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fcard.yaml\n\n## Enablement\n\nMinimal Bridge override:\n\n```python\ncfg.model.context_parallel_size = 4\ncfg.model.cp_comm_type = \"a2a+p2p\"\ncfg.model.hierarchical_context_parallel_sizes = [2, 2]\ncfg.dist.use_decentralized_pg = False\n```\n\nRequired constraints:\n\n- `prod(hierarchical_context_parallel_sizes) == context_parallel_size`\n- `seq_length % (2 * context_parallel_size) == 0`\n- Transformer Engine `>= 1.12.0`\n\n## Code Anchors\n\nUpstream config and validation:\n\n```45:54:3rdparty\u002FMegatron-LM\u002Fmegatron\u002Fcore\u002Fmodel_parallel_config.py\ncontext_parallel_size: int = 1\n\"\"\"Splits network input along sequence dimension across GPU ranks.\"\"\"\n\nhierarchical_context_parallel_sizes: Optional[list[int]] = None\n\"\"\"Degrees of the hierarchical context parallelism. Users should provide a list to specify \n   the sizes for different levels. Taking the a2a+p2p cp comm type as example, it contains\n   groups of two levels, so the first value of the list indicates the group size of the a2a\n   communication type, and the second value indicates the group size of the p2p communication\n   type.\n\"\"\"\n```\n\n```428:433:3rdparty\u002FMegatron-LM\u002Fmegatron\u002Ftraining\u002Farguments.py\nif args.hierarchical_context_parallel_sizes:\n    from numpy import prod\n    assert args.context_parallel_size == prod(args.hierarchical_context_parallel_sizes)\nif \"a2a+p2p\" in args.cp_comm_type:\n    assert args.hierarchical_context_parallel_sizes is not None, \\\n    \"--hierarchical-context-parallel-sizes must be set when a2a+p2p is used in cp comm\"\n```\n\nBridge MPU path:\n\n```613:648:src\u002Fmegatron\u002Fbridge\u002Ftraining\u002Finitialize.py\nparallel_state.initialize_model_parallel(\n    ...\n    context_parallel_size=model_config.context_parallel_size,\n    hierarchical_context_parallel_sizes=model_config.hierarchical_context_parallel_sizes,\n    ...\n)\n...\nreturn ProcessGroupCollection.use_mpu_process_groups()\n```\n\nBridge decentralized-PG path:\n\n```503:524:src\u002Fmegatron\u002Fbridge\u002Ftraining\u002Finitialize.py\npg_collection = ProcessGroupCollection(\n    ...\n    cp=cp_pg,\n    tp_cp=tp_cp_pg,\n    hcp=None,\n    ep=ep_pg,\n    ...\n)\n```\n\n## Implementation Map\n\nThe code anchors above show the config declarations and argument validation.\n\n### Validation (MCore)\n\n`TransformerConfig.__post_init__` enforces that `a2a+p2p` requires HCP sizes and the product matches CP.\n\n### Process group creation\n\n`parallel_state.initialize_model_parallel` creates hierarchical CP sub-groups\nwhen HCP sizes are provided via `create_hierarchical_groups`. Bridge currently\ngets those groups through the MPU-backed `ProcessGroupCollection`.\n\n### TE integration\n\n`TEDotProductAttention` passes the hierarchical groups to Transformer Engine\nwhen `a2a+p2p` is used. Requires **Transformer Engine >= 1.12.0**.\n\n## Pitfalls\n\n1. **Bridge HCP is MPU-only today**: If `use_decentralized_pg=True`, Bridge initializes flat CP groups and leaves HCP unset.\n2. **No checked-in Bridge recipe** currently exercises HCP directly.\n3. **Single-GPU load helpers** clear `hierarchical_context_parallel_sizes`.\n4. **Silent broken training on old stacks**: If you use `a2a+p2p` without setting `hierarchical_context_parallel_sizes`, MCore now asserts. Older versions would silently disable CP communication, so each rank attended only to its local chunk and produced artificially high throughput with broken gradients.\n5. **Product must match**: `prod(hierarchical_context_parallel_sizes)` must exactly equal `context_parallel_size`. A mismatch triggers an assertion.\n6. **Verify in logs**: Look for the process group initialization output. You should see `HIERARCHICAL_CONTEXT_PARALLEL_GROUPS` being created. If you only see `CONTEXT_PARALLEL_GROUP`, HCP is not active.\n\n## Verification\n\nNo dedicated Bridge end-to-end test exists yet for HCP (see @skills\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fcard.yaml\n`follow_up_validation`). Use the existing unit tests and log inspection instead.\n\nRun the decentralized-PG unit test to confirm the flat-CP behavior is preserved:\n\n```bash\nuv run python -m pytest tests\u002Funit_tests\u002Ftraining\u002Ftest_decentralized_pg.py -q\n```\n\nFor a manual smoke check, launch a 4-GPU run with a small recipe and\n`cp_comm_type=a2a+p2p` plus `hierarchical_context_parallel_sizes=[2,2]`:\n\n```bash\nCUDA_VISIBLE_DEVICES=0,1,2,3 uv run python -m torch.distributed.run --nproc_per_node=4 \\\n  scripts\u002Ftraining\u002Frun_recipe.py \\\n  --recipe llama32_1b_pretrain_config \\\n  model.context_parallel_size=4 \\\n  model.cp_comm_type=a2a+p2p \\\n  \"model.hierarchical_context_parallel_sizes=[2,2]\" \\\n  train.train_iters=2\n```\n\nSuccess criteria:\n\n- Logs show `HIERARCHICAL_CONTEXT_PARALLEL_GROUPS` being created\n- Training completes at least one step without error\n- If you only see `CONTEXT_PARALLEL_GROUP`, HCP is not active\n",{"name":5,"license":14,"description":7,"when_to_use":23},"Scaling context parallelism beyond KV heads, or investigating a commit that changed CP config and caused OOM or a regression; 'hierarchical_context_parallel_sizes', 'a2a+p2p', 'hierarchical CP', 'CP beyond KV heads', 'multi-level CP'.","main","fc4f2c7759ae400c66cd38656db70ead882a0d08","catalog\u002Fbundles\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent#readme","https:\u002F\u002Fgithub.com\u002Fmatheussluzz","2026-08-27 05:21:51",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add matheussluzz\u002FZeuZ-Agent --skill nemo-mbridge-perf-hierarchical-context-parallel",{"tool":37,"command":38},"bunx","bunx skills add matheussluzz\u002FZeuZ-Agent --skill nemo-mbridge-perf-hierarchical-context-parallel",{"tool":40,"command":41},"pnpm","pnpm dlx skills add matheussluzz\u002FZeuZ-Agent --skill nemo-mbridge-perf-hierarchical-context-parallel","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002FSKILL.md",true,[45,51,55,59,65],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"BENCHMARK.md","REFERENCE","参考文档",4459,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002FBENCHMARK.md",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"card.yaml",2800,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fcard.yaml",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"skill-card.md",3949,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fskill-card.md",{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"skill.oms.sig","OTHER","其他",4841,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fskill.oms.sig",{"path":66,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":67,"sourceHtmlUrl":68},"zeuz.manifest.yaml",172,"https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fcatalog\u002Fbundles\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fzeuz.manifest.yaml",[70,78,85,92,99,106],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":74,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":18},"01M78JQ2R0QR8H2Z6662RFX804","gamma","Fixture skill gamma for discovery benchmarks.","MIT","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fskill-registry-mini\u002Fskills\u002Fgamma\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":74,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M78JQ1KCVZ15APZG3FFF29K0","beta","Fixture skill beta for discovery benchmarks.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fskill-registry-mini\u002Fskills\u002Fbeta\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":74,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M78JQ0FJTK4Q9JKZMX9SVSEN","alpha","Fixture skill alpha for discovery benchmarks.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Fskill-registry-mini\u002Fskills\u002Falpha\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":74,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":18},"01M78JPYVYPY7R8QS10KADQPWE","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":74,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":18},"01M78JPVYHB88RF5ATZVGX84RR","wizard","Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fskills\u002Fwizard\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":74,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":18},"01M78JPSSWNTZW89DWGJTX7716","wayfinder","Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.","https:\u002F\u002Fgithub.com\u002Fmatheussluzz\u002FZeuZ-Agent\u002Fblob\u002Fmain\u002Fskills\u002Fwayfinder\u002FSKILL.md",[],[]]