Operator Models#

class physicsnemo.models.domino.model.DoMINO(*args, **kwargs)[source]#

Bases: Module

DoMINO model architecture for predicting both surface and volume quantities.

The DoMINO (Deep Operational Modal Identification and Nonlinear Optimization) model is designed to model both surface and volume physical quantities in aerodynamic simulations. It can operate in three modes:

  1. Surface-only: Predicting only surface quantities

  2. Volume-only: Predicting only volume quantities

  3. Combined: Predicting both surface and volume quantities

The model uses a combination of:

  • Geometry representation modules via GeometryRep

  • Neural network basis functions via FourierMLP

  • Parameter encoding

  • Local and global geometry processing

  • Aggregation models for final prediction

Parameters:
  • input_features (int) – Number of point input features (typically 3 for x, y, z coordinates).

  • output_features_vol (int, optional, default=None) – Number of output features in volume. Set to None for surface-only mode.

  • output_features_surf (int, optional, default=None) – Number of output features on surface. Set to None for volume-only mode.

  • global_features (int, optional, default=2) – Number of global parameter features for conditioning.

  • model_parameters (Any, optional, default=None) – Model parameters controlled by config.yaml. Contains nested configuration for geometry representation, neural network basis functions, aggregation model, position encoder, and geometry local settings.

Forward:

data_dict (dict[str, torch.Tensor]) – Dictionary containing input tensors with the following keys:

  • "geometry_coordinates": Geometry centers of shape \((B, N_{geo}, 3)\)

  • "grid": Computational domain grid of shape \((B, N_x, N_y, N_z, 3)\)

  • "surf_grid": Surface bounding box grid of shape \((B, N_x, N_y, N_z, 3)\)

  • "sdf_grid": SDF on volume grid of shape \((B, N_x, N_y, N_z)\)

  • "sdf_surf_grid": SDF on surface grid of shape \((B, N_x, N_y, N_z)\)

  • "sdf_nodes": SDF at volume mesh nodes of shape \((B, N_{vol}, 1)\)

  • "pos_volume_closest": Closest surface point to volume nodes of shape \((B, N_{vol}, 3)\)

  • "pos_volume_center_of_mass": Center of mass to volume nodes of shape \((B, N_{vol}, 3)\)

  • "pos_surface_center_of_mass": Center of mass to surface nodes of shape \((B, N_{surf}, 3)\)

  • "surface_mesh_centers": Surface mesh center coordinates of shape \((B, N_{surf}, 3)\)

  • "surface_mesh_neighbors": Surface mesh neighbor coordinates of shape \((B, N_{surf}, K, 3)\)

  • "surface_normals": Surface normals of shape \((B, N_{surf}, 3)\)

  • "surface_neighbors_normals": Surface neighbor normals of shape \((B, N_{surf}, K, 3)\)

  • "surface_areas": Surface cell areas of shape \((B, N_{surf})\)

  • "surface_neighbors_areas": Surface neighbor areas of shape \((B, N_{surf}, K)\)

  • "volume_mesh_centers": Volume mesh center coordinates of shape \((B, N_{vol}, 3)\)

  • "volume_min_max": Volume bounding box min/max of shape \((B, 2, 3)\)

  • "surface_min_max": Surface bounding box min/max of shape \((B, 2, 3)\)

  • "global_params_values": Global parameter values of shape \((B, N_{params}, 1)\)

  • "global_params_reference": Global parameter reference values of shape \((B, N_{params}, 1)\)

Outputs:

tuple[torch.Tensor | None, torch.Tensor | None] – A tuple containing:

  • Volume output tensor of shape \((B, N_{vol}, D_{vol})\) or None if volume-only mode is disabled

  • Surface output tensor of shape \((B, N_{surf}, D_{surf})\) or None if surface-only mode is disabled

Example

>>> from physicsnemo.models.domino.model import DoMINO
>>> from physicsnemo.models.domino.config import DEFAULT_MODEL_PARAMS
>>> import torch
>>> device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
>>> cfg = DEFAULT_MODEL_PARAMS  # already has model_type "combined"
>>> model = DoMINO(
...         input_features=3,
...         output_features_vol=5,
...         output_features_surf=4,
...         model_parameters=cfg
...     ).to(device)
>>> bsize = 1
>>> nx, ny, nz = cfg.interp_res
>>> num_neigh = cfg.num_neighbors_surface
>>> global_features = 2
>>> pos_normals_closest_vol = torch.randn(bsize, 100, 3).to(device)
>>> pos_normals_com_vol = torch.randn(bsize, 100, 3).to(device)
>>> pos_normals_com_surface = torch.randn(bsize, 100, 3).to(device)
>>> geom_centers = torch.randn(bsize, 100, 3).to(device)
>>> grid = torch.randn(bsize, nx, ny, nz, 3).to(device)
>>> surf_grid = torch.randn(bsize, nx, ny, nz, 3).to(device)
>>> sdf_grid = torch.randn(bsize, nx, ny, nz).to(device)
>>> sdf_surf_grid = torch.randn(bsize, nx, ny, nz).to(device)
>>> sdf_nodes = torch.randn(bsize, 100, 1).to(device)
>>> surface_coordinates = torch.randn(bsize, 100, 3).to(device)
>>> surface_neighbors = torch.randn(bsize, 100, num_neigh, 3).to(device)
>>> surface_normals = torch.randn(bsize, 100, 3).to(device)
>>> surface_neighbors_normals = torch.randn(bsize, 100, num_neigh, 3).to(device)
>>> surface_sizes = torch.rand(bsize, 100).to(device) + 1e-6 # Note this needs to be > 0.0
>>> surface_neighbors_areas = torch.rand(bsize, 100, num_neigh).to(device) + 1e-6
>>> volume_coordinates = torch.randn(bsize, 100, 3).to(device)
>>> vol_grid_max_min = torch.randn(bsize, 2, 3).to(device)
>>> surf_grid_max_min = torch.randn(bsize, 2, 3).to(device)
>>> global_params_values = torch.randn(bsize, global_features, 1).to(device)
>>> global_params_reference = torch.randn(bsize, global_features, 1).to(device)
>>> input_dict = {
...            "pos_volume_closest": pos_normals_closest_vol,
...            "pos_volume_center_of_mass": pos_normals_com_vol,
...            "pos_surface_center_of_mass": pos_normals_com_surface,
...            "geometry_coordinates": geom_centers,
...            "grid": grid,
...            "surf_grid": surf_grid,
...            "sdf_grid": sdf_grid,
...            "sdf_surf_grid": sdf_surf_grid,
...            "sdf_nodes": sdf_nodes,
...            "surface_mesh_centers": surface_coordinates,
...            "surface_mesh_neighbors": surface_neighbors,
...            "surface_normals": surface_normals,
...            "surface_neighbors_normals": surface_neighbors_normals,
...            "surface_areas": surface_sizes,
...            "surface_neighbors_areas": surface_neighbors_areas,
...            "volume_mesh_centers": volume_coordinates,
...            "volume_min_max": vol_grid_max_min,
...            "surface_min_max": surf_grid_max_min,
...            "global_params_reference": global_params_values,
...            "global_params_values": global_params_reference,
...        }
>>> output = model(input_dict)
>>> print(f"{output[0].shape}, {output[1].shape}")
torch.Size([1, 100, 5]), torch.Size([1, 100, 4])

Note

At least one of output_features_vol or output_features_surf must be specified.

Domino Utils#

Utilities for working with the Domino model, including data processing and grid construction. These utilities are essential for implementing and training Domino-based models.

DoMINO Utility Functions.

This module provides utility functions for the DoMINO model, including data preprocessing, normalization, grid creation, and sampling utilities.

SMART (Experimental)#

SMART encodes sampled geometry into latent contexts and predicts surface or volume fields at independent query coordinates. This implementation is based on the SMART paper. See the unified external aerodynamics recipe for training and inference.

class physicsnemo.experimental.models.smart.SMART(*args, **kwargs)[source]#

Bases: Module

Mesh-free steady-field surrogate derived from the SMART paper.

Encodes geometry once into one latent set per depth and decodes each spatial query independently. Each instance predicts either surface or volume fields. The selected output head determines the field channels. See SMART.

Parameters:
  • field ({"surface", "volume"}, optional, default="surface") – Field predicted by this model. Only this output head is constructed.

  • out_dim (int, optional, default=1) – Number of output channels.

  • parameter_channels (int, optional, default=0) – Number of scalar simulation conditions per geometry.

  • hidden_dim (int, optional, default=256) – Latent feature width, divisible by num_heads.

  • num_heads (int, optional, default=8) – Attention heads. An implementation choice not specified in the paper.

  • num_layers (int, optional, default=6) – Matched encoder and decoder depth.

  • num_latents (int, optional, default=2048) – Maximum coarse geometry size. Small inputs use all available points.

  • geometry_subsample (int, optional, default=65536) – Maximum geometry points attended to at each depth.

  • mlp_ratio (int, optional, default=4) – Hidden expansion of the modulated MLPs.

  • share_weights (bool, optional, default=True) – Share each encoder refinement with its corresponding decoder refinement.

  • eval_seed (int, optional, default=0) – Fixed geometry sampling seed during evaluation. Training uses the active RNG or the generator supplied to encode_geometry().

  • qk_normalization (bool, optional, default=False) – Normalize projected queries and keys by their per-head RMS in float32, with unit gain unless qk_temperature_max enables a bounded learned gain. Bounds attention logits against weight growth. This changes the attention function; train a new model when enabling it. Disabled preserves the original paper-derived implementation.

  • qk_temperature_max (float or None, optional, default=None) – Optional upper bound (> 1) on a learned per-head multiplier of normalized attention logits, initialized at 1. Requires qk_normalization=True. This bounded-temperature extension is not specified by the paper.

  • query_feature_channels (int, optional, default=0) – Aligned geometric feature channels. For example, surface normals or volume distance/direction features. Their projection starts at zero. This feature extension is not specified by the paper.

  • eval_chunk_size (int, optional, default=8192) – Maximum number of queries decoded at once during evaluation.

  • coordinate_scale (tuple of three positive floats, optional, default=(1, 1, 1)) – Axis scales applied to both point clouds after subtracting frame_center.

  • center_on_geometry (bool, optional, default=False) – When frame_center is omitted, center both clouds on the geometry’s bounding-box midpoint before scaling.

Forward:
  • geometry, queries (torch.Tensor) – Separate geometry and query clouds of shape \((B,N,3)\) and \((B,M,3)\).

  • parameters (torch.Tensor or None, optional, default=None) – Conditions of shape \((B,P)\) or \((B,1,P)\).

  • query_features (torch.Tensor or None, optional, default=None) – Aligned features of shape \((B,M,C)\) in the caller’s chosen units.

  • frame_center (torch.Tensor or None, optional, default=None) – Origin of shape \((B,3)\) or \((B,1,3)\). Overrides center_on_geometry. When omitted, use the geometry’s bounding-box midpoint if center_on_geometry=True, otherwise zero.

Outputs:

torch.Tensor – Field predictions of shape \((B,M,\mathrm{out\_dim})\).

Notes

Mixed precision follows the caller’s torch.autocast() context. Coordinates must be finite. forward normalizes both clouds together. Low-level encode_geometry and decode_queries expect coordinates already in the model frame. Padding is not supported. Use fixed-size sampled batches or batch size one for ragged clouds. Sampling is without replacement. Evaluation is repeatable for a fixed ordered cloud. Random-key sampling selects different subsets from earlier randperm-based versions for the same seed. A permutation can change the selected subset. Permutation invariance holds when all geometry points are retained, up to floating-point rounding.

decode_queries() can be compiled independently and evaluated in chunks against cached latents. Cache validity depends on geometry, parameters, weights, dtype, and device. Re-encode after any of these change.

Examples

>>> model = SMART(hidden_dim=24, num_heads=4, num_layers=2,
...               num_latents=8, geometry_subsample=16).eval()
>>> geometry = torch.randn(2, 32, 3)
>>> pressure = model(geometry, torch.randn(2, 12, 3))
>>> pressure.shape
torch.Size([2, 12, 1])
decode_queries(
queries: Float[Tensor, 'batch query_points 3'],
contexts: tuple[Float[Tensor, 'batch latents hidden_dim'], ...],
parameters: Float[Tensor, 'batch parameter_channels'] | None = None,
*,
query_features: Float[Tensor, 'batch query_points feature_channels'] | None = None,
) → Float[Tensor, 'batch query_points output_channels'][source]#

Evaluate independent queries against cached geometry contexts.

Parameters:
  • queries (torch.Tensor) – Coordinates of shape \((B,M,3)\); \(M=0\) is supported.

  • contexts (tuple[torch.Tensor, ...]) – The num_layers contexts returned by encode_geometry().

  • parameters (torch.Tensor or None, optional, default=None) – The same \((B,P)\) conditions used to encode the geometry.

  • query_features (torch.Tensor or None, optional, default=None) – Aligned geometric features of shape \((B,M,C)\). When evaluating chunks, slice these with the same indices as queries.

Returns:

Predictions of shape \((B,M,C)\) for the selected head.

Return type:

torch.Tensor

encode_geometry(
geometry: Float[Tensor, 'batch geometry_points 3'],
parameters: Float[Tensor, 'batch parameter_channels'] | None = None,
*,
generator: Generator | None = None,
) → tuple[Float[Tensor, 'batch latents hidden_dim'], ...][source]#

Build intermediate geometry latents without observing spatial queries.

Parameters:
  • geometry (torch.Tensor) – Point cloud of shape \((B,N,3)\), with \(N>0\).

  • parameters (torch.Tensor or None, optional, default=None) – Conditions of shape \((B,P)\).

  • generator (torch.Generator or None, optional, default=None) – Sampling RNG on the geometry device. Overrides eval_seed.

Returns:

One \((B,\min(N,K),D)\) context per layer. Gradients are retained.

Return type:

tuple[torch.Tensor, …]

forward(
geometry: Float[Tensor, 'batch geometry_points 3'],
queries: Float[Tensor, 'batch query_points 3'],
parameters: Float[Tensor, 'batch ... parameter_channels'] | None = None,
*,
query_features: Float[Tensor, 'batch query_points feature_channels'] | None = None,
frame_center: Float[Tensor, '...'] | None = None,
) → Float[Tensor, 'batch query_points out_dim'][source]#

Encode geometry once and predict the configured field at query points.

Training samples geometry using the active PyTorch RNG. Evaluation uses eval_seed to keep geometry sampling fixed across query chunks.

Parameters:
  • geometry (torch.Tensor) – Separate point clouds of shape \((B,N,3)\) and \((B,M,3)\).

  • queries (torch.Tensor) – Separate point clouds of shape \((B,N,3)\) and \((B,M,3)\).

  • parameters (torch.Tensor or None, optional, default=None) – Conditions of shape \((B,P)\) or \((B,1,P)\).

  • query_features (torch.Tensor or None, optional, default=None) – Aligned features of shape \((B,M,C)\).

  • frame_center (torch.Tensor or None, optional, default=None) – Coordinate origin of shape \((B,3)\) or \((B,1,3)\). A three-element tensor broadcasts one origin across the batch. Overrides center_on_geometry. When omitted, use the geometry’s bounding-box midpoint if center_on_geometry=True, otherwise zero. Both clouds are divided by coordinate_scale.

Returns:

Predictions of shape \((B,M,\mathrm{out\_dim})\). Evaluation decodes at most eval_chunk_size queries at once.

Return type:

torch.Tensor

AB-UPT (Experimental)#

AB-UPT uses geometry supernodes and interacting surface/volume anchor streams to define a query-independent field. The independent implementation follows the AB-UPT paper, without research implementation code, weights, or reference outputs. It supports joint or single-branch prediction, reusable per-forward contexts, and finite-difference vorticity with physical scaling. See the class notes for implementation choices where the paper does not specify details.

Single-branch configurations are ablations of the coupled architecture: setting volume_channels=0 removes the volume branch and its anchor inputs, while setting surface_channels=0 removes the surface branch. Cross-branch blocks become self-attention blocks to preserve depth. Joint configurations retain both interacting streams. The public forward handles coordinate and conditioning scaling, query chunking, and optional anchor supervision; low-level encode/decode methods operate in the scaled model frame.

class physicsnemo.experimental.models.ab_upt.ABUPT(*args, **kwargs)[source]#

Bases: Module

Anchored-Branched Universal Physics Transformer for 3D fields.

Geometry is reduced by radius-based supernode pooling and one Transformer block. Surface and volume anchors then attend to geometry, exchange information through shared self/cross-attention blocks, and pass through branch-specific decoder blocks. Queries follow the same layers using only cached anchor keys and values (paper Eq. 9).

Parameters:
  • surface_channels (int, optional, default=4) – Surface output channels. Zero removes the entire surface branch.

  • volume_channels (int, optional, default=7) – Volume output channels. Zero removes the entire volume branch.

  • hidden_dim (int, optional, default=192) – Token width, divisible by num_heads.

  • num_heads (int, optional, default=3) – Attention heads. Each head must have at least six channels for 3D RoPE.

  • num_interaction_blocks (int, optional, default=2) – Pairs of shared within-branch and cross-branch attention blocks. With one branch enabled, both blocks use self-attention, preserving depth.

  • num_shared_layers (int, optional, default=1) – Shared within-branch blocks after the interactions.

  • num_decoder_layers (int, optional, default=6) – Independently parameterized blocks per enabled output branch.

  • mlp_ratio (int, optional, default=4) – Feed-forward expansion ratio.

  • pooling_radius (float, optional, default=0.25) – Geometry neighborhood radius, in the supplied coordinate units.

  • pooling_chunk_size (int, optional, default=4096) – Maximum messages embedded at once. Also bounds reference-point chunks for the PyTorch radius search backend on either CPU or CUDA.

  • parameter_channels (int, optional, default=0) – Optional global conditioning channels, broadcast to both branches.

  • radius_search_backend ({None, "torch", "warp"}, optional, default=None) – None selects Warp on CPU and CUDA, except for float64 coordinates, which use PyTorch to preserve precision. Neighbor search is discrete; message passing remains differentiable in coordinates. Warp searches in float32; the PyTorch backend preserves float64 inputs.

  • pooling_message_fp32 (bool, optional, default=False) – Disable autocast for the geometry message MLP to reduce sensitivity to pooling chunk size. Requires float32 message weights under AMP; explicit float64 models retain double precision. This is an optional numerical variant, not a precision setting specified by the paper.

  • coordinate_scale (float, optional, default=1.0) – Multiplier applied by forward to coordinates and to the configured pooling_radius. Low-level encode/decode methods use scaled coordinates.

  • parameter_scale (float, optional, default=1.0) – Divisor applied by forward to global conditioning values.

  • query_chunk_size (int, optional, default=4096) – Maximum queries decoded at once using a single shared anchor context. Bounds individual attention operations, not the full autograd graph.

  • train_on_anchors (bool, optional, default=False) – Use anchor predictions during training. Supplied queries must equal their anchors in shape, coordinates, and order. Evaluation decodes queries.

Forward:
  • geometry (torch.Tensor) – Geometry point cloud of shape \((B,N_g,3)\).

  • supernodes (torch.Tensor) – Selected geometry supernode coordinates of shape \((B,S,3)\). Normally a uniform subset of geometry; chosen by the caller.

  • surface_anchors (torch.Tensor or None, optional, default=None) – Fixed surface anchor coordinates of shape \((B,M_s,3)\), required when the surface branch is enabled and otherwise omitted.

  • volume_anchors (torch.Tensor or None, optional, default=None) – Fixed volume anchor coordinates of shape \((B,M_v,3)\), required when the volume branch is enabled and otherwise omitted.

  • surface_queries (torch.Tensor or None, optional, default=None) – Surface query coordinates of shape \((B,Q_s,3)\). None uses predictions at the surface anchors without another decoder pass.

  • volume_queries (torch.Tensor or None, optional, default=None) – Volume query coordinates of shape \((B,Q_v,3)\). None uses predictions at the volume anchors.

  • parameters (torch.Tensor or None, optional, default=None) – Global conditions of shape \((B,P)\) or \((B,1,P)\), required exactly when parameter_channels > 0.

Outputs:

tuple[torch.Tensor or None, torch.Tensor or None] – Surface and volume predictions, respectively, with shapes \((B,Q_s,C_s)\) and \((B,Q_v,C_v)\). Disabled heads return None. When queries are omitted, \(Q_s=M_s\) and \(Q_v=M_v\).

Notes

Independently implemented from the AB-UPT paper. Defaults give the 12-block DrivAerML branch layout in Appendix C.3: 1 geometry cross-attention, 4 interleaved blocks, 1 shared self-attention, and 6 branch-specific blocks. The paper leaves some details unspecified; this implementation uses mean message aggregation, GELU MLPs, axis-wise sinusoidal/RoPE encodings, and no dropout. It does not claim numerical compatibility with the research code.

Single-branch models are ablations of the paper’s coupled architecture: they retain geometry encoding and anchor decoding, replace cross-branch attention with self-attention, and require no inactive-branch inputs.

Sampling belongs to the caller. Input coordinates and the configured pooling_radius must use the same units. forward scales both by coordinate_scale and casts inputs to the model weight dtype. The positional frequencies span approximately 1 to 1e-4; coordinates of order 1000 exercise more frequency bands than unit-scale coordinates. When rescaling coordinates, rescale the radius as well; the default radius is in caller-supplied units.

Queries must never be used to resample anchors between chunks. encode() / decode_queries() expose this separation, and decode_vorticity() implements the paper’s finite-difference curl with normalization corrections. Direct volume outputs are not constrained to equal the curl; the helper computes it separately from predicted velocity.

Examples

>>> import torch
>>> from physicsnemo.experimental.models.ab_upt import ABUPT
>>> model = ABUPT(hidden_dim=24, num_heads=3, num_interaction_blocks=1,
...               num_shared_layers=0, num_decoder_layers=1)
>>> geometry = torch.rand(1, 20, 3)
>>> supernodes = geometry[:, ::4]
>>> surface = geometry[:, 1::3]
>>> volume = torch.rand(1, 7, 3)
>>> pressure, flow = model(geometry, supernodes, surface, volume)
>>> pressure.shape, flow.shape
(torch.Size([1, 7, 4]), torch.Size([1, 7, 7]))
decode_queries(
queries: Float[Tensor, 'B Q 3'],
context: ABUPTContext,
field: Literal['surface', 'volume'] = 'surface',
) → Float[Tensor, 'B Q C'][source]#

Evaluate independent query coordinates using one fixed context.

Parameters:
  • queries (torch.Tensor) – Coordinates of shape \((B,Q,3)\). Empty query sets are allowed.

  • context (ABUPTContext) – Context from encode() with the same batch size and device.

  • field ({"surface", "volume"}, optional, default="surface") – Enabled output branch to evaluate.

Returns:

Predictions of shape \((B,Q,C)\) independent of other queries.

Return type:

torch.Tensor

decode_vorticity(
queries: Float[Tensor, 'B Q 3'],
context: ABUPTContext,
step: float = 0.001,
velocity_channels: tuple[int, int, int] = (1, 2, 3),
coordinate_scale: tuple[float, float, float] = (1.0, 1.0, 1.0),
velocity_scale: tuple[float, float, float] = (1.0, 1.0, 1.0),
) → Float[Tensor, 'B Q 3'][source]#

Approximate physical vorticity with the curl in paper Eq. 11.

Parameters:
  • queries (torch.Tensor) – Network-space coordinates of shape \((B,Q,3)\).

  • context (ABUPTContext) – Fixed context shared by all six offset evaluations.

  • step (float, optional, default=1.0e-3) – Central-difference step in network coordinate units.

  • velocity_channels (tuple[int, int, int], optional, default=(1, 2, 3)) – Volume output indices for x/y/z velocity, respectively.

  • coordinate_scale (tuple[float, float, float], optional, default=(1.0, 1.0, 1.0)) – Diagonal scaling from physical to network coordinates.

  • velocity_scale (tuple[float, float, float], optional, default=(1.0, 1.0, 1.0)) – Diagonal scaling from network to physical velocity. Additive normalization offsets cancel when differentiating.

Returns:

Physical vorticity of shape \((B,Q,3)\). Central differences approximate the continuous curl; their error depends on step and precision. Offset evaluations disable autocast and use the model’s float32 or float64 weight dtype, including cached keys, values, and conditioning. Explicit half-precision weights are not supported. Gradients propagate to the model and context.

Return type:

torch.Tensor

encode(
geometry: Float[Tensor, 'B Ng 3'],
supernodes: Float[Tensor, 'B S 3'],
surface_anchors: Float[Tensor, 'B Ms 3'] | None = None,
volume_anchors: Float[Tensor, 'B Mv 3'] | None = None,
parameters: Float[Tensor, 'B P'] | None = None,
) → ABUPTContext[source]#

Build a reusable field context from geometry and fixed anchors.

Parameters:
  • geometry (torch.Tensor) – Geometry coordinates of shape \((B,N_g,3)\).

  • supernodes (torch.Tensor) – Geometry supernodes of shape \((B,S,3)\).

  • surface_anchors (torch.Tensor or None, optional, default=None) – Surface anchors of shape \((B,M_s,3)\). Omit for volume-only.

  • volume_anchors (torch.Tensor or None, optional, default=None) – Volume anchors of shape \((B,M_v,3)\). Omit for surface-only.

  • parameters (torch.Tensor or None, optional, default=None) – Global conditions of shape \((B,P)\).

Returns:

Layer contexts and anchor predictions, retaining their autograd graph for training. In joint mode, streams interact synchronously.

Return type:

ABUPTContext

encode_geometry(
geometry: Float[Tensor, 'B Ng 3'],
supernodes: Float[Tensor, 'B S 3'],
) → Float[Tensor, 'B S D'][source]#

Pool local geometry and exchange information between supernodes.

Parameters:
  • geometry (torch.Tensor) – Geometry coordinates of shape \((B,N_g,3)\).

  • supernodes (torch.Tensor) – Supernode coordinates of shape \((B,S,3)\).

Returns:

Encoded geometry of shape \((B,S,d)\).

Return type:

torch.Tensor

class physicsnemo.experimental.models.ab_upt.ABUPTContext(
surface: tuple[tuple[Tensor, Tensor], ...],
volume: tuple[tuple[Tensor, Tensor], ...],
surface_predictions: Tensor | None,
volume_predictions: Tensor | None,
conditioning: Tensor | None,
)[source]#

Per-forward anchor context returned by ABUPT.encode().

Parameters:
  • surface (tuple[tuple[torch.Tensor, torch.Tensor], ...]) – Projected keys and values for each surface layer. Each tensor has shape \((B,H,M,D_h)\), with \(H\) heads, \(M\) source tokens, and head width \(D_h\). Keys already include rotary position encoding. The first pair represents geometry supernodes and is shared by the enabled branches. Later pairs represent that layer’s source anchors (the opposite branch for cross attention, the same branch for self-attention).

  • volume (tuple[tuple[torch.Tensor, torch.Tensor], ...]) – Corresponding volume contexts of shape \((B,H,M,D_h)\) per layer. Either branch’s context is empty when that branch is disabled.

  • surface_predictions (torch.Tensor or None) – Predictions at surface anchors, shape \((B,M_s,C_s)\).

  • volume_predictions (torch.Tensor or None) – Predictions at volume anchors, shape \((B,M_v,C_v)\).

  • conditioning (torch.Tensor or None) – Embedded global conditions of shape \((B,1,d)\).

Notes

Caches retain their autograd graph. Reuse them for chunks of the same sample, model weights, device, precision, and training step only. They are not model state or persistent checkpoints. No query tokens enter a cache.