Skip to navigation

nemo_automodel.components.models.nemotron_decision.scorer

View as MarkdownOpen in Claude

Scoring and checkpoint-contract checks for Nemotron Decision post-training.

Module Contents

Functions

NameDescription
full_finetune_trainableWhether backbone fine-tuning trains this parameter: decoder layers and final norm, not embeddings or the head.
gather_head_rowsRows of the frozen, bias-free decision head for token_ids.
option_logitsOption logits of one question: one bidirectional read of prompt + [mask], head restricted to the codes.
require_decision_configReject checkpoints whose runtime contract this recipe does not implement.

Data

FULL_FINETUNE_PREFIXES

_WRAPPER_SEGMENTS

API

nemo_automodel.components.models.nemotron_decision.scorer.full_finetune_trainable(
parameter_name: str
) -> bool

Whether backbone fine-tuning trains this parameter: decoder layers and final norm, not embeddings or the head.

Activation-checkpoint and torch.compile wrapper segments in the name are ignored.

nemo_automodel.components.models.nemotron_decision.scorer.gather_head_rows(
model: torch.nn.Module,
token_ids: typing.Sequence[int]
) -> torch.Tensor

Rows of the frozen, bias-free decision head for token_ids.

All ranks must call this when the head weight is a sharded DTensor.

Parameters:

model
nn.Module

Model exposing the decision head through get_output_embeddings().

token_ids
Sequence[int]

Vocabulary ids of the rows to gather, length T.

Returns: torch.Tensor

Tensor of shape [T, hidden] in the head’s dtype (a copy).

nemo_automodel.components.models.nemotron_decision.scorer.option_logits(
model: torch.nn.Module,
input_ids: typing.Sequence[int],
code_token_ids: typing.Sequence[int],
mask_token_id: int,
rows: dict[int, torch.Tensor],
device: torch.device
) -> torch.Tensor

Option logits of one question: one bidirectional read of prompt + [mask], head restricted to the codes.

Equivalent to diffusion_head(hidden[:, -1])[code_token_ids]; the frozen head rows are used directly so the head never has to run under a sharded wrapper.

Parameters:

model
nn.Module

Backbone returning the last hidden state for input_ids (output_last_hidden_states_only=True).

input_ids
Sequence[int]

Prompt token ids, length L (no mask).

code_token_ids
Sequence[int]

Single-token code of each option, length N.

mask_token_id
int

Mask token appended as the answer slot.

rows
dict[int, torch.Tensor]

Frozen head rows by vocabulary id, each of shape [hidden].

device
torch.device

Device of the token ids.

Returns: torch.Tensor

fp32 tensor of shape [N].

nemo_automodel.components.models.nemotron_decision.scorer.require_decision_config(
config: typing.Any
) -> None

Reject checkpoints whose runtime contract this recipe does not implement.

The recipe trains Nemotron 3.5 Decision checkpoints: a text Ministral 3 encoder read with fully bidirectional attention, one question per read, and the decision head at the mask token. Vision and quantized variants need their own input and storage paths and are not run silently as the text model.

Parameters:

config
Any

Hugging Face config (attribute access) of the checkpoint.

Raises:

  • ValueError: If the architecture, attention or storage format is unsupported.
nemo_automodel.components.models.nemotron_decision.scorer.FULL_FINETUNE_PREFIXES = ('encoder.layers.', 'encoder.norm.')
nemo_automodel.components.models.nemotron_decision.scorer._WRAPPER_SEGMENTS = ('_checkpoint_wrapped_module.', '_orig_mod.')