feat: Automated Post-Conversion Checkpoint Shape and Mock Tensor Vali…#4462
Open
olufiyin19 wants to merge 1 commit into
Open
feat: Automated Post-Conversion Checkpoint Shape and Mock Tensor Vali…#4462olufiyin19 wants to merge 1 commit into
olufiyin19 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
entrpn
reviewed
Jul 14, 2026
| # build and save report | ||
| report_dir = os.path.join(os.getcwd(), "reports") | ||
| os.makedirs(report_dir, exist_ok=True) | ||
| output_path = os.path.join(report_dir, f"report_{run_name}.json") |
Collaborator
There was a problem hiding this comment.
is this report saved locally or does it need to be uploaded to gcs?
Collaborator
Author
There was a problem hiding this comment.
I've updated the report to get saved locally only if no gcs bucket is provided in the input json but to gcs otherwise
…dation for the Checkpoint Validation Agent
26bdde9 to
d601394
Compare
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.
…dation for the Checkpoint Validation Agent
Description
This PR introduces the first two phases of the automated post checkpoint conversion validation pipeline. It ensures that converted ML checkpoints (e.g. Gemma, Llama) are structurally sound and computationally viable before they are deployed to TPU clusters.
The validation is broken into two sequential subtasks:
checkpoint_shape_validator.py): Parses and compares the theoretical MaxText blueprint against the actual Orbax checkpoint layer by layer to ensure 1:1 parameter mapping.mock_tensor_test.py): Performs a dynamic, "hollow" forward pass usingjax.eval_shape. This ensures the converted weights perfectly align with the network's expected graph dimensions without requiring physical TPU memory.Key Implementation Details
check_mismatchesto support local CI unit testing without requiring temp files.test_checkpoint_shape_validator.pyto unit test the dictionary comparison logic.To enable single-pod Kubernetes execution, the following adjustments were made to the forward pass trace:
transformer_as_linenwrapper to preserve.initand.applyshape tracing.skip_jax_distributed_system=trueinto the pyconfig to allow the model to build without a TPU coordinator address.Mesh(('fsdp', 'tensor', 'sequence')) to satisfy internal sharding layout requirements inutils/sharding.py.decoder_positionsanddecoder_segment_idstensors to the__call__method, satisfying the strict positional arguments of the refactored Transformer.Tests
Verified dynamic structural tracing across four distinct architectures. The script correctly parses Airflow overrides, auto-detects Hugging Face vocab sizes, and traces abstract zero-memory geometries.
1. Llama 3.1-8b
**Airflow Trigger JSON:** ```json { "checkpoint_gcs_path": "gs://maxtext-model-checkpoints/llama3.1-8b/2025-01-23-19-04/unscanned/checkpoints/0/items", "maxtext_model_name": "llama3.1-8b", "maxtext_overrides": { "attention": "dot_product", "max_target_length": 4096, "per_device_batch_size": 4, "scan_layers": false, "tokenizer_path": "meta-llama/Llama-3.1-8B-Instruct", "tokenizer_type": "huggingface" }, "run_name": "llama-context-stress-test" } ```checkpoint_shape_validation Task Execution Log:
https://paste.googleplex.com/6204023324672000
mock_tensor_validation Task Execution Log:
https://paste.googleplex.com/4820299131518976
2. Deepseek3-671b
**Airflow Trigger JSON:** ```json { "checkpoint_gcs_path":"gs://maxtext-model-checkpoints/deepseek3-671b/0/items" "maxtext_model_name":"deepseek3-671b" "maxtext_overrides":{ "attention":"dot_product" "capacity_factor":-1 "load_balance_loss_weight":0.01 "max_target_length":1024 "per_device_batch_size":1 "scan_layers":true "sparse_matmul":true "tokenizer_path":"deepseek-ai/DeepSeek-V3" "tokenizer_type":"huggingface" } "run_name":"deepseek-moe-test" } ```checkpoint_shape_validation Task Execution Log:
https://paste.googleplex.com/5227432637497344
mock_tensor_validation Task Execution Log:
https://paste.googleplex.com/6553731624730624
3. Mistral-7b
**Airflow Trigger JSON:** ```json { "checkpoint_gcs_path":"gs://maxtext-model-checkpoints/mistral-7b/2025-01-23-19-04/unscanned/checkpoints/0/items" "maxtext_model_name":"mistral-7b" "maxtext_overrides":{ "dtype":"bfloat16" "max_target_length":256 "per_device_batch_size":1 "remat_policy":"minimal" "scan_layers":false "tokenizer_path":"mistralai/Mistral-7B-v0.1" "tokenizer_type":"huggingface" } "run_name":"mistral-7b-dense-test" } ```checkpoint_shape_validation Task Execution Log:
https://paste.googleplex.com/4872771216736256
mock_tensor_validation Task Execution Log:
https://paste.googleplex.com/6022800585392128
4. Gemma3-4b
**Airflow Trigger JSON:** ```json { "checkpoint_gcs_path":"gs://maxtext-model-checkpoints/gemma3-4b/2025-03-18-19-03/unscanned/checkpoints/0/items" "maxtext_model_name":"gemma3-4b" "maxtext_overrides":{ "max_target_length":128 "per_device_batch_size":1 "scan_layers":false "tokenizer_path":"google/gemma-3-4b-it" "tokenizer_type":"huggingface" } "run_name":"gemma3-4b-basic-test" } ```checkpoint_shape_validation Task Execution Log:
https://paste.googleplex.com/6677126723010560
mock_tensor_validation Task Execution Log:
https://paste.googleplex.com/5595861106163712
5. Qwen3-8b
**Airflow Trigger JSON:** ```json { "checkpoint_gcs_path":"gs://maxtext-model-checkpoints/qwen3-8b/unscanned/0/items" "maxtext_model_name":"qwen3-8b" "maxtext_overrides":{ "attention":"dot_product" "max_target_length":2048 "per_device_batch_size":8 "scan_layers":false "tokenizer_path":"Qwen/Qwen3-8B-Instruct" "tokenizer_type":"huggingface" } "run_name":"qwen3-custom-shape-test" } ```checkpoint_shape_validation Task Execution Log:
https://paste.googleplex.com/6621602107228160
mock_tensor_validation Task Execution Log:
https://paste.googleplex.com/5138689889009664
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.