agedi.api.sampling¶
Sampling from a trained diffusion model.
Functions¶
|
Sample structures from a trained diffusion model. |
Module Contents¶
- agedi.api.sampling.sample(diffusion: Agedi, *, n_samples: int, n_atoms: int | None = None, atomic_numbers: List[int] | None = None, formula: str | None = None, positions: numpy.ndarray | None = None, cell: numpy.ndarray | None = None, pbc: numpy.ndarray | None = None, template: agedi.data.AtomsGraph | ase.Atoms | None = None, confinement: Tuple[float, float] | None = None, compile: bool = False, steps: int = 500, eps: float = 0.001, batch_size: int = 64, ff_guidance: agedi.diffusion.ForcefieldGuidanceConfig | None = None, property: Dict[str, float] | None = None, progress_bar: bool = False, save_trajectory: bool = False, print_timings: bool = False, as_atoms: bool = True) List[agedi.data.AtomsGraph] | List[ase.Atoms] | List[List[agedi.data.AtomsGraph]] | List[List[ase.Atoms]]¶
Sample structures from a trained diffusion model.
- Parameters:
diffusion – A trained
Agedimodel.n_samples – Number of structures to generate.
n_atoms – Number of atoms per structure. Automatically determined from
formulaif provided, or from the length ofatomic_numberswhenn_atomsis not explicitly given.atomic_numbers – Atomic numbers of the generated atoms. Not required when the model has a types-noiser or when
formulais provided.formula – Chemical formula (e.g.
"H2O"). Used to deriven_atomsandatomic_numberswhen they are not provided explicitly.positions – Fixed positions of the atoms (shape
(n_atoms, 3)). Required when no positions-noiser is configured (type-only diffusion). Positions will not be modified during sampling.cell – Unit-cell matrix (3×3 array or flat length-9 array). Not required when
templateis provided (the template’s cell is used instead).pbc – Periodic boundary conditions as a length-3 boolean array (e.g.
[True, True, False]). Whentemplateis provided itspbcis used unless this argument is given explicitly. Defaults to[True, True, True](fully periodic) when neithertemplatenorpbcis supplied.template – Template structure. May be an
AtomsGraphor an ASEAtomsobject; the latter is automatically converted to anAtomsGraph(withconfinementapplied when provided). When given,cellandpbcare taken from the template unless explicitly provided.ff_guidance – Force-field guidance configuration. When
None(default) aForcefieldGuidanceConfigwith default values is used (i.e. guidance is disabled).compile – When
True, usetorch.compileon the reverse diffusion step for faster sampling. Before the sampling loop starts, the maximum number of neighbors and cell-list dimensions are estimated automatically via NVIDIA nvalchemiops (estimate_max_neighborsandestimate_cell_list_sizes), and all neighbor-list buffers are pre-allocated with fixed shapes. Requires NVIDIA nvalchemiops. Defaults toFalse.print_timings – When
True, print a per-stage timing breakdown at the end of each sampling batch (graph init, score model, denoise, neighbor list, etc.). Defaults toFalse.