deploy.exporter#
Exporting potential models to serialized StableHLO bundles.
- class ParticleField(name: str, dtype: Any = <class 'jax.numpy.int32'>)[source]#
Descriptor for an additional scalar per-particle model input.
speciesis implicit and must not be registered here. Additional field semantics are defined by the exported model and its accompanying documentation.
- class GlobalField(name: str, dtype: Any = <class 'jax.numpy.float32'>)[source]#
Descriptor for a scalar model input shared by the full configuration.
- class OutputScope(value)[source]#
Declares the leading shape and engine reduction of an output.
PARTICLEoutputs have a leading particle axis.LOCALoutputs are additive rank-local configuration values that the engine adapter reduces once.GLOBALoutputs are complete configuration values and must not be reduced again.
- class OutputField(name: str, scope: OutputScope = OutputScope.PARTICLE, extensive: bool = False)[source]#
Descriptor for an auxiliary model output.
scopecontrols the particle axis and MPI reduction.extensiverecords whether a configuration value scales with system size so an engine can normalize it correctly. Extensivity does not change reduction scope and is not valid forPARTICLEoutputs.- scope: OutputScope#
Alias for field number 1
- class Exporter[source]#
Exports a potential model to a serialized StableHLO bundle.
Subclasses select a graph representation and implement
energy_fn(). The deployment documentation contains complete export examples.- Variables:
graph_type (chemtrain.deploy.graphs.NeighborList) – Graph representation used for engine neighbor data.
nbr_order (List[int]) – Two neighbor orders used with Newton on and Newton off, respectively.
r_cutoff (float) – Model cutoff radius.
unit_style (str) – Unit style used for positions and energies. Force units follow from the length and energy units.
position_dtype (Any) – Floating-point dtype of the position input and its force and virial derivatives. The energy function determines the dtypes of its calculations and returned values. Engine adapters may use a different floating-point dtype because the connector converts at the engine ABI boundary.
has_aux (bool) – If
True,energy_fnreturns(particle_energy, outputs).particle_fields (Tuple[chemtrain.deploy.exporter.ParticleField, ...]) – Ordered descriptors for additional scalar
int32arrays supplied throughparticle_data. Zero-basedspeciesis always provided and must not be registered explicitly.global_fields (Tuple[chemtrain.deploy.exporter.GlobalField, ...]) – Ordered descriptors for scalar inputs supplied through
global_data. Global field values may vary between force calls.output_fields (Tuple[chemtrain.deploy.exporter.OutputField, ...]) – Ordered descriptors for auxiliary outputs and their
PARTICLE,LOCAL, orGLOBALscope. Configuration outputs also declare whether they are extensive. Shapes are inferred during tracing.communication_required (bool) – If
True, callers must select the communication-enabled variant.include_pair_type (bool) – If
True, exposes engine topology categories asgraph.pair_type.
- abstractmethod energy_fn(position, particle_data, graph, comm=None)[source]#
Computes particle energies for positions and a graph.
- Parameters:
position – (N, dim) Array of particle positions, including ghost atoms that are not within the local domain.
particle_data – Mapping containing the built-in zero-based scalar
int32speciesarray and every registered additional scalar array, with one value per particle.graph – Graph representation of the neighborhood around atoms. If
include_pair_typeis enabled,graph.pair_typecontains aligned topology categories, with zero used for unclassified and padding entries.comm – Optional communication interface. Models that use communication call
comm.gatherorcomm.reduceat fixed locations in the traced computation.
- Returns:
An energy contribution for each particle. If
has_auxisTrue, return(energy, outputs). Output keys must matchoutput_fields.PARTICLEoutputs start with the particle axis, whileLOCALandGLOBALoutputs describe one configuration.
- export(*, communication=False, custom_calls=(), platforms=('cuda',))[source]#
Exports model variants specialized by communication and Newton mode.
Every bundle contains the two variants without model communication, one for each Newton mode.
communication=Truealso adds the communication-enabled Newton-on variant.custom_callslists additional model-specific FFI targets, whileplatformsselects CPU, CUDA, or both implementations in each variant.- Return type:
- graph_type#
alias of
SimpleSparseNeighborList
Custom Calls#
The following targets support exported models that use OpenEquivariance:
- OPENEQUIVARIANCE_CUSTOM_CALLS = ('conv_forward', 'conv_backward', 'conv_double_backward')#
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.