Skip to content

Use resolved mesh size for context parallel sharding - #4211

Merged
copybara-service[bot] merged 2 commits into
AI-Hypercomputer:mainfrom
huytransformer:htn/context-parallel-size-from-mesh
Jun 26, 2026
Merged

Use resolved mesh size for context parallel sharding#4211
copybara-service[bot] merged 2 commits into
AI-Hypercomputer:mainfrom
huytransformer:htn/context-parallel-size-from-mesh

Conversation

@huytransformer

Copy link
Copy Markdown
Collaborator

Description

Fixes TPU Flash/Tokamax Splash context-parallel sizing when ici_context_parallelism=-1. This PR reads the context-parallel size from the mesh in the attention path and train setup.

Tests

Ran TPU repro:

python3 -m maxtext.trainers.pre_train.train src/maxtext/configs/base.yml \
  run_name=cp_minus_one_repro \
  model_name=llama3.1-8b \
  attention=flash \
  use_tokamax_splash=true \
  ici_fsdp_parallelism=1 \
  ici_context_parallelism=-1 \
  packing=false \
  dataset_type=synthetic \
  steps=1 \
  enable_checkpointing=false

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 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/utils/train_utils.py 33.33% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@huytransformer
huytransformer force-pushed the htn/context-parallel-size-from-mesh branch from d86feae to 8ef48c9 Compare June 21, 2026 19:19
Comment thread src/maxtext/layers/attention_op.py Outdated
@huytransformer
huytransformer force-pushed the htn/context-parallel-size-from-mesh branch from 8ef48c9 to 90e1d66 Compare June 22, 2026 17:39
@huytransformer
huytransformer force-pushed the htn/context-parallel-size-from-mesh branch from 90e1d66 to c722758 Compare June 22, 2026 18:08
@huytransformer
huytransformer force-pushed the htn/context-parallel-size-from-mesh branch from 2d13dcb to 84f4110 Compare June 26, 2026 02:31
@copybara-service
copybara-service Bot merged commit 5547345 into AI-Hypercomputer:main Jun 26, 2026
37 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.

3 participants