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

Merged
merged 7 commits into from
May 27, 2025

Conversation

Zeyi-Lin
Copy link
Contributor

@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
Contributor 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
Copy link

codecov bot commented May 23, 2025

Codecov Report

Attention: Patch coverage is 76.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 46.96%. Comparing base (c309aa7) to head (dc68aac).
Report is 9 commits behind head on develop.

Current head dc68aac differs from pull request most recent head 5145f13

Please upload reports for the commit 5145f13 to get more accurate results.

Files with missing lines Patch % Lines
paddlenlp/trainer/integrations.py 76.00% 12 Missing ⚠️

❌ Your patch status has failed because the patch coverage (76.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.
❌ Your project status has failed because the head coverage (46.96%) is below the target coverage (58.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #10594      +/-   ##
===========================================
+ Coverage    46.91%   46.96%   +0.05%     
===========================================
  Files          799      799              
  Lines       132457   132398      -59     
===========================================
+ Hits         62136    62175      +39     
+ Misses       70321    70223      -98     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ZHUI ZHUI merged commit 062debf into PaddlePaddle:develop May 27, 2025
4 of 5 checks passed
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