Skip to content

Build the thread ID buffer of wait workers concretely - #36

Merged
maleadt merged 1 commit into
mainfrom
tb/invalidations
Oct 22, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/invalidations

Conversation

@maleadt

@maleadt maleadt commented Oct 21, 2026

Copy link
Copy Markdown
Member

create_wait_worker built the buffer for the new thread's ID as ntuple(i -> 0, 32), which returns a tuple of unknown length (ntuple only unrolls up to 10 elements), and then converted that to NTuple{32, UInt8}. That conversion was compiled with edges to generic methods (ntuple over a Val of unknown type, comparisons with Any) that packages like ForwardDiff invalidate, so with such a package loaded first, Julia discarded the precompiled code that starts wait workers in the packages using GPUToolbox. This builds the buffer with a Val count instead.

Found while surveying invalidations in the JuliaGPU stack (JuliaGPU/GPUCompiler.jl#1048). Tested with the test suite.

`ntuple` with a literal count above 10 returns a tuple of unknown length, which
was then converted to `NTuple{32, UInt8}` with generic methods (`ntuple` over a
`Val` of unknown type, comparisons with `Any`) that packages like ForwardDiff
invalidate. When such a package was loaded first, that discarded the
precompiled code that starts wait workers in packages using GPUToolbox.
@maleadt
maleadt merged commit 83533fb into main Oct 22, 2026
10 checks passed
@maleadt
maleadt deleted the tb/invalidations branch October 22, 2026 10:01
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