Skip to content

Conversation

@mfkasim1
Copy link
Contributor

@mfkasim1 mfkasim1 commented Feb 7, 2023

Hopefully fixes #89205.
This is another version of #90847 where it was reverted because it increases the compile-time significantly.
From my discussion with @ngimel in #93153 (comment), it seems the option of jiterator would be very tricky if not impossible.
So what I did was to optimize the compile-time in my computer.

To optimize the build time, first I compile the pytorch as a whole, then only change the LogcumsumexpKernel.cu file to see how it changes the compile time.
Here are my results for the compilation time of only the LogcumsumexpKernel.cu file in my computer:

If the previous PR increases the build time by 30 mins in pytorch's computer, then this PR reduces the increment of build time to about 6 mins. Hopefully this is an acceptable level of build-time increase.

What I did was (sorted by how significant it reduces the build time from the most significant one):

  • Substituting log(x) to log1p(x - 1). This is applied in the infinite case, so we don't really care about precision.
  • Implementing complex exponential manually

tag: @malfet, @albanD

@pytorch-bot
Copy link

pytorch-bot bot commented Feb 7, 2023

🔗 Helpful Links

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

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

❌ 12 Failures

As of commit c05db6c:

NEW FAILURES - The following jobs have failed:

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

@Skylion007
Copy link
Collaborator

Skylion007 commented Feb 7, 2023

Ah, actually scratch the constexpr comments, seems like there are some implementation issues in custom scalar types.


// custom min and max to be used in logcumsumexp for complex arguments
template <typename scalar_t, bool min>
__host__ __device__ c10::complex<scalar_t> _logcumsumexp_minmax(const c10::complex<scalar_t>& x, const c10::complex<scalar_t>& y) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually you can revert the templating arg too, its' a bit difficult to setup this in a constexpr if statement that is clean with the all the non-constexpr conditions as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also all the else statements are unnecessary since they all have return statements in them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What difference does it make if we remove the else statements?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mfkasim1 just removes extra indentation. That's why it's a nit. Don't really care either way.

// handling the "infectious" NaNs
return {std::numeric_limits<scalar_t>::quiet_NaN(), std::numeric_limits<scalar_t>::quiet_NaN()};
}
else if ((!::isfinite(min_real)) && (min_real == max_real)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit but a lot of the elses also aren't needed here due since it's all just dealing with early returns

@Skylion007 Skylion007 added the ciflow/trunk Trigger trunk jobs on your pull request label Feb 7, 2023
@Skylion007 Skylion007 requested review from Skylion007 and removed request for Skylion007 February 7, 2023 20:12
Copy link
Collaborator

@Skylion007 Skylion007 left a comment

Choose a reason for hiding this comment

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

Waiting to hear from @mfkasim1 and @ngimel since the OG change was reverted. Looks reasonable to me though.

@mfkasim1
Copy link
Contributor Author

mfkasim1 commented Feb 7, 2023

Waiting to hear from @mfkasim1 and @ngimel since the OG change was reverted. Looks reasonable to me though.

What do you need from me?

@Skylion007
Copy link
Collaborator

Waiting to hear from @mfkasim1 and @ngimel since the OG change was reverted. Looks reasonable to me though.

What do you need from me?

Wasn't either you or @ngimel who reverted the change? Just want to make sure the build times are acceptable.

@mfkasim1
Copy link
Contributor Author

mfkasim1 commented Feb 8, 2023

Waiting to hear from @mfkasim1 and @ngimel since the OG change was reverted. Looks reasonable to me though.

What do you need from me?

Wasn't either you or @ngimel who reverted the change? Just want to make sure the build times are acceptable.

tag: @malfet

@soulitzer soulitzer added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 8, 2023
@mfkasim1
Copy link
Contributor Author

@malfet @ngimel Is the build time acceptable?

@malfet malfet added the ciflow/binaries_wheel Trigger binary build and upload jobs for wheel on the PR label Feb 10, 2023
Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

Let's wait for binary build results, but otherwise looks good to me

@albanD albanD requested a review from Skylion007 February 10, 2023 18:55
@Skylion007
Copy link
Collaborator

@mfkasim1 Looks good to me. Feel free to trigger the merge whenever.

@mfkasim1
Copy link
Contributor Author

Thanks @malfet @Skylion007

@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

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR is too stale; the last push date was more than 3 days ago. Please rebase and try again. You can rebase by leaving the following comment on this PR:
@pytorchbot rebase

Details for Dev Infra team Raised by workflow job

@mfkasim1
Copy link
Contributor Author

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased clse4 onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout clse4 && git pull --rebase)

@mfkasim1
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

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: windows-binary-wheel / wheel-py3_9-cpu-test

Details for Dev Infra team Raised by workflow job

@Skylion007
Copy link
Collaborator

@pytorchbot merge -f 'Unrelated infra issue. Broken smoketest label binaries'

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes).

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/binaries_wheel Trigger binary build and upload jobs for wheel on the PR ciflow/trunk Trigger trunk jobs on your pull request Merged open source 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.

Complex support for log1p and logcumsumexp

6 participants