slapo.op.cross_entropy¶
Functions:
|
Performs cross entropy loss when logits are split across tensor parallel ranks |
Classes:
|
- slapo.op.cross_entropy.vocab_parallel_cross_entropy(vocab_parallel_logits, target, label_smoothing=0.0, group=None)[source]¶
Performs cross entropy loss when logits are split across tensor parallel ranks
- Parameters
vocab_parallel_logits – logits split across tensor parallel ranks dimension is [sequence_length, batch_size, hidden_size]
target – correct vocab ids of dimension [sequence_length, micro_batch_size]
label_smoothing – smoothing factor, must be in range [0.0, 1.0) default is no smoothing (=0.0)
group – torch.distributed group
- class slapo.op.cross_entropy.ParallelCrossEntropy(group=None)[source]¶
Methods:
forward
(outputs, labels)Defines the computation performed at every call.
- forward(outputs, labels)[source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.