Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TRACKING] feat: Integrate SwanLab for experiment tracking with online/offline mode and local dashboard support #218

Merged
merged 5 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ verl is fast with:
- Support model-based reward and function-based reward (verifiable reward)
- flash-attention, [sequence packing](examples/ppo_trainer/run_qwen2-7b_seq_balance.sh), [long context](examples/ppo_trainer/run_deepseek7b_llm_sp2.sh) support via DeepSpeed Ulysses, [LoRA](examples/sft/gsm8k/run_qwen_05_peft.sh), [Liger-kernel](examples/sft/gsm8k/run_qwen_05_sp2_liger.sh)
- scales up to 70B models and hundreds of GPUs
- experiment tracking with wandb and mlflow
- experiment tracking with wandb, swanlab and mlflow

## Upcoming Features
- Reward model training
Expand Down
20 changes: 19 additions & 1 deletion verl/utils/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


class Tracking(object):
supported_backend = ['wandb', 'mlflow', 'console']
supported_backend = ["wandb", "mlflow", "swanlab", "console"]

def __init__(self, project_name, experiment_name, default_backend: Union[str, List[str]] = 'console', config=None):
if isinstance(default_backend, str):
Expand All @@ -47,6 +47,22 @@ def __init__(self, project_name, experiment_name, default_backend: Union[str, Li
mlflow.log_params(_compute_mlflow_params_from_objects(config))
self.logger['mlflow'] = _MlflowLoggingAdapter()

if "swanlab" in default_backend:
import swanlab
import os

SWANLAB_API_KEY = os.environ.get("SWANLAB_API_KEY", None)
SWANLAB_LOG_DIR = os.environ.get("SWANLAB_LOG_DIR", "swanlog")
SWANLAB_MODE = os.environ.get("SWANLAB_MODE", "cloud")
if SWANLAB_API_KEY:
swanlab.login(SWANLAB_API_KEY) # NOTE: previous login information will be overwritten
swanlab.init(project=project_name,
experiment_name=experiment_name,
config=config,
logdir=SWANLAB_LOG_DIR,
mode=SWANLAB_MODE)
self.logger["swanlab"] = swanlab

if 'console' in default_backend:
from verl.utils.logger.aggregate_logger import LocalLogger
self.console_logger = LocalLogger(print_to_console=True)
Expand All @@ -60,6 +76,8 @@ def log(self, data, step, backend=None):
def __del__(self):
if 'wandb' in self.logger:
self.logger['wandb'].finish(exit_code=0)
if 'swanlab' in self.logger:
self.logger['swanlab'].finish()


class _MlflowLoggingAdapter:
Expand Down
Loading