Skip to content

Migrate the test script to use to_maxtext.py for supported models#4541

Open
AusarYao28 wants to merge 1 commit into
mainfrom
yaoyuchen-test
Open

Migrate the test script to use to_maxtext.py for supported models#4541
AusarYao28 wants to merge 1 commit into
mainfrom
yaoyuchen-test

Conversation

@AusarYao28

@AusarYao28 AusarYao28 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Description

Migrated test script for Deepseek2-16b, gpt-oss-20b, and Mixtral8x7b

FIXES: b/534808841

Tests

I've run each test script and compared its output before and after change, deepseekv2 test script fails with the same error message before and after change (checkpoint conversion script passed but forward pass failed)

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.

@google-cla

google-cla Bot commented Jul 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Migrated test script for Deepseek2-16b, gpt-oss-20b, and Mixtral8x7b

@aireenmei aireenmei 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.

Could you share the test results, even it's the same error unrelated to this migration? We may want to create a bug further investigate if not already.

base_output_directory=${BASE_OUTPUT_PATH}/scanned \
scan_layers=true \
attention=dot_product \
enable_nnx=false \

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.

Have you tested enable_nnx=true (default)? We eventually want the nnx path to work since it's the future and we are migrating to it.

model_name=${MODEL_NAME} \
base_output_directory=${BASE_OUTPUT_PATH}/scanned \
scan_layers=true \
attention=dot_product \

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.

The attention type should not affect checkpoint conversion. I suggest leave it the default value to reduce noise.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Without dot attention we have error: ```
File "/home/yaoyuchen_google_com/maxtext/maxtext_venv/lib/python3.12/site-packages/jax/experimental/pallas/ops/gpu/attention.py", line 243, in mha
raise ValueError(
ValueError: This kernel expects q, k, and v to have the same head dimension, but found q.shape=(192, 2048, 16, 192), k.shape=(192, 2048, 16, 192), v.shape=(192, 2048, 16, 128).


With dot attention we have a different error: ```
Traceback (most recent call last):                                                                                                                                                                                                                                                                              
  File "<frozen runpy>", line 198, in _run_module_as_main                                                                                                                                                                                                                                                       
  File "<frozen runpy>", line 88, in _run_code                                                                                                                                                                                                                                                                  
  File "/home/yaoyuchen_google_com/maxtext/src/maxtext/checkpoint_conversion/to_maxtext.py", line 1162, in <module>                                                                                                                                                                                             
    main(                                                                                                                                                                                                                                                                                                       
  File "/home/yaoyuchen_google_com/maxtext/src/maxtext/checkpoint_conversion/to_maxtext.py", line 1003, in main                                                                                                                                                                                                 
    filtered_map_keys = validate_and_filter_param_map_keys(param_map_mt_to_hf.keys(), maxtext_abstract_dict.keys())                                                                                                                                                                                             
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                             
  File "/home/yaoyuchen_google_com/maxtext/src/maxtext/checkpoint_conversion/utils/utils.py", line 118, in validate_and_filter_param_map_keys                                                                                                                                                                   
    raise ValueError(                                                                                                                                                                                                                                                                                           
ValueError: maxtext_state_dict must be a subset of flattened param_map                                                                                                                                                                                                                                          
param map  

hardware=cpu skip_jax_distributed_system=True \
--hf_model_path=${CKPT_DISK_LOCATION} \
--lazy_load_tensors=False \
--eager_load_method='safetensors'

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.

'safetensors' is the default value, no need to specify?

enable_nnx=false \
hardware=cpu skip_jax_distributed_system=True \
--hf_model_path=${CKPT_DISK_LOCATION} \
--lazy_load_tensors=False \

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.

Have you tried the default value lazy_load_tensors=True? It minimizes RAM usage, we can always use it.

hardware=cpu skip_jax_distributed_system=True \
--hf_model_path=${CKPT_DISK_LOCATION} \
--lazy_load_tensors=False \
--eager_load_method='safetensors'

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.

Add these for Pathways compatibility:

checkpoint_storage_use_ocdbt=False
checkpoint_storage_use_zarr3=False

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.

I don't think permission change is needed? We usually run bash <script.sh> instead of directly ./script.sh

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.

We don't add golden_logits for new models to tests/assets/golden_logits any more, because it makes the repo size grow too fast. Now we have this instruction (https://github.com/AI-Hypercomputer/maxtext/pull/4541/changes#diff-af585533e794d79e01037bc09d8f4b879e8328b0a577f037579d6f2b6f45c4c4L57) in the test script. You can download the existing golden logits from gs://maxtext-test-assets/golden_data_gpt-oss-20b.jsonl and test against it.

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