Repository navigation
feat: share compilation cache for host devices - #1901
Merged
polvalente merged 3 commits intoNov 27, 2026
Merged
Conversation
josevalim
approved these changes
Nov 16, 2026
polvalente
reviewed
Nov 20, 2026
| {executable, {used_inputs, outputs, outfeed, _input_typespecs?}} = | ||
| compile(key, vars, fun, compile_options, 0, [], callback) | ||
|
|
||
| executable = bind_device(executable, compile_options) |
Member
There was a problem hiding this comment.
Could we have a test that requires multi device? We have a flag for this in test_helper I think.
Contributor
Author
There was a problem hiding this comment.
Sure, I'll give it a go
Contributor
Author
There was a problem hiding this comment.
I added one, I wasn't sure where the right place for the test was, let me know if you'd want is somewhere else!
The test compiled add_two/2 with scalar s32 inputs, the same function and shapes as the debug logging test. With the device-agnostic cache key, that test could already have cached the compilation, so the initial refute failed depending on test order. Co-authored-by: Paulo Valente <polvalente@users.noreply.github.com>
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.
First of all, thanks for all the work on the libraries!
We've increased the number of host devices and got performance gains. We've run into high memory usage from our NX programs. This seems to be due to how the compiled programs are cached in memory.
This patch drops the device id from the cache key and ensures only one copy for each program exists.
Change
For host clients without a mesh:
device_idis dropped from the compilation cache key, so all devices shareone compiled executable per function, shape and options.
by the current call (
bind_device/2). That covers__compile__/jitaswell as
module_compilation: :to_executable.Other platforms (CUDA, ROCm, etc.) and mesh/sharded executables are
unchanged: their executables are tied to a device, so
device_idstays inthe key. Executables with
device_id < 0are not portable and are leftalone.
Repro