Skip to content

feat(laguna): support packed THD context parallelism - #3640

Open
akoumpa wants to merge 3 commits into
mainfrom
akoumpa/feat/laguna-thd-cp
Open

feat(laguna): support packed THD context parallelism#3640
akoumpa wants to merge 3 commits into
mainfrom
akoumpa/feat/laguna-thd-cp

Conversation

@akoumpa

@akoumpa akoumpa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Add native packed THD plus context-parallel training support for Laguna, including full and sliding-window attention semantics.

This is stacked on the Laguna XS 2.1 recipe PR so this diff contains only the THD/CP implementation and validation recipe.

Changelog

  • Add Laguna-native THD forward handling and CP capability declarations.
  • Route packed CP through block-diagonal SDPA while preserving document and sliding-window boundaries.
  • Preserve the framework native TE THD input sharder for CP1 baselines.
  • Extend block-diagonal CP metadata and masks for THD lengths and local attention windows.
  • Add CPU float32 logits/gradient parity coverage and CP mask/runtime tests.
  • Add an EP8 + CP2 + 1K THD Laguna XS validation recipe and update documentation.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?

Validation

  • CPU float32 packed/per-document logits and all-parameter gradient parity passed for full and sliding-window attention.
  • 48 Laguna/block-diagonal CP tests passed.
  • 104 capability and mesh-validation tests passed.
  • 27 docs/recipe coverage checks passed; 1 skipped.
  • Ruff and import-linter passed.
  • cw-dfw Slurm job 16473638: 100-step, eight-GPU EP8 + CP2 run completed.
  • W&B CP2 run: https://wandb.ai/Nemo-automodel/laguna-xs-2p1-sft/runs/905zourb
  • Train loss: 2.9746 at step 0 to 2.1269 at step 99.
  • Validation loss: 2.8546 at step 49 to 2.6684 at step 99.
  • Peak memory: 42.90 GiB.

Controlled CP1/CP2 loss parity

  • cw-dfw Slurm job 16481738: both matched 100-step runs completed on the same eight-GPU allocation.
  • Both runs use the same frozen 3,392-pack THD dataset, global batch size 8, seed, checkpoint, optimizer, and schedule. Dataset SHA-256: 6bf1bf3f0a969ad6a7120e980d0a11c452be89814396c25386962fca6d973e56.
  • All 100 per-step label-token counts match exactly.
  • CP1 W&B (native TE THD): https://wandb.ai/Nemo-automodel/laguna-xs-2p1-sft/runs/0y2cigaj
  • CP2 W&B (block-diagonal SDPA THD): https://wandb.ai/Nemo-automodel/laguna-xs-2p1-sft/runs/5rgo3ay8
  • Mean absolute loss difference: 0.00946 (0.44%); maximum: 0.02258 (0.92%, step 0); RMSE: 0.01039; Pearson r: 0.999795.
  • Step 0: CP1 2.95205, CP2 2.97463; step 99: CP1 2.10886, CP2 2.12573.
  • Peak memory: CP1 39.02 GiB; CP2 42.90 GiB.
  • The attention backend is the necessary controlled difference: TE handles packed THD at CP1, while Laguna uses block-diagonal SDPA for packed sliding-window CP2 because TE does not support that combination.

@akoumpa
akoumpa requested review from a team and jgerh as code owners August 24, 2026 04:46
@copy-pr-bot

copy-pr-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@akoumpa

akoumpa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ea7baf2

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

@akoumpa

akoumpa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

cw-dfw matched loss parity completed on Slurm job 16481738. Across 100 identical global batches, mean absolute loss difference is 0.00946 (0.44%), max is 0.02258 (0.92%), Pearson r is 0.999795, and all label-token counts match.

@akoumpa

akoumpa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a0c66d6

@akoumpa

akoumpa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Conflict repair + validation update

Rebased the two THD+CP commits onto current main after #3639 merged. The PR is now conflict-free at head 10e70902c1995fdcfcc9634137bdf7e59b11357d.

The matched cw-dfw validation remains:

Post-rebase local checks: 48 Laguna/block-diagonal CP tests passed; Ruff passed; recipe/model-coverage tests passed (5 passed, 1 skipped).

@akoumpa

akoumpa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 10e7090

@jgerh jgerh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completed tech pubs review of docs/model-coverage/llm/poolside/laguna.mdx and provided a few copyedits

Comment thread docs/model-coverage/llm/poolside/laguna.mdx Outdated
Comment thread docs/model-coverage/llm/poolside/laguna.mdx Outdated
Comment thread docs/model-coverage/llm/poolside/laguna.mdx Outdated
Co-authored-by: jgerh <163925524+jgerh@users.noreply.github.com>
@akoumpa

akoumpa commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0ee3a52

@akoumpa akoumpa closed this Aug 27, 2026
@akoumpa akoumpa reopened this Aug 27, 2026
@akoumpa

akoumpa commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 0ee3a52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants