Fix compile_cache_test flakiness caused by the persistent cache compile time threshold - #4692
Open
bzantium wants to merge 1 commit into
Open
Fix compile_cache_test flakiness caused by the persistent cache compile time threshold#4692bzantium wants to merge 1 commit into
bzantium wants to merge 1 commit into
Conversation
…pile time threshold. Previously, test_train_step_cache_hit relied on the AOT compilation of train_step taking longer than jax_persistent_cache_min_compile_time_secs, which defaults to 1 second. JAX writes an entry to the persistent cache only when a compilation is slower than this threshold, so on a fast runner the AOT compilation is never cached, the runtime execution recompiles instead of hitting the cache, and the test fails even though the AOT and runtime cache keys agree. This fix sets the threshold to 0 in the subprocess environment so that the AOT compilation is cached regardless of how long it takes, leaving the test to verify only what it is meant to verify: that the AOT and runtime signatures produce the same cache key.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
bzantium
requested review from
A9isha,
NuojCheng,
RissyRan,
SurbhiJainUSC,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
huytransformer,
igorts-git,
jiangjy1982,
khatwanimohit,
richjames0,
shralex,
vipannalla and
xibinliu
as code owners
July 31, 2026 15:01
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
test_train_step_cache_hitrelies on the AOT compilation oftrain_steptaking longer thanjax_persistent_cache_min_compile_time_secs, which defaults to 1 second. JAX writes an entry to the persistent cache only when a compilation is slower than this threshold, so on a fast runner the AOT compilation is never cached, the runtime execution recompiles instead of hitting the cache, and the test fails even though the AOT and runtime cache keys agree.This showed up on a CI run where the two compilations of
jit_train_steplogged identical shapes and argument mappings, but the AOT one finished in 0.941s and the runtime one in 1.790s. Only the second cleared the threshold, so the single file in the cache directory was written by the runtime compilation rather than read by it, and it was the only one of the 20 compilations in that subprocess above 1 second.This fix sets the threshold to 0 in the subprocess environment so that the AOT compilation is cached however fast it is, leaving the test to verify only what it is meant to verify: that the AOT and runtime signatures produce the same cache key.
Tests
Checked against jax 0.10.0 that
JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS=0reachesjax.config.jax_persistent_cache_min_compile_time_secs, and that a sub-second compilation writes a cache entry with the threshold at 0 while writing none at the default. Lowering the threshold also caches the other functions the subprocess compiles, but only one entry carries thejit_train_stepprefix the test filters on, so the existing assertions still hold.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.