torch-pipeline-parallelism

Implement PyTorch pipeline parallelism with AFAB and 1F1B scheduling.

134|21|Updated Nov 12, 2025
One-click install
npx skills add https://github.com/letta-ai/skills --skill torch-pipeline-parallelism
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: torch-pipeline-parallelism
Source: https://github.com/letta-ai/skills/tree/main/ai/benchmarks/letta/terminal-bench-2/trajectory-only/torch-pipeline-parallelism
Command: npx skills add https://github.com/letta-ai/skills --skill torch-pipeline-parallelism

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides guidance for implementing PyTorch pipeline parallelism for distributed training of large language models. It covers model partitioning, inter-rank communication, gradient flow management, and common pitfalls.

Core Features & Use Cases

  • Model partitioning: Split transformer layers across ranks.
  • Inter-rank communication: Send/recv and activation caching.
  • Gradient flow management: AFAB scheduling, loss scaling, and backward synchronization.

Quick Start

Implement a 3-stage pipeline across 4 GPUs and validate gradient flow.

Frequently Asked Questions about torch-pipeline-parallelism

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

FAQPage Schema
How do I implement pipeline parallelism to scale PyTorch distributed training?

Pipeline parallelism splits transformer layers across multiple GPUs and coordinates forward and backward passes using scheduling strategies like AFAB (All-Forward-All-Backward) and 1F1B. This approach reduces per-GPU memory requirements and enables training of larger models by distributing computation across ranks while maintaining gradient flow and synchronization.

What's the best way to partition a transformer model across multiple ranks?

Model partitioning assigns consecutive transformer layers to different ranks based on your pipeline depth and GPU count. Define clear boundaries between stages, handle activation caching at partition points, and use explicit shape tracking across devices to ensure tensors maintain correct dimensions during inter-rank communication.

How do I manage gradient flow and synchronization in a distributed PyTorch pipeline?

Maintain gradient flow by coordinating backward passes across ranks using AFAB or 1F1B scheduling, applying loss scaling to prevent gradient underflow, and synchronizing gradient updates between pipeline stages. Use torch.distributed P2P operations (send/recv) to exchange activations and gradients while preserving computation order.

Can I use pipeline parallelism with PyTorch's distributed communication primitives?

Yes, pipeline parallelism uses torch.distributed P2P operations like send and recv for direct communication between ranks. This enables fine-grained control over activation and gradient exchange without requiring collective operations, making it suitable for non-homogeneous pipeline topologies and custom scheduling strategies.

What are common pitfalls when implementing PyTorch pipeline parallelism?

Common issues include incorrect activation caching leading to stale gradients, shape mismatches during inter-rank communication, loss of gradient synchronization between stages, and inefficient scheduling causing pipeline bubbles. Explicit shape handling, careful verification of gradient flow, and rigorous testing across all ranks prevent these failures.