Skip to content

Make Flax thread-safe for multi-threaded tracing. - #5543

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_957106352
Aug 12, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
test_957106352

Conversation

@copybara-service

Copy link
Copy Markdown

Make Flax thread-safe for multi-threaded tracing.

Replace the global _use_named_call bool with a contextvars.ContextVar
so each thread gets its own context without racing on a shared global.
Move submodule adoption caching from a process-global WeakKeyDictionary
onto flax.core.Scope (_submodule_adoption_cache) to guarantee thread-isolated
tracing trees without global locks.

@copybara-service
copybara-service Bot force-pushed the test_957106352 branch 7 times, most recently from ee6e17c to 809818f Compare August 7, 2026 02:38
@copybara-service
copybara-service Bot force-pushed the test_957106352 branch 4 times, most recently from 0e62079 to c08309a Compare August 12, 2026 14:26
Replace the global _use_named_call bool with a contextvars.ContextVar
so each thread gets its own context without racing on a shared global.
Move submodule adoption caching from a process-global WeakKeyDictionary
onto flax.core.Scope (_submodule_adoption_cache) to guarantee thread-isolated
tracing trees without global locks.

PiperOrigin-RevId: 963430523
@copybara-service
copybara-service Bot merged commit c5f2e5b into main Aug 12, 2026
@copybara-service
copybara-service Bot deleted the test_957106352 branch August 12, 2026 14:27
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