instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Provide clean and structured docstrings | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright 2025 Giga Team. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/... | --- +++ @@ -28,6 +28,7 @@
def get_safe_dtype(dtype: torch.dtype, device: str | torch.device) -> torch.dtype:
+ """Mps is currently not compatible with float64."""
if isinstance(device, torch.device):
device = device.type
if device == "mps" and dtype == torch.float64:
@@ -39,6 +40,8 @@ def crea... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/models/pi0_torch/model/modeling_pi0.py |
Create docstrings for each class method | # Copyright 2025 Meituan Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | --- +++ @@ -20,6 +20,16 @@
def create_resource_pool_manager(config, roles: list) -> ResourcePoolManager:
+ """
+ Create resource pool manager
+
+ Args:
+ config: Configuration object
+ roles: List of roles that need to create resource pools
+
+ Returns:
+ ResourcePoolManager: Resour... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/separation/utils.py |
Create structured documentation for my script | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -181,6 +181,14 @@
class BroadcastOperation:
+ """Async broadcast operation in separate thread.
+
+ Args:
+ rank (int): The rank of the current process.
+ ranks_group (int): The process group's value.
+ bucket (torch.Tensor): The tensor to broadcast.
+ metadata (list[Para... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/checkpoint_engine/kimi_checkpoint_engine.py |
Write docstrings describing each step | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -13,6 +13,7 @@ # limitations under the License.
+"""Utility helpers to register custom VLA models with Hugging Face Auto classes."""
from transformers import AutoConfig, AutoImageProcessor, AutoProcessor
@@ -31,6 +32,7 @@
def register_openvla_oft() -> None:
+ """Register the OpenVLA OFT model... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/models/register_vla_models.py |
Create documentation strings for testing functions | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2023-2024 SGLang Team
# Copyright 2025 ModelBest Inc. and/or its affiliates
# Copyright 2025 Meituan Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the ... | --- +++ @@ -14,6 +14,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+PPO Trainer with Ray-based single controller.
+This trainer supports model-agonistic model initialization w... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/separation/ray_trainer.py |
Write beginner-friendly docstrings | # Copyright 2025 The RLinf Authors.
# Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
... | --- +++ @@ -52,6 +52,19 @@
def to_tensor(array: dict | torch.Tensor | np.ndarray | list | Any, device: str = "cpu") -> dict | torch.Tensor:
+ """
+ Copied from ManiSkill!
+ Maps any given sequence to a torch tensor on the CPU/GPU. If physx gpu
+ is not enabled then we use CPU, otherwise GPU, unless spec... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/envs/action_utils.py |
Improve documentation using docstrings | # Copyright 2025 Meituan Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | --- +++ @@ -38,6 +38,9 @@
class FullyAsyncLLMServerManager(AsyncLLMServerManager):
+ """FullyAsyncLLMServerManager supports resume generation on partial rollout, making rollout interruption
+ invisible to the AgentLoop.
+ """
@rollout_trace_op
async def generate(
@@ -49,6 +52,18 @@ imag... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/fully_async_policy/agent_loop/agent_loop.py |
Add docstrings that explain inputs and outputs | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright 2025 Meituan Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/license... | --- +++ @@ -33,13 +33,36 @@
class DetachActorWorker(ActorRolloutRefWorker):
+ """
+ A worker class that extends ActorRolloutRefWorker to support detaching and restoring the actor model.
+
+ This worker facilitates saving the model state to CPU and restoring it, enabling efficient
+ resource management a... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/separation/engine_workers.py |
Fully document this Python code with docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -35,10 +35,16 @@
class CheckpointEngineRegistry:
+ """Checkpoint engine registry."""
_registry: dict[str, type["CheckpointEngine"]] = {}
def register(backend: str):
+ """Register a checkpoint engine.
+
+ Args:
+ backend: The backend of the checkpoint engine.
+ ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/checkpoint_engine/base.py |
Generate docstrings with examples | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -21,6 +21,20 @@
class SupportSACTraining:
+ """
+ Base class for Soft Actor-Critic (SAC).
+
+ Subclasses implement a Policy that can be plugged directly into SAC training.
+ This implementation requires the actor and critic to be integrated within a
+ single model instance, e.g., sharing a... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/sac/base.py |
Generate docstrings for this script | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -23,6 +23,7 @@
class SACReplayPool:
+ """SAC Replay Pool for storing samples."""
def __init__(
self,
@@ -40,6 +41,12 @@ self.sample_device = sample_device
def add_batch(self, batch: TensorDict):
+ """Add a batch of samples to the replay pool.
+
+ Args:
+ ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/sac/replay_pool.py |
Write Python docstrings for this snippet | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Single Process Actor
+"""
import logging
@@ -40,6 +43,7 @@ actor_module: nn.Module,
ac... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/dp_rob.py |
Write docstrings for backend logic | # Copyright 2025 The RLinf Authors.
# Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#... | --- +++ @@ -141,6 +141,9 @@ @register(dispatch_mode=make_nd_compute_dataproto_dispatch_fn(mesh_name="env"), blocking=False)
@DistProfiler.annotate(color="red", role="env_interact_step")
def env_interact_step(self, data: DataProto) -> dict:
+ """
+ This function is used to interact with the e... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/workers/env/env_worker.py |
Add detailed docstrings explaining each function | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2023-2024 SGLang Team
# Copyright 2025 ModelBest Inc. and/or its affiliates
# Copyright 2025 Meituan Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the ... | --- +++ @@ -14,6 +14,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+This trainer supports model-agonistic model initialization with huggingface
+"""
import asyncio
import u... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/one_step_off_policy/ray_trainer.py |
Add docstrings to clarify complex logic | # Copyright 2025 The RLinf Authors.
# Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
... | --- +++ @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utils for evaluating policies in LIBERO simulation environments."""
import math
@@ -21,18 +22,48 @@
def get_libero_image(obs: dict[str, np.ndarray]) -> np.ndarray:
+ """
+ ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/envs/libero_env/utils.py |
Add inline docstrings for readability | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Single Process Actor
+"""
import logging
import os
@@ -33,6 +36,16 @@
def get_dict_from_prefix(tenso... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/sac/sac_actor.py |
Add concise docstrings to each method | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -12,6 +12,29 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""
+This script is used to merge huggingface model and test verl checkpoints from FSDP and Megatron backends.
+
+To merge FSDP checkpoints:
+```sh
+python scripts/legacy_model_merger.py... | https://raw.githubusercontent.com/verl-project/verl/HEAD/scripts/legacy_model_merger.py |
Add docstrings to improve collaboration | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -13,6 +13,17 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""
+This script override a model with custom config and random weights, mainly for create small models for
+debugging purposes.
+
+Usage:
+ python scripts/init_random_model.py \
+ ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/scripts/init_random_model.py |
Create documentation strings for testing functions | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,14 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+In single GPU rollout, the sequences are generated directly by sampling from the model.
+The output will co... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/naive_rollout_rob.py |
Add detailed documentation for each class | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -51,6 +51,15 @@ async def extract_tool_calls(
self, responses_ids: list[int], tools: list[OpenAIFunctionToolSchema] = None
) -> tuple[str, list[FunctionCall]]:
+ """Extract tool calls from the responses.
+
+ Args:
+ responses_ids (List[int]): The ids of the response... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/agent_loop/tool_parser.py |
Document helper functions with docstrings | # Copyright 2025 The RLinf Authors.
# Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#... | --- +++ @@ -157,6 +157,7 @@ self.env_cls = env_cls
def start_simulator(self):
+ """Start simulator process with shared memory queues"""
if self.process:
logger.info(f"Simulator process already running for rank {self.rank}")
return
@@ -245,6 +246,7 @@ retu... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/workers/env/env_manager.py |
Add missing documentation to my Python functions | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -34,6 +34,12 @@ _class_initialized = False
def __init__(self, config: DictConfig, tokenizer: AutoTokenizer, compute_score: RawRewardFn):
+ """Initialize reward manager.
+
+ Args:
+ config (DictConfig): YAML config.
+ tokenizer (AutoTokenizer): Tokenizer for toke... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/reward_loop/reward_manager/base.py |
Write docstrings describing each step | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright 2025 Giga Team. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/... | --- +++ @@ -24,6 +24,12 @@
class Normalize:
+ """Normalize robot state vectors using mean/std or quantiles.
+
+ Args:
+ stats: A dict containing either {'mean', 'std'} or {'q01', 'q99'}.
+ use_quantiles: If True, use quantile based normalization.
+ """
def __init__(self, stats: dict[st... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/models/pi0_torch/pi0_utils.py |
Add professional docstrings to my codebase | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -33,6 +33,14 @@
@CheckpointEngineRegistry.register("mooncake")
class MooncakeCheckpointEngine(CheckpointEngine):
+ """Mooncake checkpoint engine with p2p communication using TransferEngine
+
+ Args:
+ bucket_size (int): Bucket size in bytes to transfer multiple weights at one time.
+ d... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/checkpoint_engine/mooncake_checkpoint_engine.py |
Write docstrings that follow conventions | # Copyright 2025 Amazon.com Inc and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Dataset class that enables dynamic data generation strategies between iterations of training.
+This class e... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/dynamic_dataset/dynamicgen_dataset.py |
Write proper docstrings for these functions | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -17,6 +17,20 @@
class MLP(nn.Module):
+ """
+ A configurable Multi-Layer Perceptron (MLP) module.
+ It supports dynamic layer construction, multiple activation functions,
+ and various weight initialization strategies.
+
+ Attributes:
+ input_dim (int): The number of input features.... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/models/modules/mlp.py |
Generate missing documentation strings | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -330,6 +330,7 @@
@on(Input.Submitted, "#reqid-box")
async def on_reqid_submitted(self, event: Input.Submitted) -> None:
+ """Jump to the sample that has a matching `request_id`."""
req_id_raw = event.value.strip()
# Remove hyphens so search is tolerant to different id fo... | https://raw.githubusercontent.com/verl-project/verl/HEAD/scripts/rollout_viewer.py |
Add docstrings to improve code quality | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -40,6 +40,17 @@
def compute_response_mask(config, data: DataProto) -> torch.Tensor:
+ """Compute the attention mask for the response part of the sequence.
+
+ This function extracts the portion of the attention mask that corresponds to the model's response,
+ which is used for masking computatio... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/sac/sac_ray_trainer.py |
Add docstrings to make code maintainable | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -22,6 +22,12 @@
def register(name: str) -> Callable[[type[RewardManagerBase]], type[RewardManagerBase]]:
+ """Decorator to register a reward manager class with a given name.
+
+ Args:
+ name: `(str)`
+ The name of the reward manager.
+ """
def decorator(cls: type[RewardM... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/reward_loop/reward_manager/registry.py |
Annotate my code with docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -25,12 +25,20 @@
class RewardModelManager:
+ """Reward model manager."""
def __init__(
self,
config: RewardModelConfig,
resource_pool: RayResourcePool = None,
):
+ """
+ Initialize the reward model manager.
+
+ Args:
+ config (Rewa... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/reward_loop/reward_model.py |
Create documentation for each function signature | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -89,6 +89,7 @@ retry_delay: float = 2.0,
verbose: bool = False,
) -> None:
+ """A minimal async load-balancing router."""
self.verbose = verbose
self.app = FastAPI()
self.worker_urls = worker_urls
@@ -112,6 +113,7 @@ self.client = None
as... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/reward_loop/router/naive_router.py |
Document this module using docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -56,6 +56,7 @@
@ray.remote
class GlobalRequestLoadBalancer:
+ """Global sticky-session + in-flight load balancer shared by all AgentLoopWorkers."""
def __init__(self, server_actor_ids: list[str], max_cache_size: int = DEFAULT_ROUTING_CACHE_SIZE):
if not server_actor_ids:
@@ -65,6 +66,7 ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/agent_loop/agent_loop.py |
Generate helpful docstrings for debugging | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | --- +++ @@ -15,6 +15,13 @@ # from https://github.com/PRIME-RL/SimpleVLA-RL/blob/main/verl/utils/vla_utils/openvla_oft/
# form https://huggingface.co/Haozhan72/Openvla-oft-SFT-libero10-trajall/blob/main/
+"""
+modeling_prismatic.py
+
+Core HuggingFace-style PrismaticPreTrainedModel and PrismaticForConditionalGenerati... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/models/openvla_oft/modeling_prismatic.py |
Help me add docstrings to my project | # Copyright 2025 Amazon.com Inc and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -21,6 +21,7 @@
class AbstractSampler(Sampler[int]):
+ """Abstract interface for custom samplers."""
@abstractmethod
def __init__(
@@ -32,7 +33,8 @@
class AbstractCurriculumSampler(AbstractSampler):
+ """Experimental interface for curriculum learning samplers."""
@abstractmeth... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/dataset/sampler.py |
Document functions with clear intent | # Copyright 2025 The RLinf Authors.
# Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
... | --- +++ @@ -89,6 +89,7 @@ return self._elapsed_steps
def get_all_state_ids(self):
+ """Returns all possible state IDs from the entire benchmark."""
return np.arange(self.total_num_group_envs) # (total_num_states,)
def _init_env(self):
@@ -398,9 +399,14 @@ self.render_image... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/vla/envs/libero_env/libero_env.py |
Add docstrings for internal functions | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -17,6 +17,24 @@
def resolve_config_path(config_path: str) -> str:
+ """Resolve agent loop configuration file path.
+
+ In multi-node Ray training, relative paths may not resolve correctly
+ because the working directory on remote nodes can differ from the driver node.
+ This function resolves... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/agent_loop/utils.py |
Add docstrings that explain purpose and usage | # Copyright 2025 Meituan Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | --- +++ @@ -45,12 +45,17 @@
class TrainingStopException(Exception):
+ """Exception raised to signal training should stop"""
pass
@ray.remote(num_cpus=10)
class FullyAsyncTrainer(SeparateRayPPOTrainer):
+ """
+ A fully asynchronous PPO trainer that obtains samples from a MessageQueue for traini... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/fully_async_policy/fully_async_trainer.py |
Write docstrings for data processing functions | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -30,6 +30,55 @@
class AsyncTokenBucket:
+ """Async token bucket for rate limiting with variable token consumption.
+
+ The token bucket algorithm is a classic rate limiting technique that allows
+ for burst traffic while maintaining an average rate limit. This implementation
+ is async-first ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/experimental/reward_loop/reward_manager/limited.py |
Generate docstrings with parameter types | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -33,6 +33,15 @@
class LinearForLastLayer(torch.nn.Linear):
+ """
+ A custom linear layer implementation for the last layer of a model.
+
+ This layer extends PyTorch's Linear module with functionality specifically designed
+ for handling the final layer in transformer models with sequence par... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/bridge.py |
Add docstrings to improve collaboration | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.... | --- +++ @@ -45,6 +45,7 @@ data_format: str = "thd",
mtp_config: MtpConfig = None,
):
+ """Forward pass for models with sequence packing."""
assert data_format in ["thd", "bshd"], "data_format must be 'thd' or 'bshd'"
pre_process = (
unwrap_model(model).pre_pro... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/model_forward.py |
Add docstrings to my Python code | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.... | --- +++ @@ -32,6 +32,18 @@ def _get_base_transformer_config(
hf_config: PretrainedConfig, dtype: torch.dtype, **override_transformer_config_kwargs
) -> dict:
+ """
+ Create a base TransformerConfig with common parameters across different model architectures.
+ TODO: (ycl) use dataclass or converter confi... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/config_converter.py |
Add detailed docstrings explaining each function | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
#
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
# and OPT implementations in this library. It has been modified from its
# original forms to accommodate minor ar... | --- +++ @@ -17,6 +17,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""PyTorch LLaMA model with Megatron-style acceleration."""
from typing import Optional
@@ -44,6 +45,9 @@
... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/llama/megatron/modeling_llama_megatron.py |
Add docstrings for utility scripts | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -24,6 +24,12 @@
def _megatron_calc_layer_map(config):
+ """Calculate the mapping of global layer_idx to local layer_idx
+ Returns:
+ layer_map (Dict: int -> tuple(int, int, int)):
+ mapping from the global layer index to
+ a tuple of (pp_rank, virtual_pp_rank, layer_idx... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/loader.py |
Fully document this Python code with docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2023-2024 SGLang Team
# Copyright 2025 ModelBest Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | --- +++ @@ -23,6 +23,14 @@ self.name: str = config.get("name", "interaction_agent") # More general agent default role name
async def start_interaction(self, instance_id: Optional[str] = None, **kwargs) -> str:
+ """Create a tool instance.
+
+ Args:
+ instance_id: The instance id... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/interactions/base.py |
Add missing documentation to my Python functions | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2024 Alibaba PAI Team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of th... | --- +++ @@ -36,6 +36,71 @@ second_per_grid_ts: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
):
+ """
+ Calculate the 3D rope index based on image and video's temporal, height and width in LLM.
+
+ Explanation:
+
+ Each embedding sequence contains vision embeddi... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/qwen2_5_vl/rope_utils.py |
Add docstrings to improve readability | # Copyright 2023-2024 SGLang Team
# Copyright 2025 ModelBest Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | --- +++ @@ -25,6 +25,7 @@
def get_interaction_class(cls_name):
+ """Dynamically import and return the interaction class."""
module_name, class_name = cls_name.rsplit(".", 1)
if module_name not in sys.modules:
spec = importlib.util.find_spec(module_name)
@@ -39,6 +40,14 @@
def initialize_in... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/interactions/utils/interaction_registry.py |
Generate descriptive docstrings automatically | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2024 Alibaba PAI Team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of th... | --- +++ @@ -35,6 +35,43 @@
# Note: This is under development and may be missing features.
class Qwen2_5VLModel(MegatronModule):
+ """Qwen2.5VL multi-modal model.
+
+ Args:
+ language_transformer_config (TransformerConfig): Transformer config for the language model.
+ language_transformer_layer_sp... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/qwen2_5_vl/model.py |
Generate docstrings with parameter types | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -21,6 +21,12 @@
def _megatron_calc_layer_map(config):
+ """Calculate the mapping of global layer_idx to local layer_idx
+ Returns:
+ layer_map (Dict: int -> tuple(int, int, int)):
+ mapping from the global layer index to
+ a tuple of (pp_rank, virtual_pp_rank, layer_idx... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/llama/megatron/checkpoint_utils/llama_loader.py |
Write docstrings describing functionality | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -36,6 +36,11 @@ attention_mask: Optional[torch.Tensor] = None,
**kwargs,
) -> torch.Tensor:
+ """
+ Gets the position ids for Qwen3-VL, it should be generated before sharding the sequence.
+ The batch dim has been removed and the input_ids should be a 1D tensor representing a single exampl... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/qwen3_vl.py |
Create simple docstrings for beginners | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2024 Alibaba PAI Team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of th... | --- +++ @@ -31,6 +31,7 @@ packed_seq_params_full: PackedSeqParams,
fullatt_block_indexes,
):
+ """Forward method with activation checkpointing."""
def custom(start: int, end: int):
def custom_forward(hidden_states, attention_mask, context, context_mask, rotary_pos_em... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/qwen2_5_vl/vision_transformer_block.py |
Generate documentation strings for clarity | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -68,6 +68,10 @@ video_grid_thw: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
) -> torch.Tensor:
+ """
+ Gets the position ids for GLM4V in padding-free format.
+ The batch dim has been removed and the input_ids should be a 1D tensor representing a singl... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/glm4v.py |
Create docstrings for each class method | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -45,6 +45,9 @@ *,
inference_params=None,
):
+ """
+ Derives `query`, `key` and `value` tensors from `hidden_states`.
+ """
# s = sequence length, b = batch size, h = hidden size, n = num attention heads
# Attention heads [s, b, n*h]
assert... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/patch.py |
Write proper docstrings for these functions | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Copyright 2025 The Qwen Team and The HuggingFace Inc. team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -1,283 +1,320 @@-# Copyright 2025 Bytedance Ltd. and/or its affiliates
-#
-# Copyright 2025 The Qwen Team and The HuggingFace Inc. team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the Lic... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/npu_patch.py |
Help me add docstrings to my project | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -27,6 +27,7 @@
def _megatron_calc_global_rank(tp_rank: int = 0, dp_rank: int = 0, pp_rank: int = 0):
+ """given TP,DP,PP rank to get the global rank."""
tp_size = mpu.get_tensor_model_parallel_world_size()
dp_size = mpu.get_data_parallel_world_size()
@@ -39,6 +40,12 @@
def _megatron_ca... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/qwen2/megatron/checkpoint_utils/qwen2_saver.py |
Add docstrings that explain inputs and outputs | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -85,6 +85,25 @@
@dataclass
class ModelMergerConfig:
+ """Configuration for model merger operations.
+
+ Args:
+ operation (str): Operation type - 'merge' or 'test'.
+ backend (str): Backend type for the model ('fsdp' or 'megatron').
+ target_dir (Optional[str]): Directory to sav... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/model_merger/base_model_merger.py |
Add docstrings to meet PEP guidelines | # Copyright 2023-2025 SGLang Team
# Copyright Amazon.com, Inc. or its affiliates.
# Copyright 2025 ModelBest Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ... | --- +++ @@ -30,8 +30,34 @@
class Geo3kTool(BaseTool):
+ """A demo tool for calculating the reward of geo3k.
+ - `get_openai_tool_schema`: return the tool schema in OpenAI format.
+ - `create`: create a tool instance for a trajectory.
+ - `execute`: execute the tool.
+ - `calc_reward`: calculate the r... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/tools/geo3k_tool.py |
Write documentation strings for class attributes | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+FSDP2-compatible TiledMLP implementation for memory-efficient MLP computation.
+
+This module provides a ti... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/tiled_mlp.py |
Add missing documentation to my Python functions | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -29,12 +29,26 @@
def _compute_fp8_thd_align_size(align_size: int) -> tuple[int, int]:
+ """Compute FP8 alignment sizes for thd-format sequences.
+
+ For FP8 block quantization, each sequence must be padded to a multiple of
+ lcm(16, align_size), and the total padded length must be divisible by
+... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/util.py |
Add docstrings that explain purpose and usage | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -30,6 +30,7 @@ def _megatron_calc_global_rank(
tp_rank: int = 0, dp_rank: int = 0, pp_rank: int = 0, cp_rank: int = 0, ep_rank: int = 0
):
+ """Calculate global rank with support for CP/EP parallelism"""
# Get parallel sizes for each dimension
tp_size = mpu.get_tensor_model_parallel_worl... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/saver.py |
Add docstrings for production code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -33,6 +33,7 @@
# Copied from transformers.models.llama.modeling_llama.rotate_half
def rotate_half(x):
+ """Rotates half the hidden dims of the input."""
x1 = x[..., : x.shape[-1] // 2]
x2 = x[..., x.shape[-1] // 2 :]
return torch.cat((-x2, x1), dim=-1)
@@ -40,6 +41,26 @@
# Copied from ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/kimi_vl.py |
Add docstrings for production code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -21,6 +21,12 @@
def _megatron_calc_layer_map(config):
+ """Calculate the mapping of global layer_idx to local layer_idx
+ Returns:
+ layer_map (Dict: int -> tuple(int, int, int)):
+ mapping from the global layer index to
+ a tuple of (pp_rank, virtual_pp_rank, layer_idx... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/qwen2/megatron/checkpoint_utils/qwen2_loader_depracated.py |
Create structured documentation for my script | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Implement base data transfer protocol between any two functions, modules.
+We can subclass Protocol to defi... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/protocol.py |
Fill in missing docstrings in my code | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2024 Alibaba PAI Team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of th... | --- +++ @@ -71,6 +71,18 @@
class Qwen2_5VisionModel(VisionModule):
+ """Qwen2.5 ViT vision model.
+
+ Args:
+ transformer_config (TransformerConfig): Transformer config.
+ transformer_layer_spec (ModuleSpec): Specifies module to use for transformer layers.
+ ln_pre_impl (ModuleSpec or typ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/qwen2_5_vl/vision_model.py |
Add docstrings for production code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -51,6 +51,11 @@ position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
**kwargs,
) -> tuple[torch.Tensor, Optional[torch.Tensor], Optional[tuple[torch.Tensor]]]:
+ """
+ Adapted from transformers 4.47.1 to support Ulysses sequence parallelis... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/llama.py |
Create Google-style docstrings for my code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -21,6 +21,12 @@
def _megatron_calc_layer_map(config):
+ """Calculate the mapping of global layer_idx to local layer_idx
+ Returns:
+ layer_map (Dict: int -> tuple(int, int, int)):
+ mapping from the global layer index to
+ a tuple of (pp_rank, virtual_pp_rank, layer_idx... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/qwen2/megatron/checkpoint_utils/qwen2_loader.py |
Provide clean and structured docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -67,6 +67,15 @@
def sort_placement_group_by_node_ip(pgs: list[PlacementGroup]) -> list[PlacementGroup]:
+ """
+ Sort the placement groups by node ip, all bundles in a single placement group should be on the same node.
+
+ FSDPCheckpointManager saves sharded model states and optimizer states in l... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/single_controller/ray/base.py |
Improve my code by adding docstrings | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.... | --- +++ @@ -25,6 +25,7 @@
class BaseModelInitializer(ABC):
+ """Base class for model initializers."""
def __init__(self, tfconfig: TransformerConfig, hf_config: PretrainedConfig):
self.tfconfig = tfconfig
@@ -33,9 +34,12 @@
@abstractmethod
def get_transformer_layer_spec(self, vp_stage=... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/model_initializer.py |
Replace inline comments with docstrings | # official torch 2.6.0 set_model_state_dict API leads to OOM
# this is a copy of torch/distributed/checkpoint from torch 2.7.0
# From PyTorch:
# Copyright (c) 2016- Facebook, Inc (Adam Paszke)
# Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
# Copyright (c) 2011-2014 Idiap Research... | --- +++ @@ -180,6 +180,41 @@
@dataclass
class StateDictOptions:
+ """
+ This dataclass specifies how get_state_dict/set_state_dict will work.
+
+ - ``full_state_dict``: if this is set to True, all the tensors in the
+ returned state_dict will be gathered. No ShardedTensor and DTensor
+ will be in ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/third_party/torch/distributed/checkpoint/state_dict.py |
Create Google-style docstrings for my code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -27,6 +27,7 @@
def _megatron_calc_global_rank(tp_rank: int = 0, dp_rank: int = 0, pp_rank: int = 0):
+ """given TP,DP,PP rank to get the global rank."""
tp_size = mpu.get_tensor_model_parallel_world_size()
dp_size = mpu.get_data_parallel_world_size()
@@ -39,6 +40,12 @@
def _megatron_ca... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/llama/megatron/checkpoint_utils/llama_saver.py |
Add verbose docstrings with examples | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -43,6 +43,11 @@ cache_position: Optional[torch.LongTensor] = None,
position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None, # will become mandatory in v4.46
):
+ """
+ Adapted from transformers 4.47.1 to support Ulysses sequence parallelism.
+
+ NOTE: This function is only... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/qwen2.py |
Add docstrings to improve code quality | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2024 Alibaba PAI Team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of th... | --- +++ @@ -20,6 +20,10 @@
class Qwen2_5VLSelfAttention(SelfAttention):
+ """
+ Overrides the SelfAttention class, the difference is that qwen2_5_vl uses apply_rotary_pos_emb_absolute
+ instead of apply_rotary_pos_emb
+ """
def forward(
self,
@@ -37,6 +41,28 @@ inference_params: ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/qwen2_5_vl/attention.py |
Improve documentation using docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+the class for Worker
+"""
import os
import socket
@@ -71,10 +74,26 @@
# we assume that in each WorkerG... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/single_controller/base/worker.py |
Fully document this Python code with docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -21,6 +21,12 @@
def _megatron_calc_layer_map(config):
+ """Calculate the mapping of global layer_idx to local layer_idx
+ Returns:
+ layer_map (Dict: int -> tuple(int, int, int)):
+ mapping from the global layer index to
+ a tuple of (pp_rank, virtual_pp_rank, layer_idx... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/llama/megatron/checkpoint_utils/llama_loader_depracated.py |
Add docstrings to meet PEP guidelines | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# Copyright 2025 Meituan Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not ... | --- +++ @@ -79,6 +79,11 @@ extra_block_kwargs=None,
inference_context=None,
):
+ """Postprocesses decoder hidden states to generate logits or compute loss.
+
+ Applies Multi-Token Prediction if enabled, generates output logits through
+ the output layer, and computes language model loss when labels a... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/mtp_patch.py |
Add docstrings for better understanding | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -55,6 +55,15 @@
def get_dynamic_pipeline_shards(layer_num: int, pp_size: int) -> list[int]:
+ """Calculate the pipeline sharding configuration for Megatron-LM.
+
+ Args:
+ layer_num: Total number of layers in the model.
+ pp_size: Number of pipeline parallel ranks.
+
+ Returns:
+ ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/model_merger/megatron_model_merger.py |
Fully document this Python code with docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -23,6 +23,12 @@
class Dispatch(DynamicEnum):
+ """Enum class defining different dispatch modes for distributed computation.
+
+ Each mode represents a specific strategy for distributing data across
+ different ranks in a distributed system. The modes are used to control
+ how data is partitio... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/single_controller/base/decorator.py |
Insert docstrings into my code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Metrics related to the PPO trainer.
+"""
from collections import defaultdict
from functools import parti... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/trainer/ppo/metric_utils.py |
Add docstrings for internal functions | # official torch 2.6.0 set_model_state_dict API leads to OOM
# this is a copy of torch/distributed/checkpoint from torch 2.7.0
# From PyTorch:
# Copyright (c) 2016- Facebook, Inc (Adam Paszke)
# Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
# Copyright (c) 2011-2014 Idiap Research... | --- +++ @@ -169,6 +169,27 @@ type_check: bool = True,
non_blocking: bool = True,
) -> dict[str, Any]:
+ """Iterate through the state dict, applying the given functions to each tensor type.
+
+ Args:
+ iter_object (Any): the target state_dict.
+ sharded_tensor_func (Callable): the function ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/third_party/torch/distributed/_state_dict_utils.py |
Add docstrings including usage examples | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -69,6 +69,11 @@ second_per_grid_ts: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
) -> torch.Tensor:
+ """
+ Gets the position ids for Qwen2-VL, it should be generated before sharding the sequence.
+ The batch dim has been removed and the input_ids should be... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/qwen2_vl.py |
Document my Python code with docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Apply monkey-patch function to models
+"""
import sys
from types import SimpleNamespace
@@ -35,6 +38,7 @... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/transformers/monkey_patch.py |
Add docstrings to incomplete code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org... | --- +++ @@ -12,6 +12,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Core functions to implement PPO algorithms.
+The function implemented in this file should be used by traine... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/trainer/ppo/core_algos.py |
Generate docstrings for this script | # Copyright 2023-2024 SGLang Team
# Copyright 2025 ModelBest Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | --- +++ @@ -22,6 +22,16 @@
class BaseTool:
+ """Base class for tools.
+
+ A tool should support the following methods:
+
+ - `get_openai_tool_schema`: return the tool schema in OpenAI format.
+ - `create`: create a tool instance for a trajectory.
+ - `execute`: execute the tool.
+ - `calc_reward`:... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/tools/base_tool.py |
Add concise docstrings to each method | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -33,8 +33,45 @@
class FSDPModelMerger(BaseModelMerger):
+ """
+ Model merger for FSDP (Fully Sharded Data Parallel) checkpoints.
+
+ This class handles the conversion of FSDP distributed checkpoints into HuggingFace format.
+ FSDP shards model parameters across multiple processes, and this me... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/model_merger/fsdp_model_merger.py |
Add docstrings for internal functions | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
#
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
# and OPT implementations in this library. It has been modified from its
# original forms to accommodate minor ar... | --- +++ @@ -77,6 +77,7 @@
class Qwen2LinearScalingRotaryEmbedding(Qwen2RotaryEmbedding):
+ """Qwen2RotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
self.sca... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/qwen2/megatron/layers/parallel_attention.py |
Generate consistent docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+the class of WorkerGroup
+"""
import logging
import signal
@@ -22,8 +25,20 @@
class ResourcePool:
+ ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/single_controller/base/worker_group.py |
Help me document legacy Python code | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -99,8 +99,35 @@
class SandboxFusionTool(BaseTool):
+ """A tool for executing the code using sanbox fusion image.
+
+ - `get_openai_tool_schema`: return the tool schema in OpenAI format.
+ - `create`: create a tool instance for a trajectory.
+ - `execute`: execute the tool.
+ - `calc_reward... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/tools/sandbox_fusion_tools.py |
Write docstrings for utility functions | # Copyright 2025 Bytedance Ltd. and/or its affiliates
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.... | --- +++ @@ -12,6 +12,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Registry module for model architecture components.
+"""
from enum import Enum
from typing import Callabl... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/mcore/registry.py |
Document classes and their methods | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
#
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
# and OPT implementations in this library. It has been modified from its
# original forms to accommodate minor ar... | --- +++ @@ -17,6 +17,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""PyTorch Qwen2 model."""
from typing import Optional
@@ -45,6 +46,9 @@
# Copied from transformers.models... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/qwen2/megatron/modeling_qwen2_megatron.py |
Insert docstrings into my code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2023-2024 SGLang Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | --- +++ @@ -1,213 +1,245 @@-# Copyright 2024 Bytedance Ltd. and/or its affiliates
-# Copyright 2023-2024 SGLang Team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.a... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/tools/utils/search_r1_like_utils.py |
Add inline docstrings for readability | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2023-2024 SGLang Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | --- +++ @@ -37,6 +37,7 @@
# Adapted from verl/tools/sandbox_fusion_tools.py
class PoolMode(Enum):
+ """Execution pool mode enumeration."""
ThreadMode = 1
ProcessMode = 2
@@ -44,6 +45,7 @@
@ray.remote(concurrency_groups={"acquire": 1, "release": 10})
class TokenBucketWorker:
+ """Ray actor for ra... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/tools/image_zoom_in_tool.py |
Add docstrings to improve collaboration | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -24,6 +24,9 @@
class Role(Enum):
+ """
+ To create more roles dynamically, you can subclass Role and add new members
+ """
Actor = 0
Rollout = 1
@@ -69,16 +72,19 @@ def need_reference_policy(
config: DictConfig,
) -> bool:
+ """Given the config, do we need ref policy."""
... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/trainer/ppo/utils.py |
Provide clean and structured docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -27,6 +27,18 @@
class BaseCheckpointManager:
+ """
+ A checkpoint manager that saves and loads the following states in a SPMD way:
+ - model
+ - optimizer
+ - lr_scheduler
+ - extra_states
+
+ We save
+ - sharded model states and optimizer states
+ - full lr_scheduler states
+ ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/utils/checkpoint/checkpoint_manager.py |
Generate docstrings for script automation | # Copyright 2025 Individual Contributor: Thibaut Barroyer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... | --- +++ @@ -30,16 +30,42 @@
def _call_with_kwargs(raw_fn, extra_kwargs, *args, **kwargs):
+ """Calls `raw_fn` by merging `extra_kwargs` into call-time `kwargs`, with `extra_kwargs` taking precedence.
+
+ This function is used to merge additional keyword arguments with the original function's arguments.
+ "... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/trainer/ppo/reward.py |
Generate consistent docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2023-2024 SGLang Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | --- +++ @@ -1,197 +1,279 @@-# Copyright 2024 Bytedance Ltd. and/or its affiliates
-# Copyright 2023-2024 SGLang Team
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.a... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/tools/search_tool.py |
Create docstrings for reusable components | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2025 ModelBest Inc. and/or its affiliates
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/license... | --- +++ @@ -12,6 +12,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Multi-turn SFT dataset that supports training on conversation data with multiple turns
+"""
import loggin... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/utils/dataset/multiturn_sft_dataset.py |
Auto-generate documentation strings for this file | # Copyright 2025 Bytedance Ltd. and/or its affiliates
import logging
import os
from transformers import PreTrainedTokenizerBase, ProcessorMixin
from verl.utils.tokenizer import normalize_token_ids
logger = logging.getLogger(__name__)
logger.setLevel(os.getenv("VERL_LOGGING_LEVEL", "WARN"))
def initialize_system_pr... | --- +++ @@ -11,6 +11,16 @@
def initialize_system_prompt(tokenizer, **apply_chat_template_kwargs) -> list[int]:
+ """
+ Initialize system prompt tokens for chat templates that support them.
+
+ Args:
+ tokenizer: The tokenizer with a chat template
+ **apply_chat_template_kwargs: Additional arg... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/utils/chat_template.py |
Add docstrings for utility scripts | # Copyright 2025 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -47,6 +47,11 @@
class CheckpointHandler:
+ """
+ Checkpoint handler handles the path, global_step of a checkpoint folder.
+ Currently, it only works with a single model.
+ We can expand it to support multiple models. It is expected to be used with SPMD style (e.g., torchrun)
+ """
d... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/utils/checkpoint/checkpoint_handler.py |
Generate docstrings for each module | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2023-2024 SGLang Team
# Copyright 2025 ModelBest Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | --- +++ @@ -38,6 +38,17 @@
def collate_fn(data_list: list[dict]) -> dict:
+ """
+ Collate a batch of sample dicts into batched tensors and arrays.
+
+ Args:
+ data_list: List of dicts mapping feature names to torch.Tensor or other values.
+
+ Returns:
+ Dict where tensor entries are stacke... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/utils/dataset/rl_dataset.py |
Create Google-style docstrings for my code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
#
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
# and OPT implementations in this library. It has been modified from its
# original forms to accommodate minor ar... | --- +++ @@ -72,6 +72,7 @@
class LlamaLinearScalingRotaryEmbedding(LlamaRotaryEmbedding):
+ """LlamaRotaryEmbedding extended with linear scaling. Credits to the Reddit user /u/kaiokendev"""
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):
self.sca... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/models/llama/megatron/layers/parallel_attention.py |
Add documentation for all methods | # Copyright 2023-2024 SGLang Team
# Copyright 2025 ModelBest Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | --- +++ @@ -19,6 +19,7 @@
class OpenAIFunctionPropertySchema(BaseModel):
+ """The schema of a parameter in OpenAI format."""
type: str
description: str | None = None
@@ -26,6 +27,7 @@
class OpenAIFunctionParametersSchema(BaseModel):
+ """The schema of parameters in OpenAI format."""
typ... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/tools/schemas.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.