Disable JAX compilation cache when dump_hlo is True#4167
Merged
Conversation
khatwanimohit
approved these changes
Jun 15, 2026
hengtaoguo
approved these changes
Jun 15, 2026
gobbleturk
approved these changes
Jun 15, 2026
gobbleturk
left a comment
Collaborator
There was a problem hiding this comment.
This PR implies any hero run should not dump HLO, which is fine I guess since our main HLO use cases are for one-off debugging, but something to note in PR description perhaps, maybe also in types.py documentation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
When
dump_hlo=trueis set, MaxText relies on XLA compiler flags to dump HLO files during compilation. However, ifjax_cache_diris configured, subsequent runs reuse the JAX compilation cache on disk. Since compilation is bypassed, XLA does not run, and no HLO files are dumped. This silently fails to produce HLOs if the user clears the dump directory between runs.Solution: Automatically bypass the JAX compilation cache initialization in pyconfig.py if
dump_hlois True. This forces recompilation and ensures that HLOs are always generated as requested. A warning is logged to inform the user:Alternative considered: We explored programmatically extracting the final HLO text from the cached executable using compiled.as_text(). While this successfully retrieves the post-optimization HLO even on cache hits, it is unable to recover the full suite of XLA compiler intermediate output files (like before_optimizations.txt, tpu_comp_env.txt, memory usage reports, etc.) which are never generated when compilation is skipped. Forcing recompilation remains the only way to guarantee the complete dump.
If the change fixes a bug or a Github issue, please include a link, e.g.,:
FIXES: b/440500124
Tests
Tested on my TPU VM using a tiny model before and after the fix to confirm that when
dump_hlo==TrueXLA compilation gets triggered and HLO is dumped.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.