sequence-packing

Manages PackedSequenceSpecs and context-parallel constraints for Megatron-Bridge long-context training.

2.8k|332|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/NVIDIA/skills --skill sequence-packing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sequence-packing
Source: https://github.com/NVIDIA/skills/tree/main/skills/Megatron-Bridge/perf-techniques/sequence-packing
Command: npx skills add https://github.com/NVIDIA/skills --skill sequence-packing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps users configure and validate packed sequence workflows in Megatron-Bridge, enabling stable long-context training by distinguishing offline packed SFT paths for LLMs from in-batch packing paths for VLMs, and applying the correct CP constraints.

Core Features & Use Cases

  • Distinguish two packing paths: offline packed SFT for LLM finetuning and in-batch packing for VLM finetuning, with aligned CP settings.
  • Provide configuration anchors and validation guidance to ensure pad lengths, sequence lengths, and mult requirements are respected during training.
  • Typical use case includes planning or debugging Megatron-Bridge training runs that require long-context sequences and context-parallelism.

Quick Start

Configure Megatron-Bridge to enable offline packed SFT for LLM finetuning or in-batch packing for VLMs, and apply the correct CP constraints.

Frequently Asked Questions about sequence-packing

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

FAQPage Schema
How do I configure packed sequences for long-context LLM finetuning in Megatron-Bridge?

To configure packed sequences for long-context LLM finetuning, use the offline packed sequence SFT path in Megatron-Bridge, ensuring proper padding and sequence length divisibility by 2 * context_parallel_size for stable training.

What is the difference between offline packed SFT and in-batch packing for VLM training?

Offline packed SFT handles long-context LLM finetuning by pre-packing sequences, while in-batch packing dynamically packs multimodal inputs for VLM finetuning, specifically requiring aligned context-parallel constraints when CP is enabled.

Why does my Megatron-Bridge training fail when context-parallelism is enabled with packed sequences?

Megatron-Bridge training fails with packed sequences if sequence lengths are not divisible by 2 * context_parallel_size or padding rules are ignored, as the PackedSequenceSpecs enforce strict divisibility constraints for CP stability.

Can I use in-batch packing for VLM finetuning without enabling context-parallel?

In-batch packing for VLM finetuning is designed for scenarios requiring context-parallelism, but you must apply the correct CP constraints and configuration keys to ensure proper sequence management and avoid training instability.

What are the sequence length requirements for Megatron-Bridge packed sequence workflows?

Megatron-Bridge packed sequence workflows require sequence lengths to be divisible by 2 * context_parallel_size, enforce proper padding rules, and mandate specific configuration keys to validate PackedSequenceSpecs during training.

When should I use sequence-packing for Megatron-Bridge models?

Use sequence-packing for Megatron-Bridge models when planning or debugging long-context training runs, specifically for LLMs with large sequence lengths or VLMs requiring in-batch packing with context-parallelism enabled.