这是indexloc提供的服务,不要输入任何密码
Skip to content

[JAX] Make util.lru_cache(..., trace_context_in_key=False) always cache #30392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Jul 22, 2025

[JAX] Make util.lru_cache(..., trace_context_in_key=False) always cache

With this change, the implementation of util.lru_cache(..., trace_context_in_key=False) is effectively the same as functools.lru_cache,
except being cleared when JAX backends are cleared.

This makes a semantics change when check_tracer_leaks is enabled (as in
several tests and debugging sessions). Previously, caching was disabled with
check_tracer_leaks is enabled, which accidentally prevented caching JAX
backends and runtime objects after #30324
With this change, these objects will be cached as before, and will avoid
performance regression due to such unintended cache misses.

@copybara-service copybara-service bot force-pushed the test_785884738 branch 3 times, most recently from 5f493a4 to fa4d21e Compare July 22, 2025 18:12
@copybara-service copybara-service bot changed the title [JAX] Optimize util.lru_cache(..., trace_context_in_key=False) [JAX] Make util.lru_cache(..., trace_context_in_key=False) always cache Jul 22, 2025
…ache

With this change, the implementation of `util.lru_cache(...,
trace_context_in_key=False)` is effectively the same as `functools.lru_cache`,
except being cleared when JAX backends are cleared.

This makes a semantics change when `check_tracer_leaks` is enabled (as in
several tests and debugging sessions). Previously, caching was disabled with
`check_tracer_leaks` is enabled, which accidentally prevented caching JAX
backends and runtime objects after #30324
With this change, these objects will be cached as before, and will avoid
performance regression due to such unintended cache misses.

PiperOrigin-RevId: 785931431
@copybara-service copybara-service bot merged commit 8bfdc0d into main Jul 22, 2025
@copybara-service copybara-service bot deleted the test_785884738 branch July 22, 2025 18:29
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.

1 participant