Skip to content

Conversation

@mnabian
Copy link
Collaborator

@mnabian mnabian commented Oct 24, 2025

PhysicsNeMo Pull Request

Description

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.
  • The CHANGELOG.md is up to date with these changes.
  • An issue is linked to this pull request.

Dependencies

@mnabian
Copy link
Collaborator Author

mnabian commented Oct 24, 2025

/blossom-ci

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.

Greptile Overview

Greptile Summary

This PR replaces graceful handling of empty world edges in two graph construction helpers with explicit error raising. Previously, when no world edges were found (when connecting mesh nodes to world/collider nodes based on a radius threshold), the functions returned the graph unchanged with empty world edge features. Now, both examples/structural_mechanics/deforming_plate/helpers.py and the DGL variant in deforming_plate_dgl/helpers.py raise a ValueError("No world edges to add") when world_edges.numel() == 0. The change also improves empty-tensor detection by using numel() instead of checking shape[1], making it more robust to malformed tensors. This converts what was treated as a valid edge case into a hard failure, ensuring that missing world edges—likely caused by incorrect world_edge_radius or missing world position data—are caught immediately rather than silently propagating through the simulation pipeline.

PR Description Notes:

  • The PR description is empty beyond the template; no description, linked issue, or CHANGELOG update is provided
  • All checklist items remain unchecked

Important Files Changed

Filename Score Overview
examples/structural_mechanics/deforming_plate/helpers.py 2/5 Replaces silent early-return for empty world edges with explicit ValueError; changes empty check from shape[1] to numel()
examples/structural_mechanics/deforming_plate_dgl/helpers.py 2/5 Identical behavioral change to PyG version: converts empty world edges from valid edge case to error condition

Confidence score: 2/5

  • This PR introduces a breaking behavioral change that may fail valid simulations where world edges legitimately don't exist due to geometry or radius parameters
  • Score reflects that the change converts previously-working code into error conditions without clear justification, documentation, or tests verifying when empty world edges should be errors versus valid states
  • Both helpers.py files need careful review to determine whether this error-on-empty behavior is correct for all simulation configurations, and whether downstream code assumes world edges can be absent

Sequence Diagram

sequenceDiagram
    participant Caller
    participant add_world_edges
    participant load_json
    participant radius_search
    participant Graph

    Caller->>add_world_edges: add_world_edges(graph, world_edge_radius, edge_stats_path)
    add_world_edges->>Graph: clone()
    Graph-->>add_world_edges: cloned graph
    add_world_edges->>load_json: load_json(edge_stats_path)
    load_json-->>add_world_edges: edge_stats (edge_mean, edge_std)
    add_world_edges->>Graph: get existing mesh edges
    Graph-->>add_world_edges: mesh_src, mesh_dst
    add_world_edges->>Graph: get world_pos
    Graph-->>add_world_edges: world_pos
    add_world_edges->>radius_search: radius_search(world_pos, world_pos, radius)
    radius_search-->>add_world_edges: edge_index
    add_world_edges->>add_world_edges: filter self-loops and existing edges
    alt No world edges found
        add_world_edges->>Caller: raise ValueError("No world edges to add")
    else World edges exist
        add_world_edges->>add_world_edges: compute world edge features
        add_world_edges->>add_world_edges: compute mesh edge features
        add_world_edges->>Graph: add world edges and update edge attributes
        add_world_edges->>Caller: return graph, mesh_edge_features, world_edge_features
    end
Loading

2 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@mnabian
Copy link
Collaborator Author

mnabian commented Oct 24, 2025

/blossom-ci

Copy link
Collaborator

@Alexey-Kamenev Alexey-Kamenev left a comment

Choose a reason for hiding this comment

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

LGTM!

@mnabian mnabian merged commit 91cb7d7 into NVIDIA:main Oct 24, 2025
1 check passed
@mnabian mnabian deleted the bug_deforming_plate branch October 24, 2025 22:38
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