Skip to content

Enable packing for all-gather CP - #4230

Merged
copybara-service[bot] merged 1 commit into
AI-Hypercomputer:mainfrom
huytransformer:htn/ag-packing
Jun 25, 2026
Merged

Enable packing for all-gather CP#4230
copybara-service[bot] merged 1 commit into
AI-Hypercomputer:mainfrom
huytransformer:htn/ag-packing

Conversation

@huytransformer

@huytransformer huytransformer commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Description

Previously, packed CP training was rejected unless context_parallel_strategy="ring". The all-gather CP already has segment IDs and positions via the packed data, and TPU Flash attention already uses Q sharded over context with K/V gathered for attention.

b/525146921

Tests

Ran TPU unit test:

pytest tests/unit/attention_test.py::AttentionTest::test_tpu_flash_attention_packed_all_gather_context_parallel

Checklist

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/utils/train_utils.py 20.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@richjames0 richjames0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm with nit

Comment thread src/maxtext/utils/train_utils.py Outdated
Comment thread src/maxtext/utils/train_utils.py Outdated
Comment thread tests/unit/attention_test.py
@copybara-service
copybara-service Bot merged commit a9963bc into AI-Hypercomputer:main Jun 25, 2026
64 of 65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants