nemo_automodel.components.training.domain_mixture
nemo_automodel.components.training.domain_mixture
Objective weighting for named pretraining data mixtures.
Module Contents
Classes
Data
API
Runtime importance weights and metrics for a named data mixture.
loss_multipliers[i] = objective_weights[i] / sampling_weights[i].
Applying that multiplier to every supervised token sampled from domain
i makes the expected training objective match objective_weights
without changing the sampler or creating separate optimizers.
Validate and flatten per-sample dataset IDs to shape [batch].
Parameters:
Integer tensor of per-sample domain IDs.
Bounds-check the IDs. This costs two blocking
device-to-host syncs, so callers on the per-microbatch critical
path pass False once a step-level pass has already validated
the very same batches.
Return the multiplier vector on device, building it at most once.
loss_multipliers is immutable after :meth:DomainMixtureConfig.build,
so rebuilding it per microbatch only adds a pageable host-to-device copy
on the critical path.
Count supervised tokens per domain.
Parameters:
Integer tensor with one domain ID per label row.
Target token IDs of shape [batch, ...] or a flat
single-sample tensor.
Label value excluded from the count.
Returns: torch.Tensor
Int64 tensor of shape [num_domains].
Expand per-sample importance weights to the label layout.
Parameters:
Integer tensor of shape [batch] (or a scalar for a
single sample). IDs follow the domain order in the config.
Target token IDs of shape [batch, sequence] or
[sequence] for a single flattened sample.
Bounds-check dataset_ids. Costs two device syncs;
see :meth:_domain_ids.
Returns: torch.Tensor
Float32 tensor matching labels.shape. Every row is constant
Combine named per-domain validation losses using objective weights.
Configuration for importance-weighted multi-domain pretraining.
Build the immutable runtime domain-mixture objective.
Declarative sampling and objective weights for one data domain.