nemo_automodel.components.loss.decision_batch
nemo_automodel.components.loss.decision_batch
Validate identified question scores against supervision before padding once.
Model adapters attach identities in their actual output order. This boundary can reject mislabeled ordering and widths; it cannot infer identities from anonymous logit values or detect a caller attaching incorrect metadata to those values.
Module Contents
Classes
Functions
API
Validated, record-major inputs to the decision objective.
Tensor of shape [questions, max_options] with -inf padding and autograd connected to every input question’s scores.
Supervision tensors with DecisionTargets layouts; its
option_mask is the single authoritative mask for these logits.
Read-only supervision required by this component.
Gold option index, or -100 when unlabelled.
Option identities in model-output order.
Question identity within its record.
Loss question type: 0=noul, 1=choice, 2=score.
Optional utilities aligned with the option identities.
Padded supervision and the original record/question/option identities.
Long tensor of shape [questions]; gold option index or -100.
Bool tensor of shape [questions, max_options]; True for a real option. The assembly boundary uses this same mask for logits.
Long tensor of shape [questions]; 0=noul, 1=choice, 2=score.
Original targets grouped by record, retaining option order.
Direct tensor-only construction is valid for isolated loss math;
assembly requires identities prepared by from_questions.
Input record identifiers in record-major order.
Optional float tensor of shape [questions, max_options].
Optional bool tensor of shape [questions]; explicit rewards are available on True rows, with labelled one-hot rewards otherwise.
Optional float tensor of shape [questions, max_options].
Optional float tensor of shape [questions].
Prepare supervision before model forwards, preserving identities.
This preparation allows a distributed optimizer window to reduce its supervision denominator without retaining every microbatch’s graph.
Parameters:
Input record IDs, aligned with the outer question axis.
Targets in each record’s expected question/option order.
Optional per-question weights; missing IDs use 1.
Optional identified reference tensors of shape [options] per question, in the same nested record/question order. They must be finite; stored copies are detached from autograd.
Device for the supervision tensors. Defaults to CPU.
Returns: DecisionTargets
Supervision with layouts documented by DecisionTargets. Padding
Return supervision on device, retaining immutable identity metadata.
Parameters:
Destination for every tensor-bearing field described above.
Returns: DecisionTargets
Targets with the same tensor shapes as this instance. Unchanged-device
Scores carrying their model-output identity through batch assembly.
Allowed option identifiers in the score tensor’s order.
Question identifier within the input record.
Input record identifier.
Floating tensor of shape [options], containing raw logits or, only when used as a reference policy, log-probabilities.
Check identified ragged rows against the prepared supervision order.
Parameters:
Nested record/question score tensors of shape [options] each.
Prepared supervision with the DecisionTargets tensor layouts.
Returns: list[torch.Tensor]
Original score tensors of shape [options], flattened in record-major
Validate identified scores and pad them using the supervision’s mask.
Parameters:
Per-record/question identified tensors of shape [options]. All rows must have the same dtype/device and follow the target identities.
Supervision with DecisionTargets layouts, prepared through
from_questions and on the same device as logits.
Returns: DecisionBatch
DecisionBatch with record-major logits [questions, max_options] and