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

Add cumprod support for device mps #104688

Closed
wants to merge 23 commits into from
Closed

Conversation

Mr4k
Copy link
Contributor

@Mr4k Mr4k commented Jul 6, 2023

Related to #77764

Add support for the cumprod operation (which in turn allows its gradient). This also allows us to compute the gradient of prod since it was blocked behind cumprod in the case where exactly one element of the tensor was 0.

@Mr4k Mr4k requested a review from kulinseth as a code owner July 6, 2023 04:57
@pytorch-bot
Copy link

pytorch-bot bot commented Jul 6, 2023

🔗 Helpful Links

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

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

✅ 1 Unrelated Failure

As of commit cca389b:

UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:

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

@pytorch-bot pytorch-bot bot added ciflow/mps Run MPS tests (subset of trunk) release notes: mps Release notes category labels Jul 6, 2023
}
auto input = dtype.has_value() ? self.to(dtype.value()) : self;

// issue #103810551: cumprod is horribly broken for int8, int16 and as chances for overflow is pretty high, cast to
Copy link
Contributor Author

@Mr4k Mr4k Jul 6, 2023

Choose a reason for hiding this comment

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

I'm not sure what issue #103810551 is and where I want to check if this applies to cumprod as well as cumsum. So far I assumed it did but seeing the actual issue in whatever tracker it lies would help. If it didn't I could remove a decent chunk of this function. If it does not I can dedupe this with cumsum and make a general helper function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from the work done on kulinseth#419, it appears constraint does hold for both functions so I will merge them into a single one as is done in this pr

@@ -393,7 +394,7 @@ Tensor logit_mps(const Tensor& self, c10::optional<double> eps) {

mps::unary_op(input,
result,
"cumsum_out_mp" + std::to_string(dim),
"cumsum_out_mps" + std::to_string(dim),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

drive by spelling fix

test/test_mps.py Outdated Show resolved Hide resolved
@Mr4k
Copy link
Contributor Author

Mr4k commented Jul 7, 2023

@kulinseth it appears this might be a duplicate pr with something on your branch: kulinseth#419, happy to close my pr out if need be

@Mr4k
Copy link
Contributor Author

Mr4k commented Jul 9, 2023

I'm not sure why macos-12-py3 tests are failing for test_output_grad_match_cumprod_cpu_float32. It's likely something silly I missed. However I noticed the tests seem to not actually running be on macos12. If you look at the Print Runner OS/HW Info step of the CI it says kern.osproductversion: 13.2.1 which seems suspicious. I'm curious if there is anyway this could be a macOS < 13.3 problem but I don't have access to a laptop to repro with

@bdhirsh bdhirsh added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jul 10, 2023
@Mr4k
Copy link
Contributor Author

Mr4k commented Jul 12, 2023

@kulinseth just wanted to bump here. Also @DenisVieriu97 if you are also cleared to review these prs

Copy link
Collaborator

@kulinseth kulinseth left a comment

Choose a reason for hiding this comment

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

Looks good, thanks.

@Mr4k
Copy link
Contributor Author

Mr4k commented Jul 27, 2023

@kulinseth @DenisVieriu97 I finally triaged all the bugs working on this pr uncovered and it's now ready to go! Edit: Sorry for "@"ing you both, I didn't know I had permission to merge without intervention from one of you.

@Mr4k
Copy link
Contributor Author

Mr4k commented Aug 1, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 1, 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: New commits were pushed while merging. Please rerun the merge command.

Details for Dev Infra team Raised by workflow job

@Mr4k
Copy link
Contributor Author

Mr4k commented Aug 1, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/mps Run MPS tests (subset of trunk) ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: mps Release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants