Skip to content

fix(nnx): fix gpt3 paxml checkpoint conversion state map and layout - #4555

Open
hsuan-lun-chiang wants to merge 1 commit into
mainfrom
fix/nnx-gpt3-ckpt
Open

fix(nnx): fix gpt3 paxml checkpoint conversion state map and layout#4555
hsuan-lun-chiang wants to merge 1 commit into
mainfrom
fix/nnx-gpt3-ckpt

Conversation

@hsuan-lun-chiang

@hsuan-lun-chiang hsuan-lun-chiang commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Description

Fix the Errors in b/535891456:

  1. Missing RNGs state handling in GPT-3 PaxML checkpoint conversion:
    When executing convert_gpt3_ckpt_from_paxml.py, verification failed with:
AssertionError: ['model']['decoder']['dropout']['rngs']['aqt']['count'].value not found

Cause: Recent NNX updates added dynamic RNG state (such as AQT count) into model variables, which are not present in PaxML checkpoints.

Fix: convert NNX state to linen format before doing the checkpoint conversion, when the rngs will be filtered out .

  1. On-disk NNX checkpoint layout mismatch:
    When restoring the converted checkpoint in train.py, loading failed with:
ValueError: Checkpoint does not match the model:
  - 'decoder/decoder_norm/bias': missing
  ...

Cause: convert_gpt3_ckpt_from_paxml.py was saving the raw TrainStateNNX structure directly instead of calling train_state_nnx.to_checkpoint_dict(converted_state) to format it into the standard Linen-interchangeable checkpoint layout.

Fix: Added converted_state = train_state_nnx.to_checkpoint_dict(converted_state) prior to saving when cfg.pure_nnx is active.

Test

Test with convert_gpt3_ckpt_from_paxml.py and train.py as in the DAG.
Logs

Checklist

Before submitting this PR, please make sure (put X in square brackets):

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

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/maxtext/common/checkpointing.py 50.00% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@hsuan-lun-chiang hsuan-lun-chiang changed the title fix(nnx): ignore rngs in gpt3 checkpoint conversion from paxml fix(nnx): fix gpt3 paxml checkpoint conversion state map and layout Jul 21, 2026
@hsuan-lun-chiang
hsuan-lun-chiang force-pushed the fix/nnx-gpt3-ckpt branch 4 times, most recently from bbcc873 to 05653a9 Compare July 24, 2026 03:17
@hsuan-lun-chiang
hsuan-lun-chiang marked this pull request as ready for review July 24, 2026 06:57
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@hsuan-lun-chiang
hsuan-lun-chiang force-pushed the fix/nnx-gpt3-ckpt branch 3 times, most recently from 78284b4 to 7074735 Compare July 27, 2026 09:49
Comment thread src/maxtext/common/checkpointing.py Outdated
@hsuan-lun-chiang
hsuan-lun-chiang force-pushed the fix/nnx-gpt3-ckpt branch 16 times, most recently from 2ea8719 to d078108 Compare July 28, 2026 12:14
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.

3 participants