Swanlab
⚡️SwanLab - an open-source, modern-design AI training tracking and visualization tool. Supports Cloud / Self-hosted use. Integrated with PyTorch / Transformers / verl / LLaMA Factory / ms-swift / Ultralytics / MMEngine / Keras etc.
Last verified:
What is Swanlab?
SwanLab is an open-source, modern-design AI training tracking and visualization tool that provides a platform for tracking, recording, comparing, and collaborating on machine learning experiments. It offers a friendly Python API and beautiful UI interface designed for AI researchers and ML engineers, enabling them to visualize training processes, automatically record logs, track hyperparameters, compare experiments, and collaborate with teams online.
Key features include comprehensive experiment metric and hyperparameter tracking with support for scalar metrics, images, audio, text, video, 3D point clouds, biochemical molecules, and custom ECharts visualizations. SwanLab supports both cloud-based usage (similar to Weights & Biases) and self-hosted offline deployment. It integrates with over 30 mainstream AI frameworks including PyTorch, HuggingFace Transformers, PyTorch Lightning, LLaMA Factory, Ultralytics, Keras, TensorFlow, LightGBM, XGBoost, and more. The tool provides real-time hardware monitoring for CPU, GPU (Nvidia, Moore Threads, Metax), NPU (Ascend), MLU (Cambricon), XPU (Kunlunxin), DCU (Hygon), memory, disk, and network usage.
SwanLab is designed for AI researchers, machine learning engineers, and deep learning teams who need to track model training, debug training issues, compare multiple experiments, and collaborate on projects. It supports team collaboration through shared projects, real-time experiment synchronization, online discussion, and persistent URL sharing. The platform offers features like breakpoint resume training recording, experiment tagging, chart customization, table views with sorting/filtering, and plugin extensions for notifications (email, Slack, Discord, Feishu, DingTalk).
The tool is particularly suitable for users in China due to faster access speeds compared to international alternatives like WandB, and easier communication with the development team. It supports both Apache-2.0 licensed open-source usage and cloud deployment, making it accessible for individuals and organizations with different compliance and performance needs.
Swanlab pricing
Pricing model: Freemium
SwanLab is completely free and open-source under Apache-2.0 license. The cloud version offers free registration and use with no paid tiers mentioned. The self-hosted community edition is also free and supports offline dashboard viewing and experiment management. There is no paid premium plan - all features including cloud usage, team collaboration, hardware monitoring, and plugin extensions are available for free. Users can register for free on the official website to get an API Key for cloud usage.
Swanlab pros
- Open-source and free with Apache-2.0 license
- Supports both cloud and self-hosted offline deployment
- Fast access speed for users in China compared to WandB
- Integrates with 30+ AI frameworks including PyTorch and Transformers
- Real-time hardware monitoring for GPU, NPU, CPU, memory, disk, network
- Modern, beautiful UI with intuitive visualization dashboards
- Supports multiple data types: scalars, images, audio, text, video, 3D point clouds
- Over 20 chart types including line charts, bar charts, pie charts, heatmaps, ROC curves, confusion matrices
- Team collaboration features with shared projects and real-time synchronization
- Persistent experiment URLs for easy sharing and embedding
- Breakpoint resume training support to continue experiments
- Automatic logging of Git repository, Python environment, and working directory
- Plugin system for notifications (email, Slack, Discord, Feishu, DingTalk)
- Experiment tagging and grouping with drag-and-drop organization
- Chart customization with flexible line style, color, grid, legend position settings
- Table view with sorting, filtering, column control, and max/min value display
- MLFlow and TensorBoard sync functionality for experiment migration
- Multiple API Key management for enhanced security
- Support for resume training and adding metrics to existing experiments
- Mobile-friendly for checking experiments on phone
Swanlab cons
- Relatively new tool with smaller community compared to WandB or TensorBoard
- Self-hosted version requires Docker deployment knowledge
- Line chart output truncated at 1024 characters default limit (max 4096)
- Experiment marked as crashed if no logs uploaded within 15 minutes
- Primarily Chinese-focused documentation with some English gaps
- Cloud version requires internet connection for cloud features
- Limited third-party integrations compared to established MLOps platforms
- Fewer pre-built templates and tutorials compared to competitors
- Multi-user on same machine requires careful API Key configuration
- Some advanced features still in active development
Frequently asked questions about Swanlab
Where can I find my API Key?
After logging in to the SwanLab website, the API Key will be displayed on the user settings page at https://swanlab.cn/settings. You can copy it from there and use it for login via the command line with 'swanlab login' or in Python scripts with swanlab.login(api_key='Your API Key').
Can I use SwanLab offline?
Yes, SwanLab supports self-hosted deployment for offline use. You can deploy the self-hosted community version using Docker by cloning the self-hosted repository and running the install script. After logging in to your self-hosted server with 'swanlab login --host http://localhost:8000', you can record experiments to your private server.
How to start multiple experiments from a single script?
Add swanlab.finish() between multiple experiment creations. After executing swanlab.finish(), executing swanlab.init() again will create a new experiment. If swanlab.finish() is not executed, subsequent swanlab.init() calls will be ignored.
How to disable SwanLab logging during training for debugging?
Set the mode parameter of swanlab.init to 'disabled' to prevent experiment creation and data logging: swanlab.init(mode='disabled'). This is useful when you want to temporarily disable logging without removing SwanLab code from your script.
The local training has ended but the experiment shows as running on SwanLab UI. How to fix?
Click the stop button next to the experiment name to change the status from 'Running' to 'Interrupted' and stop receiving data uploads. Note that SwanLab also has a hidden rule: if no logs are uploaded within 15 minutes (including automatically collected system metrics), the experiment is automatically marked as 'Crashed' to prevent indefinite 'Running' state.
How to upload data to a self-hosted SwanLab?
There are two ways: 1) In Python code: swanlab.login(api_key='Your API Key', host='Your Self-Hosted Server Address'), or 2) In command line: swanlab login --host Your_Self-Hosted_Server_Address --api-key Your_API_Key. After logging in, experiments will be uploaded to your self-hosted server instead of the cloud.
On the same machine, multiple people are using SwanLab. How should it be configured?
There are two recommended methods: Method 1 - Add swanlab.login(api_key='Your API Key') at the beginning of each person's code to ensure logs go to the correct account. Method 2 - Before running the code, set the environment variable SWANLAB_API_KEY='Your API Key'. This prevents logs from being transmitted to someone else's account on shared machines.
How to enable experiment smoothing on charts?
Find the 'Settings' button in the upper right corner of the experiment page and click it. In the menu pulled out on the right, find the 'Smooth' option and slide the slider to enable smoothing. This feature can also be persisted for line charts.
How to change an experiment's 'Crashed' status?
On the experiment page, click the status label. In the pop-up window, select your desired status (Completed, Running, or Interrupted). This is useful when the training actually completed normally but was marked as crashed due to network issues or sudden termination.
What are the internal metric names I should avoid using?
Metric names refer to the key part of the dictionary passed into swanlab.log(). Some keys are internally used by SwanLab to transmit system hardware metrics, so it is not recommended to use them. Internal metrics include names starting with '_swanlab_.xxx'. Using these names may conflict with SwanLab's automatic hardware metric collection.