nvalchemi.gen.GenerationStage#
- class nvalchemi.gen.GenerationStage(*values)[source]#
Stages of the
AtomisticGeneratorpipeline.One stage per distinct point of the fixed pipeline (optionally condition the inputs, then generate — a
Batchreturn takes the contract path). Hooks mutate theGenerationContextby replacing its fields, and the driver re-reads the context after each dispatch. Hooks at one stage run in list order, and a raising hook aborts the call (nothing catches it).Firing policy:
BEFORE_CONDITION/AFTER_CONDITIONfire only when a condition step was provided for the call (the driver’scondition_funcor the generating function’sconditionattribute);AFTER_GENERATEfires only when the sample is aBatch.- BEFORE_CONDITION#
Fired before the condition step runs;
ctx.inputsholds the call’s raw input (andctx.batchholds it too when it is aBatch,Noneotherwise). Edit or replacectx.inputshere — the condition callable receives whateverctx.inputsholds after this dispatch. Fires only when a condition step was provided for the call.
- AFTER_CONDITION#
Fired after the condition step;
ctx.inputsholds the conditioned value the generating function is about to be called with (e.g. a conditioningBatchtiled bynum_samples). Attach conditioning metadata (e.g. text embeddings for classifier-free guidance) or replace the conditioned input here. Fires only when a condition step was provided for the call.
- AFTER_GENERATE#
Fired after generation when the sample is a
Batch;ctx.batchholds it. A function returning a non-Batchcontainer skips this stage. Filter or mutate the generated batch here — filtering is graph-level subsetting (ctx.batch = ctx.batch[keep]). The batch may already be zero-graph (a function may signal total rejection viaempty()), so filters should toleratenum_graphs == 0. Zero-graph selections still raiseIndexError— a hook signalling total rejection replacesctx.batchwith an explicitly built empty batch rather than subsetting to nothing.