megatron.core.tensor_parallel.layers.VocabParallelEmbedding#
- class megatron.core.tensor_parallel.layers.VocabParallelEmbedding(num_embeddings: int, embedding_dim: int, *, init_method=<function xavier_normal_>, params_dtype: ~torch.dtype = torch.float32, use_cpu_initialization: bool = False, perform_initialization: bool = True)#
Bases:
Module
Embedding parallelized in the vocabulary dimension.
This is mainly adapted from torch.nn.Embedding and all the default values are kept. :param num_embeddings: vocabulary size. :param embedding_dim: size of hidden state.
- Keyword Arguments:
init_method – method to initialize weights.
params_dtype –
use_cpu_initialization –
perform_initialization –
- forward(input_)#
Define 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.