Skip to content

Conversation

@loliverhennigh
Copy link
Collaborator

PhysicsNeMo Pull Request

Description

Refactor physicsnemo nn to more closely align with pytorch.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 4, 2025

Skipped: This PR changes more files than the configured file change limit: (448 files found, 100 file limit)

@loliverhennigh loliverhennigh changed the base branch from main to v2.0-refactor December 4, 2025 00:31
Copy link
Collaborator

@coreyjadams coreyjadams left a comment

Choose a reason for hiding this comment

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

A lot of the pieces you've put in module might be better suited in functional, I think. For example, the neighbors utilities are pretty much pure functions. Similar for many activation functions.

Is ASV supported with this too or just reorganization? Is that benchmark mixing meant to use ASV or something else?

Comment on lines +24 to +26
class Function(TorchAutogradFunction, BenchmarkMixin):
"""Base class for PhysicsNeMo custom autograd functions."""
# Placeholder for utilities to bring in warp, fuser, etc. No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

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

This locks us in to the inherit-from-TorchAutogradFunction interface and away from the custom op solution that pytorch seems to prefer here:
https://docs.pytorch.org/tutorials/advanced/python_custom_ops.html

I favor the custom op decorators for several reasons:

  • better integration with torch.compile and avoiding compile breaks
  • Registration with pytorch dispatch tools, used to enable ShardTensor's distributed dispatch
  • built-in testing utilities from pytorch to validate compile support, etc.



class Module(torch.nn.Module):
class Module(torch.nn.Module, BenchmarkMixin):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will automatically expose our models to this BenchmarkMixin functionality. Not necessarily a bad thing, though I wonder if we'll hit unforeseen consequences in save / load / restore / broken checkpoints, etc.

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