Skip to content

[Integration] add swanlab logger #10594

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 6 commits into
base: develop
Choose a base branch
from

Conversation

Zeyi-Lin
Copy link

@Zeyi-Lin Zeyi-Lin commented May 14, 2025

Pull Request Description

This PR introduces SwanLab, a lightweight open-source experiment tracking tool, as a new logging option for the training framework. The integration provides both online and offline tracking capabilities, along with a local dashboard for visualizing results.

image

We have officially integrated with excellent open-source projects such as transformers, LLaMA Factory, and veRL. We are also very eager to integrate with the outstanding 🌟Ultralytics to provide developers with a better training experience.

🎬Here is a onlinedemo of the integrated effect:

https://swanlab.cn/@ZeyiLin/Qwen2.5-0.5B-SFT-paddlenlp/runs/myyyg5lbbikbnvdtw11zr/chart

image

Below is a detailed overview of the changes and usage instructions:

Key Features of SwanLab Integration

1. Online and Offline Tracking:

  • Online Mode: Track experiments remotely and store data on SwanLab's cloud platform.
  • Offline Mode: Use a local dashboard to visualize training logs without an internet connection.

2. Hardware Monitoring:

  • Automatically tracks GPU usage, power consumption, temperature, and other hardware metrics.
  • Supports NVIDIA GPUs, Huawei Ascend NPUs and Kunlunxin XPUs.

3. Remote Access:

  • View training progress remotely via the SwanLab web interface or mobile app.

4. Local Dashboard:

  • Includes an open-source local dashboard for offline visualization of training logs.

Usage Instructions

Step 1: Set Up Online Tracking (Optional)

Install:

pip install swanlab

To use SwanLab's online tracking, log in to the SwanLab website and obtain your API key from the Settings page. Then, authenticate using the following command:

swanlab login

If you prefer offline mode, skip this step.

Step 2: Configure SwanLab as the Logger

To enable SwanLab as the experiment tracker, Please execute the following command to enable swanlab:

"""
Tested on:
pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
pip install paddlenlp==3.0.0b4
"""
from paddlenlp.trl import SFTConfig, SFTTrainer
from datasets import load_dataset

dataset = load_dataset("ZHUI/alpaca_demo", split="train")

training_args = SFTConfig(
    output_dir="Qwen/Qwen2.5-0.5B-SFT",
    device="gpu",
    per_device_train_batch_size=1,
    logging_steps=20,
    report_to="swanlab",
    )

trainer = SFTTrainer(
    args=training_args,
    model="Qwen/Qwen2.5-0.5B-Instruct",
    train_dataset=dataset,
)

trainer.train()

Then, You can now happily use SwanLab for experiment tracking!

Step 3: View Training Logs

After logging in, you will see a confirmation message:

image image

For more details, refer to the SwanLab Cloud Documentation.

  • Offline Tracking: Use the local dashboard to visualize logs:
swanlab watch

For advanced configurations, such as setting a custom port, refer to the Offline Dashboard Documentation and CLI Documentation.

Impact

  • Provides a lightweight, flexible, and user-friendly experiment tracking solution.
  • Supports both online and offline use cases, making it suitable for environments with restricted internet access.
  • Enhances hardware monitoring capabilities for better resource utilization.

Copy link

paddle-bot bot commented May 14, 2025

Thanks for your contribution!

@CLAassistant
Copy link

CLAassistant commented May 14, 2025

CLA assistant check
All committers have signed the CLA.

@Zeyi-Lin Zeyi-Lin requested a review from ZHUI May 16, 2025 03:06
@Zeyi-Lin
Copy link
Author

Zeyi-Lin commented May 16, 2025

@ZHUI Hey, 🤔it seems that the test failure was not caused by my commits. Could you please run the test again? 😄Thank you!

@ZHUI
Copy link
Collaborator

ZHUI commented May 16, 2025

Ok, i'll re-run those tests.

@ZHUI ZHUI closed this May 16, 2025
@ZHUI ZHUI reopened this May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants