Skip to content

addmv decomp #2#96264

Closed
cybershiptrooper wants to merge 7 commits intopytorch:masterfrom
cybershiptrooper:master
Closed

addmv decomp #2#96264
cybershiptrooper wants to merge 7 commits intopytorch:masterfrom
cybershiptrooper:master

Conversation

@cybershiptrooper
Copy link
Contributor

Fixes #94617

@pytorch-bot
Copy link

pytorch-bot bot commented Mar 8, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/96264

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit fb23a09:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@cybershiptrooper
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Mar 8, 2023
@cybershiptrooper
Copy link
Contributor Author

cybershiptrooper commented Mar 8, 2023

@ngimel could you please review this again?
I somehow messed up merging the previous one
(again, sorry about that: pretty new to open source..)
Thanks a lot

@ezyang
Copy link
Contributor

ezyang commented Mar 8, 2023

Test failures are real 🤔

@ezyang ezyang requested a review from lezcano March 8, 2023 15:52
@ngimel
Copy link
Collaborator

ngimel commented Mar 8, 2023

Hm, it does @pw_cast_for_opmath, I don't understand accuracy failures.

@cybershiptrooper
Copy link
Contributor Author

cybershiptrooper commented Mar 9, 2023

I might need some help here :(
The accuracy error does not show up on replacing torch.mv with @/matmul/(A*b).sum(dim=1), but I couldn't understand why..

out = alpha * torch.mv(mat1, vec)
return out + beta * self # fails
----
out = alpha * torch.matmul(mat1, vec)
return out + beta * self # success

And I saw this but removing it doesn't affect any mv related tests, so idk why/when did mv itself faced accuracy issues, or if this changes addmv's behaviour(but why would printing something random cause problem?)

Also, I couldn't understand the test_has_decomposition error: shouldn't @register_decomposition add it to the table?

@ngimel
Copy link
Collaborator

ngimel commented Mar 10, 2023

I guess you need to add higher tolerance for addmv to that table

@ezyang
Copy link
Contributor

ezyang commented Mar 10, 2023

Is the precision difference due to FMA or something?

@ngimel
Copy link
Collaborator

ngimel commented Mar 10, 2023

blas gemv likely compiles to fma, while out + beta * self doesn't

@ezyang
Copy link
Contributor

ezyang commented Mar 10, 2023

I wonder if we should have an FMA prim for this reason 🤔

@cybershiptrooper
Copy link
Contributor Author

@ngimel I just have one more question for clarity: matmul just forwards the call to torch.mv (in this case). So shouldn't matmul also use the same rounding? Why would matmul pass and not mv if they both call the same function? The print thing also went over my head
Thanks a lot

@ngimel
Copy link
Collaborator

ngimel commented Mar 11, 2023

Yes, matmul should call mv. Sorry, I don't quite understand what fails and what passes from your comments, can you post a standalone runnable script demonstrating the differences between matmul and mv?

@cybershiptrooper
Copy link
Contributor Author

There isn't any difference in the result but somehow, matmul passes the accuracy test on my system.. ( instead of using torch.mv(mat1, vec) )

@ngimel
Copy link
Collaborator

ngimel commented Mar 13, 2023

Sorry, both things can't be true

  1. there's no difference in the results with matmul and mv
  2. matmul passes the test and mv doesn't.
    Can you please dig deeper and see what's going on?
    Or leave mv in decomposition and increase tolerance for the tests.

@cybershiptrooper
Copy link
Contributor Author

@ngimel
Whenever I go through matmul, both orig and decomp(in DecompCrossRefMode) have low accuracy(~1e-2 to ~1e-4), and mv's test passes(holds for all seeds).. Not sure what is happening yet. If there is something wrong, I'll add an issue separately.
Error in mv's test is due to (self * vec) not using FMA in its decomp(increased its tolerance). No need to increase addmv's tolerance.
I hope this is fine. Am I allowed to merge this using pytorchbot? Or do I need all reviews to do so?
Thanks

@ngimel
Copy link
Collaborator

ngimel commented Mar 15, 2023

I don't understand how orig can have different accuracy depending on decomposition, but you can land PR in its current form if the tests pass.

@cybershiptrooper
Copy link
Contributor Author

ahh.. Could you please run again? Sorry for the trouble

@ezyang
Copy link
Contributor

ezyang commented Mar 16, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 16, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@cybershiptrooper
Copy link
Contributor Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 23, 2023
cyyever pushed a commit to cyyever/pytorch_private that referenced this pull request Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write a decomposition for addmv

6 participants