Skip to content

Add a New Experiment Tracker: SwanLab #1413

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

YushunXiang
Copy link
Contributor

@YushunXiang YushunXiang commented Jun 30, 2025

This pull request introduces support for SwanLab as an experiment tracker alongside WandB in the training pipeline. Key changes include the addition of a SwanLabLogger utility, updates to configuration classes, and modifications to the training script to integrate SwanLab logging.

SwanLab Integration:

  • lerobot/common/utils/swanlab_utils.py: Added a new utility module containing the SwanLabLogger class for logging metrics, policies, and videos to SwanLab. This includes helper functions for generating group names, retrieving run IDs, and sanitizing artifact names.
  • pyproject.toml: Added swanlab>=0.6.4 as a dependency to enable SwanLab integration.

Configuration Updates:

  • lerobot/configs/default.py: Introduced a new SwanLabConfig class for SwanLab-specific configurations, such as enabling/disabling artifacts, specifying project details, and setting the tracking mode. Updated WandBConfig with a deprecation notice for enable and additional fields for better compatibility with the new tracking system.
  • lerobot/configs/train.py: Updated TrainPipelineConfig to include a tracker field for selecting between "wandb," "swanlab," "both," or "none." Added validation logic to ensure valid tracker selection and enable the appropriate configuration dynamically. [1] [2]

Training Script Enhancements:

  • lerobot/scripts/train.py: Modified the training script to initialize and use SwanLabLogger based on the selected tracker. Added support for logging metrics, policies, and videos to SwanLab during training and evaluation phases. [1] [2] [3] [4]

Usage Example:

python lerobot/scripts/train.py \
    --dataset.repo_id=lerobot/test  \
    --dataset.root=your-local-path \
    --output_dir=output/test \
    --policy.device=cuda \
    --policy.type=diffusion \
    --policy.push_to_hub=false \
    --steps=1000000 \
    --save_freq=20000 \
    --num_workers=8 \
    --batch_size=16 \
    --tracker=swanlab \
    --swanlab.project=your-project \
    --swanlab.run_id=test \

Set tracker=swanlab


If you have a plan to merge this PR, I will update the document in detial. @aliberts

@Copilot Copilot AI review requested due to automatic review settings June 30, 2025 14:38
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces SwanLab integration as a new experiment tracker option alongside WandB in the training workflow. It adds a new SwanLabLogger utility, updates configuration classes to support the new tracker, and modifies the training script to initialize and use SwanLab logging when selected.

  • Added SwanLabLogger in lerobot/common/utils/swanlab_utils.py to handle logging of metrics, policies, and videos to SwanLab.
  • Updated pyproject.toml with the swanlab dependency and modified configuration files to support dynamic tracker selection.
  • Enhanced lerobot/scripts/train.py to initialize and utilize SwanLabLogger based on the chosen tracker.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Added swanlab dependency
lerobot/scripts/train.py Updated logger initialization and logging calls to include SwanLab
lerobot/configs/train.py Updated config with tracker field and validation logic
lerobot/configs/default.py Added SwanLabConfig and updated WandBConfig with deprecation notices
lerobot/common/utils/swanlab_utils.py Introduced SwanLabLogger and helper functions for SwanLab integrations

match = re.search(r"run-([^\.]+).swanlab", paths[0].split("/")[-1])
if match is None:
raise RuntimeError("Couldn't get the previous SwanLab run ID for run resumption.")
swanlab_run_id = match.groups(0)[0]
Copy link
Preview

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using match.group(1) instead of match.groups(0)[0] for clarity when extracting the run ID.

Suggested change
swanlab_run_id = match.groups(0)[0]
swanlab_run_id = match.group(1)

Copilot uses AI. Check for mistakes.

YushunXiang and others added 6 commits June 30, 2025 22:46
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Yushun Xiang <[email protected]>
* Move files

* Replace imports & paths

* Update relative paths

* Update doc symlinks

* Update instructions paths

* Fix imports

* Update grpc files

* Update more instructions

* Downgrade grpc-tools

* Update manifest

* Update more paths

* Update config paths

* Update CI paths

* Update bandit exclusions

* Remove walkthrough section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants