vocab_parallel_torch ¶
log_prob_of from softmax_torch.py for logits sharded over the class dimension across a
torch.distributed group (tensor-parallel language-model heads). Chunked over rows; recomputes
the softmax in backward to bound memory.
vocab_parallel_log_prob_of ¶
vocab_parallel_log_prob_of(
logits_shard: Tensor,
target: Tensor,
group: ProcessGroup | None = None,
chunk: int = _DEFAULT_CHUNK,
) -> torch.Tensor
log_prob_of for logits split over the last (class) dimension across group.
Every rank must call it with the same target and chunk. Backward recomputes the
softmax chunk by chunk and returns the gradient of this rank's shard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logits_shard
|
Tensor
|
|
required |
target
|
Tensor
|
|
required |
group
|
ProcessGroup | None
|
|
None
|
chunk
|
int
|
Rows processed at a time, to bound temporary memory. |
_DEFAULT_CHUNK
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|