Skip to content
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

Fix fusion with inplace #1659

Closed
wants to merge 2 commits into from
Closed

Fix fusion with inplace #1659

wants to merge 2 commits into from

Conversation

louisfd
Copy link
Member

@louisfd louisfd commented Apr 18, 2024

The bug in #1656 seems to be caused by fusion when it works on several read-write tensors.

What happened was rather subtle: if the output of the fused kernel was a mutable tensor, then it was "Readwrite", even if there were only writes to it in this specific kernel. So while looking to match the outputs with potential inplace inputs it would not find itself and could wrongly assume that another tensor with the same shape could was it. So it did not write to the right tensor.

Batches of one allowed to detect it, but I think the bug happened with other batch sizes as well.

@nathanielsimard I'm not sure why this id comparison was not there before. Could adding it break something?

Fix #1656

@louisfd louisfd requested a review from nathanielsimard April 18, 2024 20:28
Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 86.36%. Comparing base (9fbcbed) to head (f9b002b).

Files Patch % Lines
crates/burn-jit/src/codegen/compilation.rs 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1659      +/-   ##
==========================================
- Coverage   86.41%   86.36%   -0.06%     
==========================================
  Files         694      694              
  Lines       80675    80690      +15     
==========================================
- Hits        69719    69684      -35     
- Misses      10956    11006      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +196 to +199
if desc.shape == desc_input.shape
&& input.item() == output.item()
&& desc.id == desc_input.id
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's right, it's not a requirement! But I think we should verify before chosing an input to replace the output if the output is also an input, in which case we have to use it.

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.

If the batch size is 1, testing LSTM on the Wgpu backend will fail
2 participants