Skip to content

Commit 1f6ad03

Browse files
committed
[train]: style, fix some typo.
1 parent 790ccee commit 1f6ad03

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

flagscale/models/megatron/engram/engram_transformer_layer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def sharded_state_dict(
349349
self, prefix: str = "", sharded_offsets: tuple = (), metadata: dict | None = None
350350
):
351351
# Engram let the layers be non-homogeneous, so we need to set the flag in metadata to let the sharded state dict logic know.
352-
# This is usefule when all layer are same, the TransformerBlock will be homogeneous, it generate sharded_state_dict will same keys for all layer and need all layers have the same structure.
352+
# This is useful when all layer are same, the TransformerBlock will be homogeneous, it generate sharded_state_dict will same keys for all layer and need all layers have the same structure.
353353
# The layer has engram module does not fit this assumption.
354354
# If the flag is set to True, the sharded_state_dict will use layer_number to generate different keys for different layer, which is same to models has dense layer leading and moe layer following.
355355
# Actually, engram really causes the layers to be non-homogeneous.

flagscale/models/megatron/engram/multi_head_embedding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _initialize_engram_weight_gpu_with_seed(weight, init_method, local_init_seed
4141

4242

4343
class EngramMemory(nn.Module):
44-
"""Embedding parallelized in the vocabulay dimension.
44+
"""Embedding parallelized in the vocabulary dimension.
4545
4646
This is mainly adapted from torch.nn.Embedding and all the default values are kept.
4747
@@ -230,7 +230,7 @@ def sharded_state_dict(
230230
self,
231231
prefix: str = '',
232232
sharded_offsets: Tuple[Tuple[int, int, int]] = (),
233-
metadata: Optional[dict] = None,** kwargs,
233+
metadata: Optional[dict] = None, **kwargs,
234234
):
235235
state_dict = self.state_dict(prefix="", keep_vars=True)
236236
weight_prefix = f"{prefix}weight"

flagscale/train/megatron/training/arguments_fs.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,13 @@ def _parse_recompute_refined_config(recom_config, recom_config_name):
376376
if self.args.engram_embedding_parallel_method == "allreduce":
377377
if self.args.rank == 0:
378378
warnings.warn(f"[rank0]: We do not recommend using allreduce for engram embedding, this is deprecated and will be removed in a later version.", DeprecationWarning)
379-
if self.args.engram_embedding_parallel_size is not None:
380-
warnings.warn(
381-
"[rank0]: If set the embedding_parallel_method to allreduce, " \
382-
"the embedding module will be the tensor_parallel.layers.VocabParallelEmbedding with tensor_parallel." \
383-
"So the embedding_parallel_size is useless and set to None."
384-
)
385-
self.args.engram_embedding_parallel_size = None
379+
if self.args.engram_embedding_parallel_size is not None:
380+
warnings.warn(
381+
"[rank0]: If set the embedding_parallel_method to allreduce, " \
382+
"the embedding module will be the tensor_parallel.layers.VocabParallelEmbedding with tensor_parallel." \
383+
"So the embedding_parallel_size is useless and set to None."
384+
)
385+
self.args.engram_embedding_parallel_size = None
386386
elif self.args.engram_embedding_parallel_method == "alltoall":
387387
assert self.args.engram_embedding_parallel_size is not None, "embedding parallel size should be specified when using alltoall"
388388
else:
@@ -393,7 +393,7 @@ def _parse_recompute_refined_config(recom_config, recom_config_name):
393393
warnings.warn("Offloading embedding optimizer states will offload all embedding optimizer states to CPU, which may cause slowdown. " \
394394
"Please make sure this is what you want. This is typically used to save GPU memory when Engram embedding is large while accelerators are limited." \
395395
"If you do not want to offload all embedding optimizer states to CPU, please disable this and set the --optimizer-offload-fraction to a value less than 1 to offload part of the optimizer states to CPU." \
396-
"Of cource you can set the --optimizer-offload-fraction to offload other params meanwhile enable this to offload all embedding optimizer states to CPU.")
396+
"Of course you can set the --optimizer-offload-fraction to offload other params meanwhile enable this to offload all embedding optimizer states to CPU.")
397397
assert not self.args.use_megatron_fsdp, "Megatron FSDP is not supported yet; support is planned for a later version."
398398
assert not self.args.init_model_with_meta_device, "Init_model_with_meta_device is not supported yet; support is planned for a later version."
399399
assert self.args.use_distributed_optimizer, "When use engram, distributed_optimizer must be enabled, because there is a bug caused by allreduce grad norm in model parallel group when do not use distributed_optimizer. We have not found a pretty solution yet, so disable it temporarily."

0 commit comments

Comments
 (0)