nemo_rl.algorithms.single_controller_utils.step_assembly#
Step-assembly accounting for the SingleController train pump.
Owns the cursor over the step the train pump is assembling and charges a
permanently lost prompt group to the step that will close short for it. Kept out
of SingleControllerActor so the assembling cursor, its step-assembly record
and the shortfall-crediting rules live in one place; the controller drives it
through begin_step/finish_step and the per-loss credit_shortfall.
Module Contents#
Classes#
Track the step being assembled and charge lost groups to it. |
API#
- class nemo_rl.algorithms.single_controller_utils.step_assembly.ShortfallCredit#
- target_step: Optional[int]#
None
- charged_step: int#
None
- allow_short: bool#
None
- class nemo_rl.algorithms.single_controller_utils.step_assembly.StepAssembly#
- version: int#
None
- selected_groups: int#
None
- selection_credits: Optional[list[nemo_rl.algorithms.single_controller_utils.step_assembly.ShortfallCredit]]#
None
- class nemo_rl.algorithms.single_controller_utils.step_assembly.StepAssembler(
- *,
- sampler: nemo_rl.algorithms.async_utils.staleness_sampler.PromptGroupSampler,
- num_prompts_per_step: int,
- runtime: nemo_rl.algorithms.rollout_checkpointing.state.RolloutRuntimeState,
- initial_version: int,
Track the step being assembled and charge lost groups to it.
Holds the sampler, the per-step prompt-group target and the shared
RolloutRuntimeStateobject directly. The runtime’sbatch_shortfall/steps_allowed_short/shortfall_reconciliation_pendingmaps and sets are read live off that object, so restore replacements stay visible. The cursor starts from the restored trainer version so step0stays valid after a restore.Initialization
- property assembling_version: int#
The step the train pump is selecting groups for, or will select next.
- property step_assembly: Optional[nemo_rl.algorithms.single_controller_utils.step_assembly.StepAssembly]#
The open step’s assembly record, or
Nonebetween steps.
- begin_step(version: int) None#
Open a fresh step’s assembly record at
version.
- finish_step(version_during_step: int) None#
Close the step: a group lost from here on counts toward the next.
- accounting_step(target_step: Optional[int]) int#
The step a group counts toward: its own, or the one being assembled.
- _charge_step_for_lost_group(
- target_step: Optional[int],
The step a permanently lost group is charged to, or None for no step.
- advance_assembling_version() None#
Move past steps whose selected groups and losses fill their batch.
- _mark_step_allowed_short(charged_step: int) None#
Record one allow-short reason the assembler charged to
charged_step.A step already permitted by another path – a drained pooled step, an exhausted close, or a checkpoint restore – has no tracked count, so its standing permission counts as one reason the assembler will not release (see
_allow_short_reasons). The assembler’s own charge then stacks on top, so reconciliation can undo it without dropping the other path’s.
- _release_step_allowed_short(charged_step: int) None#
Undo one allow-short reason the assembler charged; drop at the last.
- _allow_short_reasons(charged_step: int) int#
Reasons the step may close short: tracked charges, or 1 if premarked.
- reconcile_selection_credits(
- assembling_version: int,
- credits: list[nemo_rl.algorithms.single_controller_utils.step_assembly.ShortfallCredit],
Reapply only losses that raced an awaited selection, using its result.
- credit_shortfall(
- target_step: Optional[int],
- *,
- allow_short: bool = False,
Record that a step will never receive a group it is waiting for.