MCPcopy Create free account

hub / github.com/JinjieNi/MegaDLMs / functions

Functions4,219 in github.com/JinjieNi/MegaDLMs

↓ 5 callersMethodrun_one_forward_step
The forward pass of the model for inference Appropriate utility is called for the forward pass depending on the type of model parallelism use
megatron/core/inference/model_inference_wrappers/abstract_model_inference_wrapper.py:214
↓ 5 callersFunctionsample_N
(dataset, N, randomize)
tests/unit_tests/data/test_gpt_dataset.py:22
↓ 5 callersFunctionset_args
(args)
megatron/training/global_vars.py:133
↓ 5 callersFunctionset_tensor_model_parallel_attributes
Sets tp attributes to tensor
megatron/core/tensor_parallel/layers.py:78
↓ 5 callersMethodsetup_embeddings_and_output_layer
Sets up embedding layer in first stage and output layer in last stage. This function initalizes word embeddings in the final stage when we ar
megatron/core/models/common/language_module/language_module.py:87
↓ 5 callersFunctionsetup_model_and_optimizer
Setup model and optimizer.
megatron/training/training.py:720
↓ 5 callersMethodsharded_state_dict
( self, prefix: str = '', sharded_offsets: tuple = (), metadata: Optional[dict] = None )
megatron/core/transformer/mlp.py:132
↓ 4 callersMethod__init__
Constructor. Args: hidden_size_student: Size of the student's hidden dimension. hidden_size_teacher: Size of
megatron/inference/algos/distillation.py:87
↓ 4 callersMethod__iter__
Remove 'endoftext' string.
tools/bert_embedding/huggingface.py:16
↓ 4 callersMethod_adjust_key_value_for_inference
Saves the generated key and value tensors to the end of the buffers in inference_params. Returns the full size keys and values from t
megatron/core/transformer/attention.py:184
↓ 4 callersMethod_allocate_memory
Allocate memory to store kv cache during inference.
megatron/core/transformer/attention.py:172
↓ 4 callersMethod_apply_image_tag
Surround <image> with image tags such as <img> and </img>.
megatron/training/tokenizer/multimodal_tokenizer.py:138
↓ 4 callersFunction_build_attention_mask_and_position_ids
Build the attention mask and postition ids for the input tokens.
megatron/inference/text_generation/generation.py:450
↓ 4 callersFunction_check_supported_type
Check if arg is a supported type for cudagraph input/outputs.
megatron/core/transformer/cuda_graphs.py:53
↓ 4 callersMethod_checkpointed_attention_forward
Forward method with selective activation checkpointing.
megatron/core/transformer/attention.py:132
↓ 4 callersFunction_ensure_var_is_initialized
Make sure the input variable is not None.
megatron/training/global_vars.py:266
↓ 4 callersFunction_gather_along_first_dim
Gather tensors and concatenate along the first dimension. Args: input_tensor (torch.Tensor): A tensor to be gathered.
megatron/core/tensor_parallel/mappings.py:114
↓ 4 callersMethod_get
Return a tensor with the input `shape` as a view into the 1-D data starting at `start_index`.
megatron/core/distributed/param_and_grad_buffer.py:664
↓ 4 callersMethod_get_deep_attr
(cls, obj, path)
tools/checkpoint/schema_base.py:30
↓ 4 callersMethod_get_layer
(self, layer_number)
megatron/legacy/model/transformer.py:1587
↓ 4 callersFunction_is_pil_image
(img)
tasks/vision/segmentation/transforms.py:20
↓ 4 callersFunction_load_base_checkpoint
Load the base state_dict from the given directory If rank0 is true, just loads rank 0 checkpoint, ignoring arguments.
megatron/training/checkpointing.py:894
↓ 4 callersFunction_reduce_scatter_along_first_dim
Reduce-scatter the input tensor across model parallel group. Args: input_ (torch.Tensor): The input tensor to be reduce-scattered.
megatron/core/tensor_parallel/mappings.py:156
↓ 4 callersFunction_transpose_first_dim
(t, num_splits, num_splits_first, model)
megatron/training/checkpointing.py:737
↓ 4 callersFunctionact_function
act (position-wise halting) with cache and true halting. Every time the act halt function predicts the halt Args:
megatron/core/transformer/custom_layers/ut_modules.py:604
↓ 4 callersFunctionall_to_all
Wrapper for autograd function
megatron/core/tensor_parallel/mappings.py:524
↓ 4 callersFunctionapply_factories
Turn ShardedTensorFactories into ShardedTensors *in-place*. Args: sharded_state_dict (ShardedStateDict): state dict possibly
megatron/core/dist_checkpointing/mapping.py:647
↓ 4 callersFunctionapply_factory_merges
Apply merges defined by ShardedTensorFactories *in-place*. Args: x1 (StateDict): state dict loaded from the checkpoint x2 (Sharde
megatron/core/dist_checkpointing/mapping.py:666
↓ 4 callersFunctionbert_extended_attention_mask
(attention_mask)
megatron/legacy/model/bert_model.py:20
↓ 4 callersFunctionbuild_dataset
(name, data_prefix, max_num_samples, max_seq_length, seed, binary_head, ma
megatron/legacy/data/dataset_utils.py:534
↓ 4 callersFunctionbuild_train_valid_datasets
(data_path, image_size)
tasks/vision/segmentation/data.py:153
↓ 4 callersFunctionbuild_train_valid_test_data_iterators
Build pretraining data iterators.
megatron/training/training.py:2149
↓ 4 callersFunctioncheck_adlr_autoresume_termination
Check for autoresume signal and exit if it is received.
megatron/training/utils.py:220
↓ 4 callersFunctioncheck_param_hashes_across_dp_replicas
Computes hashes of all parameters in model, all-gathers hashes across DP replicas, and then checks for equality between the locally-computed hashe
megatron/core/utils.py:326
↓ 4 callersFunctioncheckpoint
Checkpoint a model or part of the model. This has been directly copied from torch.utils.checkpoint.
megatron/core/tensor_parallel/random.py:323
↓ 4 callersFunctioncheckpoint_exists
(checkpoints_path)
megatron/training/checkpointing.py:229
↓ 4 callersMethodclear
Clear the embedding data structures to save memory. The metadata ends up getting used, and is also much smaller in dimensiona
megatron/legacy/data/realm_index.py:43
↓ 4 callersFunctionclear_aux_losses_tracker
Clear the auxiliary losses.
megatron/core/transformer/moe/moe_utils.py:684
↓ 4 callersMethodconcat_and_pad_tokens
Concat with special tokens and pad sequence to self.max_seq_length
megatron/legacy/data/ict_dataset.py:143
↓ 4 callersFunctionconvert_by_vocab
Converts a sequence of [tokens|ids] using the vocab.
megatron/training/tokenizer/bert_tokenization.py:139
↓ 4 callersMethoddecode
(self, ids)
megatron/training/tokenizer/tokenizer.py:238
↓ 4 callersFunctiondestroy_global_vars
()
megatron/training/global_vars.py:275
↓ 4 callersFunctiondestroy_num_microbatches_calculator
Destroy number of microbatches calculator.
megatron/core/num_microbatches_calculator.py:101
↓ 4 callersMethoddispatcher_dropless_test
(self)
tests/unit_tests/transformer/moe/test_token_dispatcher.py:93
↓ 4 callersMethodembed_text_dataset
Embed a text dataset. Args: text_dataset (torch.utils.data.Dataset): Text dataset to embed. Each sample of the text dataset shoul
megatron/core/datasets/retro/config/bert_embedders.py:21
↓ 4 callersFunctionenable_forward_pre_hook
(model_chunks)
megatron/training/training_nan_skipping.py:1257
↓ 4 callersFunctionenable_forward_pre_hook
(model_chunks)
megatron/training/training.py:1268
↓ 4 callersMethodencode
Encode text dataset, to be later added to index. Args: config (RetroPreprocessingConfig): Retro preprocessing config.
megatron/core/datasets/retro/index/indexes/faiss_par_add.py:84
↓ 4 callersMethodencode
Convert text to a list of token IDs.
tests/unit_tests/test_tokenizer.py:206
↓ 4 callersFunctionensure_directory_exists
Build filename's path if it does not already exists.
megatron/training/checkpointing.py:118
↓ 4 callersFunctionfind_matching_values
Return matching values in a single list Args: x (Union[dict, list]) : state dict to process. Top-level argument must be a dict or list
tests/unit_tests/dist_checkpointing/test_local.py:31
↓ 4 callersFunctionfix_query_key_value_ordering
Fix up query/key/value matrix ordering if checkpoint version is smaller than 2.0
megatron/training/checkpointing.py:776
↓ 4 callersMethodforward
(self, encoder_input_ids, decoder_input_ids, encoder_attn_mask, decoder_attn_mask, encoder_dec
megatron/legacy/model/t5_model.py:116
↓ 4 callersMethodforward
Forward.
megatron/core/extensions/transformer_engine.py:215
↓ 4 callersFunctiongenerate_state_dict
(args, model, optimizer, opt_param_scheduler, rng_state, use_dist_ckpt=False, iteratio
megatron/training/checkpointing.py:697
↓ 4 callersMethodget
This function is n abstraction over __getitem__ with support for slicing Args: idx (int): The index into the dataset
megatron/core/datasets/gpt_dataset.py:748
↓ 4 callersFunctionget_added_codes_dir
Get directory of saved encodings. Args: config (RetroPreprocessingConfig): Retro preprocessing config. Returns: Path to the
megatron/core/datasets/retro/index/utils.py:105
↓ 4 callersFunctionget_capacity
Calculate the capacity of each expert. Args: num_tokens (int): num of the input tokens. num_experts (int): num of the expert
megatron/core/transformer/moe/moe_utils.py:167
↓ 4 callersFunctionget_context_parallel_group
Get the context-parallel group the caller rank belongs to.
megatron/core/parallel_state.py:1097
↓ 4 callersFunctionget_current_global_batch_size
Get current global batch size.
megatron/core/num_microbatches_calculator.py:22
↓ 4 callersMethodget_current_running_global_batch_size
Get current running global batch size. If decrease_batch_size_if_needed is False, this just equals global batch size.
megatron/core/num_microbatches_calculator.py:287
↓ 4 callersMethodget_db_chunk_text
Get DB chunk as text.
tools/retro/cli/cli.py:125
↓ 4 callersMethodget_empty_index_path
Get file path to empty index (i.e., trained, but unpopulated). Args: config (RetroPreprocessingConfig): Retro preprocessing confi
megatron/core/datasets/retro/index/index.py:52
↓ 4 callersFunctionget_expert_tensor_and_model_parallel_group
Get the expert-tensor and expert-model group the caller rank belongs to.
megatron/core/parallel_state.py:1668
↓ 4 callersMethodget_grad_stats_parallel_group
Process group for reducing gradient statistics (num_zeros & norm). The two most common cases are: - Non-distributed optimizer (defaul
megatron/core/optimizer/optimizer.py:156
↓ 4 callersFunctionget_index_dir
Create sub-directory for this index. Args: config (RetroPreprocessingConfig): Retro preprocessing config. Returns: Path to i
megatron/core/datasets/retro/index/utils.py:13
↓ 4 callersFunctionget_megatron_optimizer
Retrieve the Megatron optimizer for model chunks. We use separate optimizers for expert parameters and non-expert parameters. Args:
megatron/core/optimizer/__init__.py:368
↓ 4 callersMethodget_mode
Method to get the operating mode
megatron/core/rerun_state_machine.py:220
↓ 4 callersFunctionget_model_type
Returns model_type attribute
megatron/core/utils.py:141
↓ 4 callersFunctionget_pipeline_model_parallel_group
Get the pipeline-model-parallel group the caller rank belongs to.
megatron/core/parallel_state.py:1045
↓ 4 callersMethodget_tensors
Filter and flatten all tensors from args and kwargs.
megatron/core/transformer/cuda_graphs.py:672
↓ 4 callersFunctionget_timestamp_in_ms
Helper function to get timestamp in ms Returns: [int]: [timestamp in ms]
megatron/training/one_logger_utils.py:7
↓ 4 callersMethodget_wd
Weight decay incr functions
megatron/core/optimizer_param_scheduler.py:98
↓ 4 callersMethodglobal_slice
Returns a tuple of int and slice objects representing a slice of the global tensor that this ShardedTensor corresponds to.
megatron/core/dist_checkpointing/mapping.py:149
↓ 4 callersFunctioninit_method_normal
Init method based on N(0, sigma).
megatron/legacy/model/utils.py:13
↓ 4 callersMethodis_initialized
Checks if the internal RNG state has been set wirth set_states().
megatron/core/extensions/transformer_engine.py:1138
↓ 4 callersFunctionis_nd_flattened_tensor
Checks if ShardedTensor is flattened and more than 1-dimensional Args: sh_ten (Any): any object Returns: bool: whether the g
megatron/core/dist_checkpointing/strategies/resharding.py:78
↓ 4 callersFunctionload_checkpoint_no_arg_checks
(*args, **kwargs)
tests/unit_tests/dist_checkpointing/test_optimizer.py:155
↓ 4 callersFunctionload_tensors_metadata
Load tensors metadata from the checkpoint. Returns a dictionary similar to a sharded state dict, but note that the dictionary keys are simply
megatron/core/dist_checkpointing/serialization.py:172
↓ 4 callersMethodmake_object_verbose
Make index object verbose. Args: index (faiss.Index): Faiss object to set verbose. verbose (bool): Sets whether index
megatron/core/datasets/retro/index/index.py:42
↓ 4 callersFunctionmap_reduce
Simple map-reduce implementation following `more_itertools.map_reduce` interface.
megatron/core/dist_checkpointing/dict_utils.py:236
↓ 4 callersFunctionmaybe_load_config
Returns checkpoint config if `checkpoint_dir` is a distributed checkpoint and None otherwise Args: checkpoint_dir: checkpoint directory
megatron/core/dist_checkpointing/core.py:48
↓ 4 callersFunctionnormalize
Do non-exponentiated normalization Args: weights (List[float]): The weights Returns: List[float]: The normalized weights
megatron/core/datasets/utils.py:34
↓ 4 callersFunctionpermute
(w, n_heads=n_heads, dim1=dim, dim2=dim)
tools/checkpoint/loader_llama_mistral.py:126
↓ 4 callersMethodprep_model_for_inference
A utility function for preparing model for inference This function is called before the forward pass. It puts the model in eval mode, builds
megatron/core/inference/model_inference_wrappers/t5/t5_inference_wrapper.py:42
↓ 4 callersFunctionqueue_put
(name, msg)
tools/checkpoint/loader_mixtral_hf.py:277
↓ 4 callersFunctionqueue_put
(name, msg)
tools/checkpoint/loader_llama_mistral.py:564
↓ 4 callersFunctionread_metadata
(tracker_filename)
megatron/training/checkpointing.py:236
↓ 4 callersFunctionread_tb_logs_as_list
Reads a TensorBoard Events file from the input path, and returns the summary specified as input as a list. Args: path: str, path to t
tests/functional_tests/python_test_utils/common.py:35
↓ 4 callersMethodreport
Function to log the min/max metircs and the associated rank over a time period It finds the slowest and fastest rank among all ranks. It shou
megatron/core/utils.py:1039
↓ 4 callersMethodrun
Run pipeline. Running a pipeline consists of: - Save checkpoint (includes initializing params & forward passing data). - Con
tests/functional_tests/test_cases/common/ckpt_converter/__main__.py:472
↓ 4 callersMethodschedule_async_request
Start a new async call and add it to a queue of active async calls. This method must be called on all ranks. Args: async
megatron/core/dist_checkpointing/strategies/async_utils.py:170
↓ 4 callersFunctionset_tensor_grad_fn_sequence_sr
Set sequence_sr for the grad_fn of a tensor to control the backward order. For older PyTorch version, do nothing (backward order is not chang
megatron/core/transformer/moe/shared_experts.py:230
↓ 4 callersMethodshared_embedding_or_output_weight
Gets the emedding weight or output logit weights when share embedding and output weights set to True. Returns: Tensor: During pre
megatron/core/models/common/language_module/language_module.py:155
↓ 4 callersFunctionsort_chunks_by_idxs
Split and sort the input tensor based on the split_sizes and sorted indices.
megatron/core/transformer/moe/moe_utils.py:300
↓ 4 callersMethodstart_param_sync
Initiates all necessary param all-gathers for this bucket. When ddp_config.overlap_param_gather is set to True, dispatches an asynch
megatron/core/distributed/param_and_grad_buffer.py:168
↓ 4 callersMethodstate_dict
(self)
megatron/core/optimizer/optimizer.py:860
↓ 4 callersMethodstate_dict
The state dict contains all non-DP-rank-dependent (i.e., non-parameter- related) optimizer variables. The returned state dict can be
megatron/core/optimizer/distrib_optimizer.py:579
↓ 4 callersMethodstate_dict_for_save_checkpoint
For easy load.
megatron/legacy/model/language_model.py:252
↓ 4 callersFunctionunpermute
Restore the original order of tokens after permutation. If probs are provided, it will also apply them to the tokens before restoring the ord
megatron/core/transformer/moe/moe_utils.py:262
← previousnext →301–400 of 4,219, ranked by callers