nvalchemi.training.distillation.TeacherScorer#

class nvalchemi.training.distillation.TeacherScorer(*args, **kwargs)[source]#

Structural interface for objects that produce teacher signals for a batch.

An implementation declares the signals it emits and returns, for one Batch, {batch field: (tensor, level)} with levels "node" or "system" as add_key() takes them. Tensors must be detached and live on the batch’s device.

It may also publish label_fields, the sequence of batch fields label() populates (never a bare string); consumers read it through scorer_fields(). An implementation naming a built-in signal is read as writing every field that signal populates, so one that writes fewer, or one whose signals are its own, must declare label_fields. The protocol will not grow required members.

Label precision is the scorer’s decision. A consumer calls label() inside the ambient autocast region, meaning whatever autocast state is in force at the call site, and opens no region of its own. An implementation used in a mixed-precision workflow therefore sets its own autocast mode. InProcessTeacherScorer disables autocast unless its autocast setting says otherwise.

See also

InProcessTeacherScorer

Scorer that evaluates a teacher in this process.

nvalchemi.training.distillation.labeling.label_dataset

Offline consumer.

label(batch)[source]#

Return {batch field: (detached tensor, level)} for batch.

Parameters:

batch (Batch)

Return type:

dict[str, tuple[Tensor, Literal[‘node’, ‘system’]]]