nvalchemi.gen.GenerationPipeline#
- class nvalchemi.gen.GenerationPipeline(*, stages)[source]#
Sequential composition of generation and batch-processing stages.
- Parameters:
stages (Annotated[list[Any], MinLen(min_length=1)])
- stages#
Ordered pipeline stages:
AtomisticGeneratorinstances, dynamics engines, orBatch -> Batchcallables.- Type:
list[Any]
Notes
Field-contract validation. Every
AtomisticGeneratorstage must declarerequired_inputs/outputs(set on the AtomisticGenerator directly or defaulted from the generating function’s attributes); construction raises otherwise. For each adjacent AtomisticGenerator -> AtomisticGenerator link, the downstream stage’srequired_inputsmust be covered by the upstream stage’soutputs: the dynamics link contract (AIMNet2charges-> Ewald) applied to generation. Authors of custom generating functions own keeping their stage’s declaration in sync with what the function actually writes. Non-AtomisticGenerator stages carry no declarations and are not validated (their outputs are unknown at construction).The first stage’s
required_inputsdescribe its conditioning input and are not validated (the pipeline cannot know what a user’sinputscarries).Sessions and compile.
GenerationPipelineis a context manager: entry creates one dedicated CUDA stream (when the firstAtomisticGeneratorstage’s resolved device is CUDA) and shares it with every stage that follows the_streamconvention – AtomisticGenerator stages withdedicated_streamset, and any other stage that accepts a pre-set stream (dynamics engines and fused stages honor it) – then enters each stage’s own session.Stage calling convention. A stage with a
runmethod (a dynamics engine or a fused stage) is driven to completion withstage.run(batch, **kwargs)– its own hooks fire inside its loop. Any other stage is called asstage(batch, **kwargs). A dynamics stage must carry its own exit criterion (convergence orn_steps); the fold offers no step budget of its own.- compile(**kwargs)[source]#
Compile every AtomisticGenerator stage’s generating function.
Per-stage compilation (see
AtomisticGenerator.compile()); non-AtomisticGenerator stages are skipped. There is no whole-fold compile: the Batch plumbing and hook dispatch between stages would graph-break for no real capture. (Cross-stage tensor fusion is a separate research item.)- Parameters:
**kwargs (Any) – Forwarded to each stage’s
AtomisticGenerator.compile().- Returns:
This instance, for fluent chaining.
- Return type:
- model_config = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(_GenerationPipeline__context)[source]#
Initialize session state.
- Parameters:
_GenerationPipeline__context (Any)
- Return type:
None
- stream(inputs=None, *, max_batches=None, stage_kwargs=None)[source]#
Stream pipeline outputs, mirroring
AtomisticGenerator.stream().One fold per input item;
inputsis the data source.- Parameters:
inputs (Any) – Iterable of inputs, or
Nonefor repeated unconditional draws.max_batches (int | None) – Cap on batches yielded (
Nonemeans unbounded).stage_kwargs (Mapping[str, Any] | Sequence[Mapping[str, Any] | None] | None) – Per-call options addressed to stages, forwarded to
__call__()on every fold.
- Yields:
Any – One output per fold, exactly as produced.
- Return type:
Iterator[Any]