Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/JinjieNi/MegaDLMs
/ functions
Functions
4,219 in github.com/JinjieNi/MegaDLMs
⨍
Functions
4,219
◇
Types & classes
650
↳
Endpoints
8
↓ 274 callers
Method
size
Get the size of the dtype/code in bytes Args: key (Union[int, Type[numpy.number]]): The dtype or code Raises:
megatron/core/datasets/indexed_dataset.py:78
↓ 269 callers
Function
print_rank_0
If distributed is initialized, print only on rank 0.
megatron/training/utils.py:299
↓ 257 callers
Function
get_args
Return arguments.
megatron/training/global_vars.py:23
↓ 211 callers
Method
initialize_model_parallel
( tensor_model_parallel_size=1, pipeline_model_parallel_size=1, virtual_pipeline_model
tests/unit_tests/test_utilities.py:98
↓ 202 callers
Method
destroy_model_parallel
()
tests/unit_tests/test_utilities.py:87
↓ 195 callers
Method
items
Return generator over underlying items.
megatron/core/optimizer/optimizer.py:923
↓ 195 callers
Method
split
(self, json_line)
tools/preprocess_data.py:77
↓ 91 callers
Method
get
Retrieve a single item from the dataset with the option to only return a portion of the item. get(idx) is the same as [idx] but get()
megatron/core/datasets/indexed_dataset.py:653
↓ 88 callers
Function
log_single_rank
If torch distributed is initialized, log only on rank Args: logger (logging.Logger): The logger to write the logs args (Tuple[An
megatron/core/utils.py:288
↓ 86 callers
Method
start
Start the timer. Args: barrier (bool, optional): Synchronizes ranks before starting. Defaults to False.
megatron/core/timers.py:99
↓ 77 callers
Method
from_rank_offsets
Allows to construct the ShardedTensor given offset specified in process ranks. Args: key (str): unique key data (torc
megatron/core/dist_checkpointing/mapping.py:236
↓ 72 callers
Method
update
Updates internal state in grad scaler based on whether NaNs are seen in grads or not.
megatron/core/optimizer/grad_scaler.py:108
↓ 69 callers
Function
model_parallel_cuda_manual_seed
Initialize model parallel cuda seed. This function should be called after the model parallel is initialized. Also, no torch.cuda.manual_seed
megatron/core/tensor_parallel/random.py:201
↓ 68 callers
Method
stop
Stop the timer. Args: barrier (bool, optional): Synchronizes ranks before stopping. Defaults to False.
megatron/core/timers.py:112
↓ 66 callers
Method
log
logs the timers passed in names to stdout. Example usage is to log average per step value for timer 'foo', this function can be called with
megatron/core/timers.py:361
↓ 64 callers
Method
is_initialized
Checks if the internal RNG state has been set wirth set_states().
megatron/core/tensor_parallel/random.py:94
↓ 59 callers
Method
write
Write timers to a tensorboard writer. Note that we only report maximum time across ranks to tensorboard. Args: names (
megatron/core/timers.py:391
↓ 58 callers
Function
build_module
(spec_or_module: Union[ModuleSpec, type], *args, **kwargs)
megatron/core/transformer/spec_utils.py:58
↓ 56 callers
Method
apply
(cls, *args, **kwargs)
megatron/core/fusions/fused_bias_gelu.py:51
↓ 55 callers
Function
_set_arg
(arg_name, old_arg_name=None, force=False)
megatron/training/checkpointing.py:1045
↓ 53 callers
Method
raises
Return a list of information on the exceptions that the function may raise.
tools/retro/config_utils.py:181
↓ 52 callers
Method
get
(self, key, model)
tools/checkpoint/schema_base.py:65
↓ 52 callers
Method
sharded_state_dict
(self)
tests/unit_tests/dist_checkpointing/test_optimizer.py:52
↓ 51 callers
Method
exists
Return whether the IndexedDataset exists on disk at the prefix Args: path_prefix (str): The prefix to the index (.idx) and data (
megatron/core/datasets/indexed_dataset.py:726
↓ 50 callers
Function
save
Saving entrypoint. Extracts ShardedTensors from the given state dict. Rank 0 saves the "regular" part of the checkpoint to common torch file.
megatron/core/dist_checkpointing/serialization.py:288
↓ 49 callers
Function
is_te_min_version
Check if minimum version of `transformer-engine` is installed.
megatron/core/utils.py:80
↓ 49 callers
Method
load
(self, sharded_state_dict, ckpt_dir)
tests/unit_tests/dist_checkpointing/test_fully_parallel.py:50
↓ 49 callers
Method
state_dict
(self, prefix='', keep_vars=False)
megatron/legacy/model/module.py:195
↓ 44 callers
Method
load
Load the sharded part of the checkpoint.
megatron/core/dist_checkpointing/strategies/base.py:138
↓ 44 callers
Function
log_retro_rank_0
Log on rank 0. Args: message (str): Message to log.
megatron/core/datasets/retro/utils.py:29
↓ 42 callers
Function
load
Loading entrypoint. In the steps below, the following verbs refer to corresponding objects: - load = load from checkpoint - extract = ext
megatron/core/dist_checkpointing/serialization.py:56
↓ 40 callers
Method
load_state_dict
Customized load.
megatron/legacy/model/t5_model.py:184
↓ 34 callers
Function
get_gpt_layer_with_transformer_engine_spec
Use this spec to use lower-level Transformer Engine modules (required for fp8 training). Args: num_experts (int, optional): Number of ex
megatron/core/models/gpt/gpt_layer_specs.py:54
↓ 34 callers
Function
get_tensor_model_parallel_group
Get the tensor-model-parallel group the caller rank belongs to.
megatron/core/parallel_state.py:1036
↓ 32 callers
Method
pad
The PAD token id Raises: NotImplementedError: Non-abstract, optional attribute
megatron/core/datasets/megatron_tokenizer.py:112
↓ 31 callers
Function
get_tokenizer
Return tokenizer.
megatron/training/global_vars.py:29
↓ 30 callers
Method
close
(self)
tests/unit_tests/data/test_bin_reader.py:71
↓ 30 callers
Function
get_timers
Return timers.
megatron/training/global_vars.py:58
↓ 30 callers
Method
put
(self)
megatron/inference/text_generation_server.py:18
↓ 30 callers
Method
tokenize
(self, *text)
tools/preprocess_data.py:44
↓ 28 callers
Function
diff
Recursive diff of dicts. Args: x1 (object): left dict x2 (object): right dict prefix (tuple): tracks recursive calls. Use
megatron/core/dist_checkpointing/dict_utils.py:69
↓ 28 callers
Function
get_num_microbatches
Get number of microbatches.
megatron/core/num_microbatches_calculator.py:17
↓ 27 callers
Method
from_pretrained
Instantiate a PreTrainedBertModel from a pre-trained model file. Download and cache the pre-trained model file if needed.
megatron/training/tokenizer/gpt2_tokenization.py:98
↓ 27 callers
Method
get_ranks
Get rank group by input token. Args: token (str): Specify the ranks type that want to get. If we want
megatron/core/parallel_state.py:347
↓ 27 callers
Method
read
Read bytes into a numpy array. Args: dtype (Type[numpy.number]): Data-type of the returned array. count (int): Numbe
megatron/core/datasets/indexed_dataset.py:348
↓ 26 callers
Method
save
Save the sharded part of the state dict.
megatron/core/dist_checkpointing/strategies/base.py:196
↓ 26 callers
Function
save_checkpoint
Save a model, optimizer and optionally dataloader checkpoint. Checkpointing context is used to persist some checkpointing state throughout a
megatron/training/checkpointing.py:315
↓ 25 callers
Function
get_gpt_layer_local_spec
Use this spec for an implementation using only modules in Megatron-Core. Args: num_experts (int, optional): Number of experts. Defaults
megatron/core/models/gpt/gpt_layer_specs.py:144
↓ 24 callers
Method
build
Builds a ShardedStateDict from the original tensor
megatron/core/dist_checkpointing/mapping.py:635
↓ 24 callers
Method
fork
Fork the cuda rng state, perform operations, and exit with the original state.
megatron/core/tensor_parallel/random.py:143
↓ 24 callers
Function
get_tensor_model_parallel_world_size
Return world size for the tensor-model-parallel group.
megatron/core/parallel_state.py:1198
↓ 23 callers
Method
add
Add vectors to index. Args: config (RetroPreprocessingConfig): Retro preprocessing config. text_dataset (GPTToTextDat
megatron/core/datasets/retro/index/index.py:111
↓ 23 callers
Method
backward
No-op
megatron/core/utils.py:213
↓ 23 callers
Function
load_checkpoint
Load a model checkpoint and return the iteration. strict (bool): whether to strictly enforce that the keys in :attr:`state_dict` of the ch
megatron/training/checkpointing.py:1148
↓ 23 callers
Function
make_viewless_tensor
Entry-point for creating viewless tensors. This method should be used, rather than calling 'MakeViewlessTensor' or '_kernel_make_viewles
megatron/core/utils.py:218
↓ 22 callers
Function
_broadcast
(item)
megatron/training/utils.py:388
↓ 22 callers
Method
encode
(self, json_line)
tools/preprocess_data.py:87
↓ 21 callers
Function
divide
Ensure that numerator is divisible by the denominator and return the division value.
megatron/core/utils.py:106
↓ 21 callers
Function
load_plain_tensors
Load checkpoint tensors without any sharding and plain structure. NOTE: common state dict is NOT included. Args: checkpoint_dir (str
megatron/core/dist_checkpointing/serialization.py:246
↓ 20 callers
Function
is_main_replica
Checks if given `replica_id` is considered as main. "Main" replica is: - integer 0 - or an iterable with all 0 elements It is the ap
megatron/core/dist_checkpointing/mapping.py:482
↓ 19 callers
Function
get_nccl_options
Set the NCCL process group options. Args: pg_name (str): process group name nccl_comm_cfgs (dict): nccl communicator configuratio
megatron/core/parallel_state.py:126
↓ 19 callers
Function
get_one_logger
Return one logger. It can be None so no need to check if it is initialized.
megatron/training/global_vars.py:47
↓ 19 callers
Function
get_tensor_model_parallel_rank
Return caller's rank for the tensor-model-parallel group.
megatron/core/parallel_state.py:1242
↓ 19 callers
Function
parse_args
Parse all arguments.
megatron/training/arguments.py:28
↓ 19 callers
Method
state_dict
(self, destination=None, prefix='', keep_vars=False)
megatron/core/transformer/module.py:183
↓ 19 callers
Function
unwrap_model
(model, module_instances=ALL_MODULE_WRAPPER_CLASSNAMES)
megatron/training/utils.py:54
↓ 18 callers
Function
_compare
(arg_name, old_arg_name=None, default=None)
megatron/training/checkpointing.py:83
↓ 17 callers
Method
forward
(self, x)
tests/unit_tests/transformer/test_module.py:23
↓ 17 callers
Function
is_torch_min_version
Check if minimum version of `torch` is installed.
megatron/core/utils.py:94
↓ 17 callers
Method
save
(self, sharded_state_dict, ckpt_dir)
tests/unit_tests/dist_checkpointing/test_fully_parallel.py:36
↓ 16 callers
Function
_binarize
args: y_data : [float] 4-d tensor in [batch_size, channels, img_rows, img_cols] threshold : [float] [0.0, 1.0] return 4-d bin
tasks/vision/segmentation/metrics.py:17
↓ 16 callers
Function
get_cuda_rng_tracker
Get cuda rng tracker.
megatron/core/tensor_parallel/random.py:195
↓ 16 callers
Function
get_model
Build the model.
megatron/training/training.py:537
↓ 16 callers
Function
nested_values
Returns iterator over (nested) values of a given dict or list.
megatron/core/dist_checkpointing/dict_utils.py:158
↓ 16 callers
Method
tokenize
(self, text)
tasks/orqa/unsupervised/tokenizers.py:146
↓ 15 callers
Method
backward
(ctx, output_grads)
megatron/legacy/model/fused_softmax.py:106
↓ 15 callers
Function
dict_list_map_inplace
Maps dicts and lists *in-place* with a given function.
megatron/core/dist_checkpointing/dict_utils.py:190
↓ 15 callers
Function
get_blend_from_list
Get the megatron.core.datasets.blended_megatron_dataset_config.BlendedMegatronDatasetConfig blend from the blend list Args: blend (Option
megatron/core/datasets/utils.py:49
↓ 15 callers
Function
has_config_logger_enabled
(config)
megatron/core/config_logger.py:17
↓ 15 callers
Function
log_config_to_disk
Encodes the input dict (dict_data) using the JSONEncoderWithMcoreTypes and dumps to disk, as specified via path
megatron/core/config_logger.py:79
↓ 15 callers
Function
print_rank_last
If distributed is initialized, print only on last rank.
megatron/training/utils.py:311
↓ 14 callers
Function
check_for_arg
(arg_name, default=None)
tools/checkpoint/loader_legacy.py:89
↓ 14 callers
Function
core_transformer_config_from_args
(args, config_class=None)
megatron/training/arguments.py:782
↓ 14 callers
Function
generator_wrapper
The `RankGenerator` class produces a hyper-rectangle for a given set of tensor, pipeline, data, expert, and context parallelism. If we have an
megatron/core/parallel_state.py:670
↓ 14 callers
Function
get_checkpoint_name
Determine the directory name for this rank's checkpoint.
megatron/training/checkpointing.py:124
↓ 14 callers
Method
get_current_global_batch_size
Get current global batch size.
megatron/core/num_microbatches_calculator.py:279
↓ 14 callers
Function
get_forward_backward_func
Retrieves the appropriate forward_backward function given the configuration of parallel_state. Returns a function that will perform all of th
megatron/core/pipeline_parallel/schedules.py:26
↓ 14 callers
Function
get_model_chunk_id
Helper method to get the model chunk ID given the iteration number.
megatron/core/pipeline_parallel/schedules.py:768
↓ 14 callers
Function
get_te_version
Get TE version from __version__; if not available use pip's. Use caching.
megatron/core/utils.py:63
↓ 14 callers
Function
is_last_rank
()
megatron/training/utils.py:307
↓ 14 callers
Function
set_random_seed
Set random seed for reproducability.
megatron/legacy/mpu/tests/commons.py:21
↓ 14 callers
Function
setup_model_and_optimizer
( seed, tp, pp, initialize_fn=initialize_gpt_model, bf16=True, dist_opt=True )
tests/unit_tests/dist_checkpointing/utils.py:155
↓ 14 callers
Method
step
Performs inference step for decoding
megatron/core/ssm/mamba_mixer.py:406
↓ 13 callers
Method
__init__
(self, in_features, hidden_features=None, out_features=None
megatron/legacy/model/vision/mit_backbone.py:14
↓ 13 callers
Function
_safe_get_rank
Internal function that safely checks and returns the rank of the caller.
megatron/core/rerun_state_machine.py:1101
↓ 13 callers
Function
check_for_arg
(arg_name, default=None)
tools/checkpoint/loader_core.py:125
↓ 13 callers
Function
check_for_arg
(arg_name, default=None)
tools/checkpoint/loader_mixtral_hf.py:205
↓ 13 callers
Function
check_for_arg
(arg_name, default=None)
tools/checkpoint/loader_llama_mistral.py:481
↓ 13 callers
Function
extract_matching_values
Return matching and nonmatching values. Keeps hierarchy. Args: x (Union[dict, list]) : state dict to process. Top-level argument must be
megatron/core/dist_checkpointing/dict_utils.py:18
↓ 13 callers
Function
get_default_strategy
Retrieves a default strategy for a given action, backend and version.
megatron/core/dist_checkpointing/strategies/base.py:29
next →
1–100 of 4,219, ranked by callers