Skip to content

Fix view and reshape ops when shape is passed as a kwarg. #1426

Merged
coreyjadams merged 2 commits intoNVIDIA:mainfrom
coreyjadams:hotfix-shard-view
Feb 18, 2026
Merged

Fix view and reshape ops when shape is passed as a kwarg. #1426
coreyjadams merged 2 commits intoNVIDIA:mainfrom
coreyjadams:hotfix-shard-view

Conversation

@coreyjadams
Copy link
Collaborator

This essentially consolidates the argument parsing for all the operations.

PhysicsNeMo Pull Request

Description

Checklist

Dependencies

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.

…ially

consolidates the argument parsing for all the operatiosn.
@coreyjadams coreyjadams self-assigned this Feb 18, 2026
@coreyjadams
Copy link
Collaborator Author

/blossom-ci

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 18, 2026

Greptile Summary

This PR consolidates argument parsing for view and reshape operations to properly handle shape parameters passed as keyword arguments. The changes introduce a unified extract_view_and_reshape_arguments() function that handles all variations (positional, variadic, kwarg) for tensor.view(), tensor.reshape(), and torch.reshape().

Key changes:

  • Refactored _extract_view_shape() into two functions: _reshape_args() for normalizing shape arguments and extract_view_and_reshape_arguments() for comprehensive argument extraction
  • Added support for shape= kwarg in torch.reshape() and aten operations
  • Added explicit error handling when shape is None or when dtype is incorrectly used with reshape
  • Comprehensive test coverage for all argument variations (tuple, variadic, list, kwarg)

Issues found:

  • Minor typo in comment: "remaning" should be "remaining" (line 708)

Important Files Changed

Filename Overview
physicsnemo/domain_parallel/shard_utils/view_ops.py Consolidated argument parsing for view/reshape operations to handle kwarg shapes correctly, with minor typo in comment
test/domain_parallel/ops/test_view_ops.py Added comprehensive test coverage for all view/reshape argument variations including kwarg support

Last reviewed commit: f3f2d26

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@coreyjadams
Copy link
Collaborator Author

/blossom-ci

@coreyjadams coreyjadams added this pull request to the merge queue Feb 18, 2026
Merged via the queue into NVIDIA:main with commit 8266475 Feb 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants