Cache and relocate Metal kernels - #916
Draft
maleadt wants to merge 1 commit into
Draft
Conversation
maleadt
force-pushed
the
relocations
branch
2 times, most recently
from
August 15, 2026 16:19
0ac8879 to
1b009b9
Compare
Deliver GPUCompiler relocation words through a table referenced by KernelState, avoiding unsupported post-load symbol patching. Keep relocation buffers and pipelines device-local while allowing relocatable Metal libraries to survive package precompilation. Add an opt-in MTLBinaryArchive cache for final machine code, descriptor-based pipeline construction, boxed-argument identity handling, and cross-session tests for compilation artifacts, table delivery, and archive behavior.
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.
Adapts Metal to JuliaGPU/GPUCompiler.jl#878 using the
:tablerelocation strategy.Metal cannot look up writable data symbols after loading a library, so GPUCompiler rewrites host references through a relocation table. Metal materializes that table in a per-device buffer and passes its address through
KernelStateon every dispatch. Pipelines and buffers remain device-local while relocatable metallibs can survive package precompilation.This also adds an opt-in
MTLBinaryArchivecache for final machine code and descriptor-based pipeline construction. Archive use remains disabled by default while the cross-process byte-stability constraints are evaluated.Tests cover Julia values, runtime globals, boxed interior relocations, device isolation, cross-session precompilation, and archive behavior. The corresponding writable-global implementation is JuliaGPU/CUDA.jl#3200.