Skip to content

Allow redefinition of kernel methods#31

Merged
maleadt merged 3 commits into
JuliaGPU:mainfrom
AntonOresten:kernel-redefinition
Jan 19, 2026
Merged

Allow redefinition of kernel methods#31
maleadt merged 3 commits into
JuliaGPU:mainfrom
AntonOresten:kernel-redefinition

Conversation

@AntonOresten

Copy link
Copy Markdown
Collaborator

Ensures the cache stays valid by replacing f, argtypes with the method instance which(f, argtypes) to allow redefinition of kernel methods. This is useful when writing kernels — when writing #16 I actually got all the way up to fmha_kernel95 or something.😅

@AntonOresten

Copy link
Copy Markdown
Collaborator Author

This will still fail when a method called from within the kernel gets updated. Maybe there's a more robust solution, but this would still be useful for now.

@AntonOresten AntonOresten marked this pull request as draft January 13, 2026 19:38
@arhik

arhik commented Jan 13, 2026

Copy link
Copy Markdown
Contributor

cool.

@AntonOresten AntonOresten marked this pull request as ready for review January 13, 2026 20:00
@AntonOresten AntonOresten marked this pull request as draft January 13, 2026 20:03
@AntonOresten AntonOresten marked this pull request as ready for review January 13, 2026 20:11
@maleadt

maleadt commented Jan 13, 2026

Copy link
Copy Markdown
Member

This is flawed, but I'll take it for now (if it works). The proper solution is to include the world age much like how GPUCompiler.jl's cache mechanism work.

For testing, you can use a temporary module you @eval things into: https://github.com/JuliaGPU/GPUCompiler.jl/blob/da0be16b92b9126711fc6d4d36dad30d094b758f/test/native.jl#L84-L98

@AntonOresten

AntonOresten commented Jan 13, 2026

Copy link
Copy Markdown
Collaborator Author

Makes sense..

I'm now using a temporary module like you suggested, and there's no method overwrite warning like before, so if this is fine for now, I think it's ready!

@AntonOresten

AntonOresten commented Jan 19, 2026

Copy link
Copy Markdown
Collaborator Author

Instead of throwing a method error, this branch seems to error at which:

ERROR: Calling invoke(f, t, args...) would throw:
MethodError: no method matching ...

This could be caught, and a real MethodError could be thrown I guess.

@maleadt

maleadt commented Jan 19, 2026

Copy link
Copy Markdown
Member

Let's go ahead and merge this, but know that I'm actually looking into a 'proper' integration with Julia's compiler infrastructure, which will support redefinitions, correct world age handling, and possibly even disk caching.

@maleadt maleadt merged commit ac2a860 into JuliaGPU:main Jan 19, 2026
8 checks passed
@AntonOresten AntonOresten deleted the kernel-redefinition branch March 19, 2026 12:49
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.

3 participants