# Description - #4314
# Description#4314
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
e1df263 to
d171b74
Compare
61da367 to
93b4298
Compare
93b4298 to
64b2708
Compare
8b89cb5 to
b7ae97e
Compare
9c513af to
833cb82
Compare
bf1b365 to
3f055d5
Compare
|
🤖 Hi @abhinavclemson, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
This pull request presents an exceptionally high-quality refactoring of MaxText's checkpointing system to primarily use the Orbax v1 API, deprecating legacy v0 implementations. The code is clean, idiomatic, and shows meticulous attention to maintaining backward compatibility and preserving standard robust semantics.
🔍 General Feedback
- Graceful Deprecations: The deprecated option
enable_orbax_v1is handled gracefully with clear warnings rather than hard failures, which ensures seamless user transitions. - Robustness in Mismatch Diagnostic: The
_weight_mismatcheslogic is highly robust, and we've proposed a small enhancement to catch structural mismatches when a dictionary is expected but a tensor is restored. - Thorough Test Coverage: Unit and integration tests have been extensively migrated and expanded to thoroughly validate the v1 checkpointer logic, including edge cases like existing steps and async saves.
| if isinstance(want, dict): | ||
| out = [] | ||
| is_quant = is_quantized_param or any(k in want for k in ("qvalue", "qarray")) |
There was a problem hiding this comment.
Adding a structural check when the model expects a dictionary but the checkpoint has a non-dict type improves the diagnostics and error messages significantly.
| if isinstance(want, dict): | |
| out = [] | |
| is_quant = is_quantized_param or any(k in want for k in ("qvalue", "qarray")) | |
| if isinstance(want, dict): | |
| if have is not None and not isinstance(have, dict): | |
| name = "/".join(str(p) for p in path) | |
| return [(name, f"structural mismatch: model expects a dict but checkpoint provides {type(have).__name__}")] | |
| out = [] | |
| is_quant = is_quantized_param or any(k in want for k in ("qvalue", "qarray")) |
| self.assertEqual(list(problems.keys()), ["a/k"]) | ||
| self.assertIn("structural mismatch", problems["a/k"]) | ||
| self.assertIn("dict", problems["a/k"]) |
There was a problem hiding this comment.
| self.assertEqual(list(problems.keys()), ["a/k"]) | |
| self.assertIn("structural mismatch", problems["a/k"]) | |
| self.assertIn("dict", problems["a/k"]) | |
| self.assertEqual(list(problems.keys()), ["a/k"]) | |
| self.assertIn("structural mismatch", problems["a/k"]) | |
| self.assertIn("dict", problems["a/k"]) | |
| def test_weight_mismatches_detects_structural_mismatch_inverse(self): | |
| want = { | |
| "a": { | |
| "k": { | |
| "w": jax.ShapeDtypeStruct((2,), jnp.float32), | |
| } | |
| } | |
| } | |
| # k is a tensor instead of a dictionary | |
| have = {"a": {"k": jnp.ones((2,))}} | |
| problems = dict(checkpointing._weight_mismatches(want, have)) # pylint: disable=protected-access | |
| self.assertEqual(list(problems.keys()), ["a/k"]) | |
| self.assertIn("structural mismatch", problems["a/k"]) | |
| self.assertIn("model expects a dict", problems["a/k"]) |
Refactor MaxText's checkpointing system to primarily use the Orbax v1 API, moving away from the legacy v0 implementations. FIXES: b/532615853 # Tests Added tests that ensure backward compatibility with v0 as we cutover to v1 # Checklist Before submitting this PR, please make sure (put X in square brackets): - [X] I have performed a self-review of my code. For an optional AI review, add the `gemini-review` label. - [X] I have necessary comments in my code, particularly in hard-to-understand areas. - [X] I have run end-to-end tests tests and provided workload links above if applicable. - [X] 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](https://maxtext.readthedocs.io/en/latest/development.html#adding-new-documentation-files). PiperOrigin-RevId: 974668260
Description
Refactor MaxText's checkpointing system to primarily use the Orbax v1 API, moving away from the legacy v0 implementations.
FIXES: b/532615853
Tests
Added tests that ensure backward compatibility with v0 as we cutover to v1
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.