MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / __init__

Method __init__

deepspeed/module_inject/layers.py:1096–1108  ·  view source on GitHub ↗
(self, module, mp_group=None, **kwargs)

Source from the content-addressed store, hash-verified

1094 """Column-parallel vocabulary projection that keeps rank-local logits."""
1095
1096 def __init__(self, module, mp_group=None, **kwargs):
1097 super().__init__(module, mp_group, gather_output=False, **kwargs)
1098 if min(self._partition_sizes) == 0:
1099 # The shard-size list is identical on every TP rank, so all ranks raise here
1100 # together instead of one rank failing into a collective hang at the loss.
1101 raise ValueError(f"vocab_parallel_lm_head requires a vocabulary of at least tp_size="
1102 f"{self.tp_world_size} rows, but '{self.name}' has {self._orig_weight_shape[0]}")
1103 self.is_vocab_parallel_lm_head = True
1104 self.vocab_size = self._orig_weight_shape[0]
1105 self.vocab_start_index = sum(self._partition_sizes[:self.tp_index])
1106 self.vocab_end_index = self.vocab_start_index + self._partition_sizes[self.tp_index]
1107 # Set by the fused linear cross-entropy loss, which defers this projection into the loss.
1108 self.fused_loss_capture = None
1109
1110 def forward(self, input):
1111 capture = self.fused_loss_capture

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected