Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/DLYuanGod/MegaTrain
/ functions
Functions
5,181 in github.com/DLYuanGod/MegaTrain
⨍
Functions
5,181
◇
Types & classes
739
↳
Endpoints
136
↓ 2 callers
Function
apply_qat_patches
Apply NVFP4 patches to support dynamic weight updates. Call before model loading.
verl/verl/utils/qat/vllm_patch.py:737
↓ 2 callers
Function
apply_qat_to_modules
Apply ModelOpt fake quantization to a list of Megatron module chunks.
verl/verl/utils/modelopt/qat_utils.py:39
↓ 2 callers
Method
apply_rotary
Apply rotary embeddings to query and key tensors. Args: q: Query tensor [B, T, num_heads, head_dim] k: Key t
infinity/ops/layers.py:98
↓ 2 callers
Function
apply_rotary_pos_emb_absolute
Reroute to the appropriate apply_rotary_pos_emb function depending on bshd (conventional) / thd (packed seq) format In Qwen2-VL, the sha
verl/verl/models/mcore/qwen2_5_vl/rope_utils.py:239
↓ 2 callers
Function
apply_router_replay_patch
Applies the monkey patch for MoE Router Replay functionality. This patch dynamically adds the 'enable_routing_replay' attribute to Transforme
verl/verl/utils/megatron/router_replay_patch.py:337
↓ 2 callers
Function
apply_tiled_mlp_monkey_patch
Apply TiledMLP monkey patch based on model_type. This function MUST be called BEFORE model instantiation to take effect. It patches the MLP c
verl/verl/models/transformers/tiled_mlp.py:177
↓ 2 callers
Function
apply_vllm_fp8_patches
()
verl/verl/utils/vllm/vllm_fp8_utils.py:723
↓ 2 callers
Function
assemble_batch_from_rollout_samples
Assemble gen_batch_output from RolloutSample objects Assembles batches from RolloutSample objects, similar to the _post_generate_batch logic
verl/verl/experimental/fully_async_policy/detach_utils.py:92
↓ 2 callers
Function
async_copy_params
Async copy parameters from CPU to GPU buffer
infinity/cuda_pipeline/layer_pipeline.cpp:7
↓ 2 callers
Method
async_send_weights
Send weights to the receiver. Accepts a sync generator or async iterator. Args: weights: Generator or async iterator yie
verl/verl/workers/rollout/vllm_rollout/bucketed_weight_transfer.py:102
↓ 2 callers
Function
backup_base_model_weights
Backup base model weights to CPU with LoRA temporarily disabled. This function temporarily disables LoRA adapters, backs up the clean base model
verl/verl/utils/fsdp_utils.py:936
↓ 2 callers
Method
begin_read
Start the read operation.
verl/verl/checkpoint_engine/nixl_checkpoint_engine.py:205
↓ 2 callers
Function
broadcast_dict_tensor
Broadcast all tensors in a dictionary from source rank to all ranks. Iterates over all tensors in the dictionary and broadcasts each one from
verl/verl/utils/torch_functional.py:388
↓ 2 callers
Method
build_packed_seq_params
( self, grid_thw: Optional[torch.Tensor], cu_seqlens: Optional[torch.Tensor] = None,
verl/verl/models/mcore/qwen2_5_vl/vision_model.py:289
↓ 2 callers
Function
build_peft_config_for_vllm
Build a peft_config dict compatible with vLLM's PEFTHelper from megatron lora config. Args: lora_config: Megatron lora configuration dict
verl/verl/utils/megatron_peft_utils.py:131
↓ 2 callers
Function
build_scheduler
Build and configure the scheduler for the diffusion model. The returned scheduler has timesteps and sigmas already set. Args: model_c
verl/verl/models/diffusers_model/utils.py:69
↓ 2 callers
Function
build_sglang_profiler_args
Build arguments for SGLang profiler. Args: profiler_config (ProfilerConfig): The unified profiler configuration. tool_config
verl/verl/utils/profiler/config.py:239
↓ 2 callers
Function
build_vllm_profiler_args
Build arguments and environment variables for vLLM profiler. Acts as an adapter to bridge verl's unified profiler config and vLLM's specific
verl/verl/utils/profiler/config.py:193
↓ 2 callers
Method
bulk_offload_group
Bulk offload group.
verl/verl/utils/activation_offload.py:298
↓ 2 callers
Function
calc_cpu_memory
Calculate required CPU memory in GB. MegaTrain stores on CPU: - FP32 master weights: 4 bytes/param - Adam optimizer states (m + v): 8
scripts/calc_resource.py:90
↓ 2 callers
Function
calc_gpu_fixed
Calculate fixed GPU memory usage in GB. Fixed components: - CUDA context: ~2 GB - Double-buffered layer templates: 2 * layer_size_bf1
scripts/calc_resource.py:101
↓ 2 callers
Function
calc_maj_val
Calculate a value based on majority voting. This function identifies the most common value for a specified vote key in the data, then re
verl/verl/trainer/ppo/metric_utils.py:478
↓ 2 callers
Method
calculate_score
Calculates a score for the interaction, potentially considering aspects like partial exposure & in-context task switching. sh
verl/verl/interactions/base.py:56
↓ 2 callers
Method
call_batch
(self, data: dict[str, Any])
verl/verl/experimental/vla/models/pi0_torch/pi0_utils.py:230
↓ 2 callers
Function
call_sandbox_api
Calls the remote sandbox API to execute code with retry logic for Gateway Timeout, using increasing delay between retries. Logs internal call
verl/verl/utils/reward_score/sandbox_fusion/utils.py:67
↓ 2 callers
Function
call_search_api
Calls the remote search API to perform retrieval with retry logic for various errors, using increasing delay between retries. Logs internal
verl/verl/tools/utils/search_r1_like_utils.py:34
↓ 2 callers
Function
ceil_div
Perform ceiling division of two integers.
verl/verl/utils/kernel/fp8_kernel.py:41
↓ 2 callers
Function
ceildiv
Compute ceiling division of a by b. Returns the smallest integer greater than or equal to a/b. Uses the identity: ceil(a/b) = floor((a + b -
verl/verl/utils/seqlen_balancing.py:305
↓ 2 callers
Function
check_exclude_modules
A helper method to check if the passed module's key name matches any of the exclude modules in the adapter_config. Adapted from https://githu
verl/verl/utils/model.py:263
↓ 2 callers
Function
check_mutually_exclusive
Validate mutually exclusive micro batch size configuration options. Ensures that users don't set both deprecated micro_batch_size and
verl/verl/utils/config.py:117
↓ 2 callers
Function
check_target_modules
A helper method to check if the passed module's key name matches any of the target modules in the adapter_config. Adapted from https://github
verl/verl/utils/model.py:286
↓ 2 callers
Method
cleanup
Stop worker threads/processes and cleanup resources.
infinity/model/cpu_master.py:1876
↓ 2 callers
Method
clear_kv_cache
(self)
verl/verl/workers/rollout/vllm_rollout/vllm_async_server.py:595
↓ 2 callers
Function
compute_gae_advantage_return
Adapted from https://github.com/huggingface/trl/blob/main/trl/trainer/ppo_trainer.py Args: token_level_rewards: `(torch.Tensor)`
verl/verl/trainer/ppo/core_algos.py:216
↓ 2 callers
Function
compute_grpo_outcome_advantage
Compute advantage for GRPO, operating only on Outcome reward (with only one scalar reward for each response). Args: token_level_
verl/verl/trainer/ppo/core_algos.py:268
↓ 2 callers
Method
compute_log_prob
(self, data: DataProto)
verl/verl/workers/megatron_workers.py:900
↓ 2 callers
Method
compute_log_prob
(self, data: DataProto)
verl/verl/workers/fsdp_workers.py:1125
↓ 2 callers
Function
compute_response_mask
Compute the attention mask for the response part of the sequence. This function extracts the portion of the attention mask that corresponds to th
verl/verl/trainer/ppo/ray_trainer.py:118
↓ 2 callers
Function
compute_rollout_corr_metrics_from_logprobs
Compute rollout correction metrics from log probabilities during training. This function is used in the actor to compute metrics using the CURREN
verl/verl/trainer/ppo/rollout_corr_helper.py:1063
↓ 2 callers
Method
compute_teacher_logprobs_single
Compute teacher log probabilities for a single unpadded sequence.
verl/verl/experimental/teacher_loop/teacher_manager.py:107
↓ 2 callers
Function
concat_tensordict
Concatenate multiple TensorDicts along dimension zero. Combines a list of TensorDicts into a single TensorDict by concatenating all tensors a
verl/verl/utils/tensordict_utils.py:224
↓ 2 callers
Function
convert_checkpoint_from_transformers_to_megatron_dpskv3
( hf_model, model, hf_config, tfconfig, layer_start_end: Optional[tuple[int, int]] = None,
verl/scripts/converter_hf_to_mcore.py:330
↓ 2 callers
Function
convert_megatron_to_hf_target_modules
Convert megatron lora target modules to HF-style module names. Args: megatron_modules: List of megatron-style module names. Returns:
verl/verl/utils/megatron_peft_utils.py:112
↓ 2 callers
Method
convert_param
(self, name: str, params_one_group: list[torch.Tensor])
verl/verl/models/mcore/weight_converter.py:30
↓ 2 callers
Function
copy_async
Async copy from src to dst on given stream.
infinity/runtime/stream.py:55
↓ 2 callers
Function
create_and_sync_state
(param_name, state, is_param)
verl/verl/utils/fsdp_utils.py:341
↓ 2 callers
Function
create_colocated_worker_raw_cls
This function returns a FusedWorker class. `FusedWorker.{class_name}` -> FusedClass Use `class_name` as a param to directly access t
verl/verl/single_controller/ray/base.py:1029
↓ 2 callers
Function
create_data_samples
(num_device: int, model_config: DiffusionModelConfig)
verl/tests/models/test_diffusers_fsdp_engine.py:106
↓ 2 callers
Function
create_data_samples
(tokenizer, data_source="ocr")
verl/tests/experimental/reward_loop/test_visual_reward_manager.py:26
↓ 2 callers
Function
create_device_mesh
(world_size, fsdp_size)
verl/verl/workers/fsdp_workers.py:104
↓ 2 callers
Function
create_model
Load a Qwen3-1.7B model with only 2 layers from pretrained weights.
verl/tests/models/test_tiled_mlp_accuracy.py:34
↓ 2 callers
Function
create_peft_model
()
verl/tests/utils/test_normalize_peft_param_name_on_cpu.py:36
↓ 2 callers
Function
create_random_input_ids
(batch_size, seq_len, vocab_size)
verl/tests/utils/test_activation_offload.py:33
↓ 2 callers
Function
create_random_input_ids
(batch_size, seq_len, vocab_size)
verl/tests/special_distributed/test_fsdp_ckpt.py:31
↓ 2 callers
Function
create_role_worker_mapping
Create mapping from roles to worker classes Args: config: Configuration object Returns: dict: Mapping from roles to wor
verl/verl/experimental/separation/utils.py:57
↓ 2 callers
Function
create_sft_dataset
Create a dataset.
verl/verl/trainer/sft_trainer_ray.py:395
↓ 2 callers
Function
create_sft_dataset
Create a dataset.
verl/verl/trainer/sft_trainer.py:464
↓ 2 callers
Function
create_test_image
(width: int = 224, height: int = 224)
verl/tests/workers/rollout/rollout_trtllm/test_trtllm_rollout_utils.py:35
↓ 2 callers
Function
create_training_config
(model_type, strategy, device_count, model)
verl/tests/models/test_engine.py:71
↓ 2 callers
Function
default_tp_concat_fn
name: name of the parameter train_params: training parameters infer_params (Iterable[torch.Tensor]): a iterator towards list of parameter
verl/verl/utils/megatron_utils.py:940
↓ 2 callers
Method
embed_suffix
Embed state, action and time tokens as the transformer suffix. Args: state: (B, state_dim) robot state; ignored when pi05 is enab
verl/verl/experimental/vla/models/pi0_torch/model/modeling_pi0.py:304
↓ 2 callers
Function
enable_qat_fuse
Enable QAT fuse mode: sets up fusion siblings for weight scale fusion.
verl/verl/utils/qat/core.py:177
↓ 2 callers
Method
encode
(self, query_list: list[str], is_query=True)
verl/examples/sglang_multiturn/search_r1_like/local_dense_retriever/retrieval_server.py:78
↓ 2 callers
Method
encode_prompt
( self, prompt_ids: torch.Tensor, attention_mask: torch.Tensor | None = None,
verl/examples/flowgrpo_trainer/vllm_omni/pipeline_qwenimage.py:119
↓ 2 callers
Method
env_interact_step
This function is used to interact with the environment.
verl/verl/experimental/vla/workers/env/env_worker.py:145
↓ 2 callers
Method
env_keys
The keys of the environment variables that are used to configure the Worker.
verl/verl/single_controller/base/worker.py:169
↓ 2 callers
Method
eval_mode
Context manager entry for switching the engine and model into evaluation mode. Usage: with engine.eval_mode():
verl/verl/workers/engine/base.py:67
↓ 2 callers
Method
execute_rank_zero_async
Execute a method on rank zero worker asynchronously. Args: method_name: Name of the method to execute *args: Position
verl/verl/single_controller/ray/base.py:808
↓ 2 callers
Function
export_qat_weights
Process exported weights through QATWeightExporter for quantized weight sync.
verl/verl/utils/modelopt/qat_utils.py:53
↓ 2 callers
Function
extract_solution
Extract the equation from the solution string.
verl/verl/utils/reward_score/search_r1_like_qa_em.py:66
↓ 2 callers
Function
extract_step
(path)
verl/verl/utils/checkpoint/checkpoint_handler.py:33
↓ 2 callers
Method
finalize
( self, processing_class: PreTrainedTokenizer | PreTrainedTokenizerFast | ProcessorMixin,
verl/verl/workers/rollout/schemas.py:551
↓ 2 callers
Method
finish_rollout
(self, mode="train")
verl/verl/experimental/vla/workers/env/env_worker.py:244
↓ 2 callers
Method
fit
The training loop of PPO. The driver process only need to call the compute functions of the worker group through RPC to const
verl/verl/trainer/ppo/ray_trainer.py:1295
↓ 2 callers
Method
flow_sde_beta
(self)
verl/verl/experimental/vla/models/pi0_torch/modeling_pi0_torch.py:366
↓ 2 callers
Method
forward
Full forward pass for one diffusion denoising step. Args: images: List of image tensors, each shaped (B, C, H, W) after batching.
verl/verl/experimental/vla/models/pi0_torch/model/modeling_pi0.py:161
↓ 2 callers
Method
forward_and_backward_custom_loss
Forward + backward with an externally provided loss function. Used by VERL integration where the loss is computed externally (PPO, DPO, etc.)
infinity/model/cpu_master.py:1623
↓ 2 callers
Method
forward_backward_batch
( self, data: DataProto, forward_only=False, use_dynamic_bsz=False, mi
verl/verl/workers/critic/megatron_critic.py:159
↓ 2 callers
Method
forward_backward_batch
We assume: - The model takes input: (input_ids, attention_mask, position_ids). No rmpad for the input - The communication sha
verl/verl/workers/actor/megatron_actor.py:399
↓ 2 callers
Function
forward_base_model
r""" Copy paste LLaMa's forward https://github.com/linkedin/Liger-Kernel/blob/main/src/liger_kernel/transformers/model/llama.py This func
verl/verl/models/transformers/dense_common.py:29
↓ 2 callers
Method
forward_step
(self, micro_batch: TensorDict, loss_function, forward_only)
verl/verl/workers/engine/fsdp/transformer_impl.py:623
↓ 2 callers
Method
from_string
(cls, name: str)
verl/verl/trainer/ppo/utils.py:59
↓ 2 callers
Function
fused_forward_model_engine
(vision_model: bool = False)
verl/verl/models/mcore/model_forward_fused.py:140
↓ 2 callers
Method
gated_residual
(self, x, y, gate)
verl/verl/experimental/vla/models/pi0_torch/model/paligemma_with_expert.py:496
↓ 2 callers
Method
generate
Generate text using the SGLang server asynchronously.
verl/verl/workers/rollout/sglang_rollout/http_server_engine.py:831
↓ 2 callers
Method
generate_backward_inputs
(self)
verl/tests/utils/test_linear_cross_entropy.py:160
↓ 2 callers
Method
generate_forward_inputs
(self)
verl/tests/utils/test_linear_cross_entropy.py:146
↓ 2 callers
Method
generate_hyper
(self)
verl/tests/utils/test_linear_cross_entropy.py:113
↓ 2 callers
Method
generate_sequences
Generate sequences
verl/verl/experimental/vla/sac/naive_rollout_pi05.py:55
↓ 2 callers
Method
get
(self)
verl/verl/protocol.py:1212
↓ 2 callers
Function
get_checkpoint_tracker_filename
Tracker file rescords the latest chckpoint during training to restart from.
verl/verl/utils/checkpoint/checkpoint_manager.py:230
↓ 2 callers
Function
get_common_default_kwargs_for_parallel_linear
()
verl/verl/utils/megatron/tensor_parallel.py:52
↓ 2 callers
Function
get_custom_reward_fn
Load and return a custom reward function from external file. Dynamically imports a reward function from a specified file path and wraps it wi
verl/verl/trainer/ppo/reward.py:50
↓ 2 callers
Function
get_data
()
verl/verl/utils/tensordict_utils.py:604
↓ 2 callers
Method
get_data_parallel_group
(self)
verl/verl/workers/engine/veomni/transformer_impl.py:306
↓ 2 callers
Method
get_data_parallel_group
(self)
verl/verl/workers/engine/fsdp/diffusers_impl.py:430
↓ 2 callers
Method
get_data_parallel_rank
(self)
verl/verl/workers/engine/megatron/transformer_impl.py:524
↓ 2 callers
Method
get_data_parallel_size
(self)
verl/verl/workers/engine/fsdp/transformer_impl.py:576
↓ 2 callers
Function
get_dp_group_size
Get data-parallel group size from device mesh.
verl/verl/workers/engine/automodel/utils.py:46
↓ 2 callers
Function
get_entropy_reduction_enum
Get the enum for the reduction method of cross entropy.
verl/verl/utils/kernel/kernels.py:129
← previous
next →
901–1,000 of 5,181, ranked by callers