fix(transforms): preserve device and dtype in squarepulse#9005
Open
aymuos15 wants to merge 2 commits into
Open
fix(transforms): preserve device and dtype in squarepulse#9005aymuos15 wants to merge 2 commits into
aymuos15 wants to merge 2 commits into
Conversation
Allocate the squarepulse output on the input tensor's device (and floating dtype) so CUDA callers no longer silently get a CPU result. Integer inputs still promote to the default float dtype. Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>
aymuos15
requested review from
KumoLiu,
Nic-Ma,
ericspod and
virginiafdez
as code owners
July 19, 2026 14:59
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughSquarepulse now initializes its output tensor on the input tensor’s device and preserves floating-point input dtype while retaining default dtype promotion for integer inputs. New tests cover CPU and CUDA inputs, output shape, dtype, device placement, binary output values, and reference-value matching. Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
squarepulseallocated its output viatorch.zeros(t.shape), which defaults to a CPU float32 tensor regardless of the input tensor's device or dtype. This caused CUDA callers to silently receive a CPU result, breaking downstream transforms when GPU tensors were passed.This fix allocates the output on the input tensor's device, and preserves the input's floating-point dtype. Integer inputs still promote to the default float dtype (matching
torch.zerosbehavior).Diff
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.