Implementation:Volcengine Verl Package Init
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Package_Management, Initialization, API_Surface |
| Last Updated | 2026-02-07 18:00 GMT |
Overview
Concrete tool for initializing the verl package, exporting its public API, and applying platform-specific patches provided by the verl library.
Description
The verl/__init__.py module is the package entry point that performs several critical initialization tasks:
- Version loading — Reads __version__ from verl/version/version file
- Public API export — Exposes DataProto and __version__ via __all__
- Logging setup — Configures default WARNING-level logging
- External module loading — Imports user-specified external modules via VERL_USE_EXTERNAL_MODULES environment variable
- ModelScope integration — Optionally patches HuggingFace Hub to download from ModelScope when VERL_USE_MODELSCOPE=true
- NPU (Ascend) compatibility — When running on NPU hardware, applies patches for nested tensor operations and tensordict synchronization
Usage
This module is automatically executed when importing verl. Use from verl import DataProto to access the core data transfer protocol, or import verl; verl.__version__ to check the installed version.
Code Reference
Source Location
- Repository: Volcengine_Verl
- File: verl/__init__.py
- Lines: 1-103
Signature
# Public API
__all__ = ["DataProto", "__version__"]
# Key exports:
from .protocol import DataProto
__version__: str # Read from verl/version/version
# Environment variables:
# VERL_USE_EXTERNAL_MODULES — Comma-separated list of external module paths to import
# VERL_USE_MODELSCOPE — Set to "true" to use ModelScope hub instead of HuggingFace
Import
from verl import DataProto
import verl
print(verl.__version__)
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| VERL_USE_EXTERNAL_MODULES | env var | No | Comma-separated module paths to import at init |
| VERL_USE_MODELSCOPE | env var | No | Set to "true" to enable ModelScope hub patching |
Outputs
| Name | Type | Description |
|---|---|---|
| DataProto | class | Core data transfer protocol class for inter-module communication |
| __version__ | str | Package version string |
Usage Examples
Basic Import
from verl import DataProto
# Create a DataProto from a dictionary
data = DataProto.from_single_dict({
"input_ids": input_ids_tensor,
"attention_mask": attention_mask_tensor,
})
Using External Modules
import os
os.environ["VERL_USE_EXTERNAL_MODULES"] = "my_custom_module,another_module"
import verl # Will import my_custom_module and another_module at init
ModelScope Integration
import os
os.environ["VERL_USE_MODELSCOPE"] = "true"
import verl # HuggingFace Hub is patched to use ModelScope
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment