nvalchemi.models.gen.GenerativeModelMixin#
- class nvalchemi.models.gen.GenerativeModelMixin[source]#
Mixin class for models designed for generative workflows.
This is the counterpart to
BaseModelMixin. It mirrors the two-step output pattern —forwardreturns raw output,adapt_output()structures it intoModelOutputs— with none of the energy machinery (no neighbor lists, no autograd plumbing).Concrete implementations must provide:
model_configattribute — aGenerativeModelConfig(or a subclass of it) set in__init__(enforced by__init_subclass__()).forward()— raw model output for one forward call.
The mixin provides defaults for:
adapt_output(): maps raw output toModelOutputs, keyed byGenerativeModelConfig.prediction_outputs(defaulting to{"flow"}).
forward/adapt_output()are the model-side contract: theAtomisticGeneratornever reads them; the generating function calls them. Materialization and conditioning belong to the procedure, so the mixin defines neither. A model may define ato_batch(sample, cond_batch=None) -> Batchhelper for its generating function to call (the demos do); nothing in the framework looks for it.Classes using this mixin do not own the generation process: that lives with the
GeneratingFunction(driven by theAtomisticGenerator); the model is what the function samples from.- adapt_output(raw, data)[source]#
Map raw model output to
ModelOutputs.The default builds an
OrderedDictkeyed byGenerativeModelConfig.prediction_outputs(defaulting to{"flow"}). A dict-likerawfills matching keys; a singleTensoris placed under the"flow"key (or the single configured key).- Parameters:
raw (Any) – Raw output from
forward().data (AtomicData | Batch) – Source structure data (for context/metadata).
- Returns:
OrderedDictwith the active prediction outputs.- Return type:
ModelOutputs