core.ops.loss#
Vocab-parallel cross entropy.
A target is called as loss = target(logits, labels, tp_group) with logits
[s, b, vocab / tp] and labels [s, b], and returns the per-token loss
[s, b]. The target owns every reduction over tp_group and consumes logits
in place; backends.CrossEntropyTarget states the contract. Targets hold no
parameters or state.
cross_entropy– the eager custom-autograd implementation, with label smoothing, and theVocabParallelCrossEntropysteps the fused path shares.fused_cross_entropy– the same computation compiled withjit_fuser.backends–select_cross_entropy, which turnscross_entropy_loss_fusionandcross_entropy_fusion_implinto the target a model binds once.
Transformer Engine’s cross entropy stays in megatron.core.extensions.transformer_engine.
Packages here do not re-export; import each name from the module that defines it.