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 — forward returns raw output, adapt_output() structures it into ModelOutputs — with none of the energy machinery (no neighbor lists, no autograd plumbing).

Concrete implementations must provide:

  • model_config attribute — a GenerativeModelConfig (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:

forward / adapt_output() are the model-side contract: the AtomisticGenerator never reads them; the generating function calls them. Materialization and conditioning belong to the procedure, so the mixin defines neither. A model may define a to_batch(sample, cond_batch=None) -> Batch helper 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 the AtomisticGenerator); the model is what the function samples from.

adapt_output(raw, data)[source]#

Map raw model output to ModelOutputs.

The default builds an OrderedDict keyed by GenerativeModelConfig.prediction_outputs (defaulting to {"flow"}). A dict-like raw fills matching keys; a single Tensor is 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:

OrderedDict with the active prediction outputs.

Return type:

ModelOutputs