Fix CI notebook execution and add SFT training step verification - #4878
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the SFT LLaMA 3 demo notebook for TPU by reducing the training steps from 100 to 5 and adding a verification check to ensure the expected number of training steps successfully executed. The review feedback identifies an issue with significant trailing whitespace in the newly added notebook lines, which violates PEP 8, and provides a suggestion to clean up the code.
SurbhiJainUSC
force-pushed
the
fix_ci
branch
2 times, most recently
from
August 13, 2026 19:20
9c52034 to
6bdac8f
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
SurbhiJainUSC
force-pushed
the
fix_ci
branch
10 times, most recently
from
August 14, 2026 00:03
0bc5a2e to
f461cc8
Compare
SurbhiJainUSC
marked this pull request as ready for review
August 14, 2026 00:14
SurbhiJainUSC
requested review from
RissyRan,
bvandermoon,
darisoy,
gobbleturk,
huytransformer,
igorts-git,
jiangjy1982,
jshin1394,
khatwanimohit,
liudangyi,
parambole,
richjames0,
shralex,
shuningjin and
xibinliu
as code owners
August 14, 2026 00:14
SurbhiJainUSC
requested review from
A9isha,
NuojCheng,
abhinavclemson,
aireenmei,
dipannita08,
gagika,
hengtaoguo and
vipannalla
as code owners
August 14, 2026 00:15
YixuanWang-99
approved these changes
Aug 14, 2026
dipannita08
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR hardens our Jupyter Notebook CI pipeline against silent failures, reorganizes our post-training integration tests, and includes several bug fixes for sharding specifications and gradient accumulation in the SFT trainer. It also optimizes the Jupyter notebook testing workflow (
run_jupyter_notebooks.yml) by transitioning from sequential execution of all notebooks on a single runner to dynamic matrix parallel execution. It also adds intelligent PR diff detection, ensuring that Pull Requests only run the specific notebooks that were modified.Why is this change required?
Long CI Duration: Previously, all 7 active example notebooks (src/maxtext/examples/*.ipynb) executed sequentially in a single job on a single TPU v6e-8 runner. Total execution time took 60–90+ minutes.Resource Inefficiency on PRs: A PR that only touched a single notebook (e.g. sft_qwen3_demo.ipynb) was forced to execute the entire suite of 7 notebooks sequentially.Cumulative Flakiness & Contamination: Sequential execution inside a single container accumulated checkpoint artifacts and cache files, leading to potential disk space issues or memory fragmentation.Key Changes:
Notebook CI Hardening
trainer.train_steps < config.steps) tosft_llama3_demo_tpu.ipynb,sft_qwen3_demo.ipynb, andlora_llama3_demo.ipynb. It throws aRuntimeErrorif training aborts early.absl.flags.mark_as_parsed()to the notebooks to preventUnparsedFlagAccessErrorsduring execution.run_jupyter_notebooks.ymlby removing themaxtext_installedconditional blocks.discover_notebooksjob that runsgit diff against origin/${GITHUB_BASE_REF}to identify only the.ipynbfiles that were added or modified in the PR. On Scheduled Runs / Workflow Edits: Falls back to discovering all active notebooks.{ notebook: ${{ fromJson(...) }} }withfail-fast: false. Each runner executes exactly one notebook in isolation.Test Reorganization & CI Pipelines
tests/integration/lora_e2e_nnx_test.pyinto a dedicatedtests/post_training/integration/lora_e2e_nnx_test.pyfile.ci_pipeline.yml,run_ci_tests.yml, andrun_tests_coordinator.ymlto explicitly executecpu-post-training-integrationandtpu-post-training-integrationflavors, ensuring these tests are not skipped.SFT & Core Fixes
train_sft.pyto properly handle gradient accumulation and removed the legacy inspection of Tunix'sgrad_normsignature.local_layersexceeded array dimensions. Added stripping logic insharding.py,maxtext_utils.py,lora_utils.py, andnnx_scan.py.quantizations.pyandlora_utils.pyto deleteqwix_rngsmetadata from the graph.swap_spaceargument frommaxtext_vllm_rollout.py.Tests
CI tests and verified E2E Airflow tests
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.