You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[python] Unify caching and key cache on CompileTarget hash (NVIDIA#4859)
Finally! Caching for Python done right 🙃 This builds on top of
@atgeller's work in NVIDIA#4607,
but using the CompileTarget now that it's available.
We store the hashes of the compilation options that affect the compiled
output within `CompiledModule`. We then determine whether the cached
module can be reused by just comparing those hashes to the ones obtained
for the new module.
We distinguish three cases when it comes to caching:
1. When `CompileTarget.fullySpecialize == true`, we disable caching.
This is the case where arguments get inlined into the IR, so keeping
caches here would require hashing the runtime arguments. We currently
don't support that. This mostly affects remote devices, so not having
caching here is reasonable (and the current behaviour already).
2. When `CompileTarget.fullySpecialize == false` and there are no
captured kernels, we key the cache on a hash of `CompileTarget`. This is
the 'best' case, where the compilation options within `CompileTarget`
fully determine the output of the compilation.
3. When `CompileTarget.fullySpecialize == false` and there are captured
kernels, we key the cache on a pair of hashes: the hash of
`CompileTarget` (as in 2) and the hash of the module IR itself. This
detects changes to the captured kernels, as the captured targets are
inlined into the IR before computing the hash.
This should also subsume the second level of caching we were performing
within the ExecutionContext. I'm going to run some benchmarks to make
sure this hasn't regressed.
---------
Signed-off-by: Luca Mondada <luca@mondada.net>
0 commit comments