-
Notifications
You must be signed in to change notification settings - Fork 62
Fix logsigmoid buffer shape for vmap+JVP #2373
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR fixes the buffer tensor shape allocation in the log_sigmoid_forward_xpu function to properly support vmap and JVP (Jacobian-vector product) operations. Previously, the buffer was initialized with shape {0}, which is incompatible with batched operations.
Key changes:
- Modified buffer allocation to use
at::empty_like(input)instead ofat::empty({0}, input.options())
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
May I know if there is the same issue existing on CUDA. I see CUDA use std::tuple<Tensor, Tensor> log_sigmoid_forward_cuda(const Tensor& input) {
auto result = at::empty_like(input);
auto buffer = at::empty({0}, input.options());
log_sigmoid_forward_out_cuda(input, result, buffer);
return std::forward_as_tuple(result, buffer);
} |
EikanWang
left a comment
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.
Could you please add a regression test?
|
It works on CUDA, as there are extra checks in |
|
Thanks, @Silv3S. |
|
CUDA custom batching strategy was introduced in pytorch/pytorch#84892 |
Fixes #2240