[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79FDPG36ZFM5A2K26TAT9Q3":3,"skill-same:01M79FDPG36ZFM5A2K26TAT9Q3":69},{"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":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M79FDPG36ZFM5A2K26TAT9Q3","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.","Elogic360\u002Fsoftware-factory","Elogic360","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F156535519?v=4","01M74NH3F0RB13PWB7JZDE2V80","elogic360","01M74NH3FPC65082MDZVMFHDM3",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\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":15,"description":7,"when_to_use":24},"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","c475fc64e94e803b50d14a791dfee8853fbb2c5c","skills\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory","https:\u002F\u002Fgithub.com\u002FElogic360","2026-11-08 22:21:22",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add Elogic360\u002Fsoftware-factory --skill nemo-mbridge-perf-hierarchical-context-parallel",{"tool":37,"command":38},"bunx","bunx skills add Elogic360\u002Fsoftware-factory --skill nemo-mbridge-perf-hierarchical-context-parallel",{"tool":40,"command":41},"pnpm","pnpm dlx skills add Elogic360\u002Fsoftware-factory --skill nemo-mbridge-perf-hierarchical-context-parallel","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002FSKILL.md",true,[45,51,55,59,63],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"BENCHMARK.md","REFERENCE","参考文档",4459,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\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\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fcard.yaml",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"evals\u002Fevals.json",1579,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fevals\u002Fevals.json",{"path":60,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":61,"sourceHtmlUrl":62},"skill-card.md",3949,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fskill-card.md",{"path":64,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":67,"sourceHtmlUrl":68},"skill.oms.sig","OTHER","其他",4841,"https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnemo-mbridge-perf-hierarchical-context-parallel\u002Fskill.oms.sig",[70,77,84,91,98,105],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M79G206MT3J6S0GY3C45P2KV","vss-summarize-video","Use to summarize a recorded video via the LVS summarization microservice (HITL-gated) with a VLM fallback. Not for report generation or live RTSP captioning.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-summarize-video\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M79G1WN63PGRE8CKD47WEBQ5","vss-setup-video-analytics-api","Use to deploy the vss-video-analytics-api REST service standalone (config-source, data-log bind, Elasticsearch, optional Kafka). Not for full warehouse deploy.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-setup-video-analytics-api\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M79G1S9F7VY3EF6H53PRP5AN","vss-setup-behavior-analytics","Use to deploy the vss-behavior-analytics service standalone (entrypoint, config-source, optional calibration). Not for the full warehouse deploy.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-setup-behavior-analytics\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M79G1N1S1Y27PFZPYMNK1MTQ","vss-search-archive","Use this skill to run top-level VSS fusion search on archived video, or to ingest video files \u002F RTSP streams for search. Do NOT use for ad-hoc visual Q&A (use vss-ask-video), live captioning (use vss-deploy-dense-captioning), or video summarization and reports (use vss-summarize-video).","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-search-archive\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M79G1H6WN0Q6C0VCAXCZX6B7","vss-query-analytics","Use this skill when reading video-analytics metrics, incidents, alerts, and sensor data via the VA-MCP server (port 9901). Not for live VLM or incident-range narrative reports.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-query-analytics\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M79G1DYPNXQS7QHZ0AAF5FX5","vss-manage-video-io-storage","Use to call the VIOS REST API (sensor list, timelines, clip extraction, snapshots, add\u002Fdelete sensors and streams). Not for VLM inference or search.","https:\u002F\u002Fgithub.com\u002FElogic360\u002Fsoftware-factory\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fvss-manage-video-io-storage\u002FSKILL.md",[],[]]