Fix one-sided padding with sharded tensors.#1535
Conversation
Greptile SummaryThis PR fixes a bug in Root cause: The outer loop in When does it trigger? The mismatch only becomes observable when the sharding is uneven across ranks, which happens naturally after a one-sided padding operation (e.g., only the leftmost rank gains elements). A subsequent pad operation on such an unevenly-sharded tensor would record wrong Fix assessment: The one-line change is correct and minimal. Notable checklist items:
Important Files Changed
Reviews (1): Last reviewed commit: "Fix one-sided padding with sharded tenso..." | Re-trigger Greptile |
|
/blossom-ci |
|
Hi @nloppi thanks for opening this! From what I can see it looks absolutely reasonable. I will take a look. It's awesome to see it being used! Is this urgent? We are heading in to a long weekend, and I need to manually test this still before merge. Meanwhile, do you think you could add your test case / reproducer to the test suite? I think it could go here: With the way you wrote it out with functionals, it's probably easiest to mimic the way we're testing attention: If you want some guidance on running the multi gpu tests, you can find it here: Sorry, we have this CI running internally post-merge so we catch issues that crop up but it's not set up for PRs yet. It's on the to-do list ... |
|
Hi @coreyjadams! Thanks!! I'll gladly add the test, and thanks for the tips. There's no rush. We can catch up next week :) |
|
Hi @coreyjadams! I added the test. I think I need to do it this way. If I just use the last assert comparing the global shapes, the |
|
I still need to rerun the test on a bigger system (after the new clean-up commit). |
Signed-off-by: Niki Loppi <nloppi@nvidia.com>
|
Hi @coreyjadams! I think this should be more or less ready now. I added the pre-commit clean-ups, validated that the new test works on an 8 GPU system, rebased and squashed everything under a single commit. Many thanks for your help! |
PhysicsNeMo Pull Request
Description
A tiny PR that fixes a bug that occurs when we do one-sided padding with sharded tensors or pad sharded tensors with uneven chunks. Found it as I was working on a differentiable solver with sharded tensors, where the partitions at the domain edges need to also contain extra ghost/halo elements for boundary conditions.
To reproduce
and run with
torchrun --nproc-per-node 4 test.pyChecklist
Dependencies
N/A
Review Process
All PRs are reviewed by the PhysicsNeMo team before merging.
Depending on which files are changed, GitHub may automatically assign a maintainer for review.
We are also testing AI-based code review tools (e.g., Greptile), which may add automated comments with a confidence score.
This score reflects the AI’s assessment of merge readiness and is not a qualitative judgment of your work, nor is
it an indication that the PR will be accepted / rejected.
AI-generated feedback should be reviewed critically for usefulness.
You are not required to respond to every AI comment, but they are intended to help both authors and reviewers.
Please react to Greptile comments with 👍 or 👎 to provide feedback on their accuracy.