🐛[BUG]: ValueError: infer_schema(func) in @torch.library.custom_op due to stringified type annotations (from __future__ import annotations)
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
Version
e416350
On which installation method(s) does this occur?
Pip
Describe the issue
When importing physicsnemo (specifically through modules relying on physicsnemo.nn.functional.derivatives.mesh_green_gauss_gradient._warp_impl), a ValueError is raised during module load by PyTorch's schema inference mechanism in @torch.library.custom_op.
PyTorch's infer_schema inspects the function signature and expects actual types (such as <class 'torch.Tensor'>), but instead receives string literals (e.g. 'torch.Tensor'). This occurs when postponed evaluation of annotations is enabled (via from future import annotations or Python 3.11+ stringified annotations) without explicitly supplying the schema argument to @torch.library.custom_op.
Minimum reproducible example
python examples/structural_mechanics/deforming_plate/preprocessor.py
Relevant log output
D:\PycharmProjects\physicsnemo\venv\Scripts\python.exe D:\PycharmProjects\physicsnemo\examples\structural_mechanics\deforming_plate\preprocessor.py
Warp CUDA warning: Could not find or load the NVIDIA CUDA driver. GPU execution will not be available.
Traceback (most recent call last):
File "D:\PycharmProjects\physicsnemo\examples\structural_mechanics\deforming_plate\preprocessor.py", line 26, in <module>
from deforming_plate_dataset import DeformingPlateDataset
File "D:\PycharmProjects\physicsnemo\examples\structural_mechanics\deforming_plate\deforming_plate_dataset.py", line 31, in <module>
from physicsnemo.datapipes.gnn.utils import load_json, save_json
File "D:\PycharmProjects\physicsnemo\physicsnemo\datapipes\__init__.py", line 42, in <module>
from physicsnemo.datapipes.dataset import Dataset
File "D:\PycharmProjects\physicsnemo\physicsnemo\datapipes\dataset.py", line 40, in <module>
from physicsnemo.datapipes.readers.base import Reader
File "D:\PycharmProjects\physicsnemo\physicsnemo\datapipes\readers\__init__.py", line 29, in <module>
from physicsnemo.datapipes.readers.mesh import DomainMeshReader, MeshReader
File "D:\PycharmProjects\physicsnemo\physicsnemo\datapipes\readers\mesh.py", line 37, in <module>
from physicsnemo.mesh import DomainMesh, Mesh
File "D:\PycharmProjects\physicsnemo\physicsnemo\mesh\__init__.py", line 17, in <module>
from physicsnemo.mesh.domain_mesh import DomainMesh
File "D:\PycharmProjects\physicsnemo\physicsnemo\mesh\domain_mesh.py", line 28, in <module>
from physicsnemo.mesh.mesh import Mesh, _requested_float_dtype
File "D:\PycharmProjects\physicsnemo\physicsnemo\mesh\mesh.py", line 52, in <module>
from physicsnemo.mesh.remeshing import remesh
File "D:\PycharmProjects\physicsnemo\physicsnemo\mesh\remeshing\__init__.py", line 45, in <module>
from physicsnemo.mesh.remeshing._partition import CellPartition, partition_cells
File "D:\PycharmProjects\physicsnemo\physicsnemo\mesh\remeshing\_partition.py", line 42, in <module>
from physicsnemo.nn.functional.neighbors import knn
File "D:\PycharmProjects\physicsnemo\physicsnemo\nn\__init__.py", line 20, in <module>
from .module.activations import (
File "D:\PycharmProjects\physicsnemo\physicsnemo\nn\module\__init__.py", line 28, in <module>
from .ball_query import BQWarp
File "D:\PycharmProjects\physicsnemo\physicsnemo\nn\module\ball_query.py", line 29, in <module>
from physicsnemo.nn.functional import radius_search
File "D:\PycharmProjects\physicsnemo\physicsnemo\nn\functional\__init__.py", line 17, in <module>
from .derivatives import (
File "D:\PycharmProjects\physicsnemo\physicsnemo\nn\functional\derivatives\__init__.py", line 17, in <module>
from .mesh_green_gauss_gradient import MeshGreenGaussGradient, mesh_green_gauss_gradient
File "D:\PycharmProjects\physicsnemo\physicsnemo\nn\functional\derivatives\mesh_green_gauss_gradient\__init__.py", line 17, in <module>
from .mesh_green_gauss_gradient import MeshGreenGaussGradient, mesh_green_gauss_gradient
File "D:\PycharmProjects\physicsnemo\physicsnemo\nn\functional\derivatives\mesh_green_gauss_gradient\mesh_green_gauss_gradient.py", line 24, in <module>
from ._warp_impl import mesh_green_gauss_gradient_warp
File "D:\PycharmProjects\physicsnemo\physicsnemo\nn\functional\derivatives\mesh_green_gauss_gradient\_warp_impl.py", line 607, in <module>
@torch.library.custom_op(
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PycharmProjects\physicsnemo\venv\Lib\site-packages\torch\_library\custom_ops.py", line 119, in inner
schema_str = torch._custom_op.impl.infer_schema(fn, mutates_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\PycharmProjects\physicsnemo\venv\Lib\site-packages\torch\_library\infer_schema.py", line 42, in infer_schema
error_fn(
File "D:\PycharmProjects\physicsnemo\venv\Lib\site-packages\torch\_library\infer_schema.py", line 21, in error_fn
raise ValueError(
ValueError: infer_schema(func): Parameter points has unsupported type torch.Tensor. The valid types are: dict_keys([<class 'torch.Tensor'>, typing.Optional[torch.Tensor], typing.Sequence[torch.Tensor], typing.List[torch.Tensor], typing.Sequence[typing.Optional[torch.Tensor]], typing.List[typing.Optional[torch.Tensor]], <class 'int'>, typing.Optional[int], typing.Sequence[int], typing.List[int], typing.Optional[typing.Sequence[int]], typing.Optional[typing.List[int]], <class 'float'>, typing.Optional[float], typing.Sequence[float], typing.List[float], typing.Optional[typing.Sequence[float]], typing.Optional[typing.List[float]], <class 'bool'>, typing.Optional[bool], typing.Sequence[bool], typing.List[bool], typing.Optional[typing.Sequence[bool]], typing.Optional[typing.List[bool]], <class 'str'>, typing.Optional[str], typing.Union[int, float, bool], typing.Union[int, float, bool, NoneType], typing.Sequence[typing.Union[int, float, bool]], typing.List[typing.Union[int, float, bool]], <class 'torch.dtype'>, typing.Optional[torch.dtype], <class 'torch.device'>, typing.Optional[torch.device]]). Got func with signature (points: 'torch.Tensor', cells: 'torch.Tensor', neighbors: 'torch.Tensor', values: 'torch.Tensor') -> 'torch.Tensor')
Process finished with exit code 1
Environment details
- Dominant language
- Python
- Stars
- 3.4k
- Forks
- 814
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 46
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/physicsnemo
-
Wasserstein CDF distance uses the first width for every binPossibly taken @sylvesterkaczmarek claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NVIDIA/physicsnemo#2042 ·
Maintainers usually reply within 1 day
-
🐛[BUG]: Darcy2D Jacobi kernel divides grad(k)·grad(u) by 2dx instead of 4dx², so the data doesn't solve the Darcy equationPossibly taken @coreyjadams claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/physicsnemo#2036 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
🐛[BUG]: Darcy2D permeability: all Fourier coefficients of a sample share one random value (bare wp.tid() in rand_init)Possibly taken @coreyjadams claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
NVIDIA/physicsnemo#2035 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
🐛[BUG]: MHD_PDE equation "B_grad_u" uses v * Bx.diff(y) instead of By * u.diff(y)Possibly taken @aaguadob claimed this 18 days ago. Open? - Needs Triage bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
NVIDIA/physicsnemo#2021 ·
Maintainers usually reply within 1 day
-
🐛[BUG]: Diffusion(time=True) in darcy_physics_informed/utils.py silently drops the time-derivative termPossibly taken @aaguadob claimed this 18 days ago. Open? - Needs Triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NVIDIA/physicsnemo#2020 ·
Maintainers usually reply within 1 day
All issues in NVIDIA/physicsnemo
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/policyengine-us#10262 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
kellyjonbrazil/jc#788 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
`/search.json` ignores the documented `editions.sort` parameterPossibly taken @PranavD2905 claimed this today. OpenAffects: Server Good First Issue Module: Solr Needs: Triage Theme: Public APIs Theme: Search
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
internetarchive/openlibrary#13989 · 1 comment ·
Maintainers usually reply within 1 day
-
bug P2: misleading query
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
jeffknupp/association#478 ·