-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom fusion #2486
Custom fusion #2486
Conversation
let mut cloned = self.builder.clone(); | ||
build(&mut cloned); | ||
if cloned.estimate_bindings() > self.max_bindings { | ||
return false; | ||
} | ||
self.builder = cloned; | ||
true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cloning every time is a bit wasteful. I would only do it if builder_current_state.estimate_bindings() + new_op.nodes() > self.max_bindings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't really work - we don't know how many nodes someone is adding in the build function. And we can't easily keep track of it as adding them mutates the builder.
estimate_bindings() also seems more expensive than a clone in the first place?
I've at least added a fast path for the first operation which should be common. If that's not enough might need to rethink how these operations are added so we can count them more easily.
I've also added a fix for a deadlock in fusion on wasm in this PR now. It might or might not make things run a bit smoothly on other platforms too, as it was incorrectly holding the server lock while waiting for a read. |
Pull Request Template
Related Issues/PRs
#1970
Changes
Expose enough information to allow custom operations to use fusing. Also expose a function to resolve a tensor from a fusion backend.
Draft until tracel-ai/cubecl#256 lands & some other bits are cleaned up.
This also fixes #1970 by bailing on fusing when going over max bindings.