Mesh: preserve complex values during aggregation - #1879
Draft
peterdsharpe wants to merge 1 commit into
Draft
Conversation
Complex tensors are not "floating point" by torch's definition, so scatter_aggregate and the point-to-facet vertex average promoted them to float64 like an integer field, silently discarding the imaginary part. This corrupted Mesh.cell_data_to_point_data, both data_source settings of Mesh.get_facet_mesh, and repair.merge_duplicate_points. A "mean" still requires real weights, since its divisor is clamped away from zero and clamp rejects complex dtypes. A "sum" has no divisor, so it accepts complex weights and promotes the accumulator to the common dtype of the values and the weights.
Contributor
CODEOWNERS review mapCurrent for commit ⏳ @peterdsharpe — 5 file(s)
No CODEOWNER
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.
PhysicsNeMo Pull Request
Description
Mesh mean and facet aggregation treated complex tensors as non-floating and cast them to
float64, silently discarding imaginary values in public operations such ascell_data_to_point_data,get_facet_mesh, and duplicate-point merging. Complex weights supplied to sums could lose their imaginary contribution for the same reason.This PR:
TypeError.Verification
pytest test/mesh: 2354 passed, 703 skipped.main, including gradients.ruff checkandruff format --checkpass for all changed files.Checklist
Dependencies
None.
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 the work or an indication that the PR will be accepted or 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.