SwanLab Documentation
repository·main·Indexed 26 days ago
https://github.com/swanhubx/swanlabA professional AI training analysis platform and Python library for tracking, visualizing, and managing experiments. SwanLab integrates with over 50 machine learning frameworks and supports hardware monitoring for NVIDIA, AMD, Ascend, and other accelerators. It features an object-oriented API (swanlab.Api), support for complex data types like 3D objects and molecules, and synchronization tools for Weights & Biases, TensorBoard, and MLFlow. The platform supports both cloud synchronization and self-hosted Community Edition deployments.
What's inside swanlab
- SwanLab is a professional, modern AI training analysis platform designed for model training teams. It integrates with over 50 mainstream frameworks and is designed to combine easily with your experimental code. It provides tools for tracking experiments, visualizing training processes, and managing model development.
Overview of the Hardware Vendor Module
mainThe Hardware Vendor Module is a specialized component in SwanLab designed to handle the collection and monitoring of hardware information. Because different hardware manufacturers use different methods for data acquisition and monitoring, this module is partitioned into sub-modules, where each sub-module is responsible for a specific vendor and provides a unified interface for upper-layer calls.
The
acceleratorsub-module is specifically responsible for collecting and monitoring information from accelerators such as GPUs, NPUs, and TPUs.Overview of SwanLab features
mainSwanLab is an open-source tool for tracking and visualizing AI model training. Key capabilities include:
- Metric & Hyperparameter Tracking: Supports scalars, images, audio, text, 3D points, and biochemical molecules. Automatically logs hardware info, Git repo, and Python environment.
- Framework Integration: Supports 30+ frameworks including PyTorch, HuggingFace Transformers, PyTorch Lightning, LLaMA Factory, Ultralytics, and more.
- Hardware Monitoring: Monitors CPU, NPU (Ascend), GPU (Nvidia), MLU (Cambricon), and memory.
- Experiment Management: Centralized dashboard for managing multiple projects, comparing results via tables/graphs, and real-time team collaboration.
- Self-Hosting: Supports offline/local use with a local dashboard.
- Extensibility: Plugin system for features like Lark/Slack notifications and CSV logging.
Understand SwanLab Protobuf Data Structure
mainSwanLab uses Protobuf to define all structured data produced during a run. Data is written to log files in an append-only format, where every entry is wrapped in a top-level
Recordenvelope.Key design principles:
- Append-only: Ensures data integrity and supports log replay.
- Monotonic IDs: The
numfield in eachRecordis globally monotonically increasing to support deduplication and breakpoint resumption. - Decoupled Media: Media data (images, audio, video) is not inlined in the
Record. Instead, theRecordstores a file path reference and metadata, while the actual files are written to disk separately. This keeps theRecordfiles lightweight for streaming.
Compare SwanLab with Tensorboard and Weights & Biases
mainSwanLab vs Tensorboard
- Online Support: SwanLab supports cloud synchronization for remote progress tracking, sharing experiment links, and real-time notifications. Tensorboard is primarily an offline tool.
- Collaboration: SwanLab enables multi-person/multi-team collaboration and project management. Tensorboard is designed for individuals.
- Centralized Dashboard: SwanLab provides a single centralized dashboard regardless of where the model is trained (local, cluster, or cloud). Tensorboard requires manual management of TFEvent files across different machines.
- Advanced Tables: SwanLab offers powerful tables to search, filter, and compare results across thousands of model versions.
SwanLab vs Weights & Biases
- Openness: Weights & Biases is a closed-source MLOps platform that requires an internet connection. SwanLab supports both online use and open-source, free, self-hosted deployment.
SwanLab Core Features Overview
mainSwanLab is an AI model training tracking and visualization tool with the following capabilities:
- Experiment Metrics and Hyperparameter Tracking: Supports scalars, images, audio, text, 3D point clouds, biological chemical molecules, and Echarts custom charts. Supports resuming training records.
- Hardware Monitoring: Real-time monitoring for CPU, NPU (Ascend), GPU (Nvidia, AMD, MLU, XLU, DCU, MetaX, Moore Threads, Iluvatar), and memory.
- Framework Integration: Supports 30+ frameworks including PyTorch, HuggingFace, PyTorch Lightning, LLaMA Factory, MMDetection, Ultralytics, Keras, XGBoost, and more.
- Experiment Management: Centralized dashboard for managing multiple projects and comparing results via online tables and charts.
- Collaboration: Online web sharing and multi-user collaborative training.
- Plugin System: Supports extensions like Lark/Slack notifications and CSV loggers.
Monitor hardware and resource usage
mainSwanLab automatically records hardware information and resource utilization during AI training. Supported hardware includes:
- GPUs: NVIDIA, AMD, Huawei Ascend (NPU), Cambricon (MLU), Kunlunxin (XPU), Moore Threads, MetaX, Iluvatar, and Hygon (DCU).
- CPU: General CPU monitoring.
- Memory: System memory monitoring.
If you require monitoring for other hardware, you can contribute via Issues or Pull Requests.
Access SwanLab community support and related repositories
mainRelated Repositories
- self-hosted: Private deployment scripts.
- SwanLab-Docs: Official documentation.
- SwanLab-Dashboard: Web code for the lightweight offline dashboard opened via
swanlab watch.
Support Channels
- GitHub Issues: Report errors or problems.
- Email Support: Feedback regarding usage (zeyi.lin@swanhub.co).
- WeChat Group: Discussions on usage and AI technology sharing.
Extend SwanLab with plugins and OpenAPI
mainYou can enhance your experiment management experience by using plugins or interacting with the SwanLab OpenAPI.
Available Plugins:
- Notifications: Email, Feishu (Lark), DingTalk, WeChat Work, Discord, Slack, Bark.
- Data Logging: CSV Logger.
- Custom Plugins: You can develop and implement your own custom plugins.
API Access:
- Use the OpenAPI to programmatically interact with SwanLab features.
Integrate SwanLab with machine learning frameworks
mainSwanLab provides integrations for a wide variety of frameworks across different domains. Supported integrations include:
- Core Frameworks: PyTorch, MindSpore, Keras.
- LLM Training: HuggingFace Transformers, LLaMA Factory, MS-Swift, Unsloth, MLX-LM, Torchtune, Sentence Transformers, XTuner, OpenMind.
- LLM Reinforcement Learning: veRL, HuggingFace trl, NVIDIA-NeMo RL, EasyR1, AReaL, ROLL.
- Deep Learning & CV: PyTorch Lightning, MMEngine, FastAI, Ultralytics, MMDetection, MMSegmentation, PaddleDetection, PaddleYOLO, PaddleNLP.
- Machine Learning: LightGBM, XGBoost, CatBoost.
- Robotics: RLinf.
- Generative AI (Text-to-Image/Video): DiffSynth Studio.
- Evaluation: EvalScope.
- Reinforcement Learning: Stable Baseline3.
- Other Tools: Tensorboard, Weights & Biases, MLFlow, HuggingFace Accelerate, Ray, Hydra, Omegaconf, SpecForge.
For instructions on integrating any specific library, refer to the official integration guides.
Explore SwanLab tutorials and research examples
mainSwanLab is used in various open-source projects, research papers, and practical tutorials. You can find implementation examples for:
- LLM Training & Fine-tuning: Projects like
happy-llm,self-llm, andunlock-deepseekprovide guidance on fine-tuning and deploying Large Language Models. - Computer Vision: Tutorials cover MNIST, FashionMNIST, CIFAR-10, ResNet (Cat vs. Dog), YOLO object detection, and U-Net medical image segmentation.
- Reinforcement Learning: Examples include DQN (CartPole) and various LLM agent RL algorithms (PPO, GRPO, etc.).
- Natural Language Processing: Tutorials for BERT text classification, NER (Named Entity Recognition), and RAG (Retrieval-Augmented Generation).
- Generative AI: Stable Diffusion text-to-image fine-tuning and multimodal model training (e.g., Qwen2-VL).
- LLM Training & Fine-tuning: Projects like
Self-host SwanLab Dashboard
mainSwanLab provides a community edition for self-hosting, allowing you to view dashboards and manage experiments in offline environments. Deployment options include Kubernetes and Docker.
Refer to the official documentation for specific deployment guides: