Skip to content

Things compile twice... why? And how to track cache hits/misses? #27186

Answered by jakevdp
Jacob-Stevens-Haas asked this question in Q&A
Discussion options

You must be logged in to vote

The JIT cache is in play here, and as you've seen you end up with only one compilation (which can be tracked via func._cache_size()). You're correct that in both cases you've created four distinct Python function objects with different object ids, but each of these when called will execute the same cached XLA operation, and thus avoid recompilation. The JIT cache is tied to the id of the original, wrapped function, not the functions returned by jit. I hope that's clear!

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Jacob-Stevens-Haas
Comment options

@yashk2810
Comment options

@jakevdp
Comment options

Answer selected by Jacob-Stevens-Haas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants