perf-hierarchical-context-parallel

Configure hierarchical context parallelism for Megatron-Bridge training runs.

Updated May 23, 2026
One-click install
npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill perf-hierarchical-context-parallel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perf-hierarchical-context-parallel
Source: https://github.com/yo-steven/skills-exploration-20260522/tree/main/skills/Megatron-Bridge/perf-hierarchical-context-parallel
Command: npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill perf-hierarchical-context-parallel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you correctly enable and validate hierarchical context parallelism (HCP) in Megatron-Bridge when using cp_comm_type="a2a+p2p", preventing misconfiguration that can cause OOM, regressions, or silently broken training.

Core Features & Use Cases

  • Configuration recipe for HCP: Sets the required knobs (context_parallel_size, cp_comm_type, hierarchical_context_parallel_sizes, and Bridge PG mode) to match Megatron-LM expectations.
  • Decision-aware setup guidance: Anchors the key guidance for hierarchical CP and points you to the internal docs/card for the “why” and selection logic.
  • Pitfall prevention + verification checks: Provides concrete constraints (product and divisibility), explains common failure modes, and tells you how to verify group creation via logs.

Quick Start

Enable hierarchical context parallelism by setting model.context_parallel_size=4, model.cp_comm_type=a2a+p2p, model.hierarchical_context_parallel_sizes=[2,2], and dist.use_decentralized_pg=false, then launch a small multi-GPU run and confirm logs show HIERARCHICAL_CONTEXT_PARALLEL_GROUPS.

Frequently Asked Questions about perf-hierarchical-context-parallel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enable hierarchical context parallelism in Megatron-Bridge?

To enable hierarchical context parallelism in Megatron-Bridge, set cp_comm_type to a2a+p2p and configure hierarchical_context_parallel_sizes. You must also set dist.use_decentralized_pg to false and launch a multi-GPU run.

Why does context parallelism cause OOM or regressions after configuration changes?

Context parallelism causes OOM or regressions when hierarchical settings are misconfigured. The product of hierarchical_context_parallel_sizes must equal context_parallel_size, and sequence length must be divisible, otherwise training breaks or fails silently.

What Transformer Engine version is required for hierarchical context parallelism?

Hierarchical context parallelism requires Transformer Engine version 1.12.0 or higher. You must verify this dependency before attempting to scale context parallelism beyond KV heads using a2a+p2p communication.

How do I validate that hierarchical context parallel groups are created correctly?

To validate hierarchical context parallel groups, launch a small multi-GPU run and check the training logs. You should confirm the presence of HIERARCHICAL_CONTEXT_PARALLEL_GROUPS entries to ensure correct process-group creation.

When do I need hierarchical context parallelism for distributed training?

You need hierarchical context parallelism when scaling context parallelism beyond KV heads in distributed training. It prevents misconfiguration issues when using a2a+p2p communication types in Megatron-Bridge runs.

What constraints apply to hierarchical_context_parallel_sizes in Megatron-Bridge?

The prod of hierarchical_context_parallel_sizes must exactly equal context_parallel_size, and sequence length must be divisible. These constraints match Megatron-LM expectations and prevent OOM or broken training.