Skip to content

Conversation

Zeyi-Lin
Copy link
Member

@Zeyi-Lin Zeyi-Lin commented Jan 16, 2025

Description

实现在训练时同步wandb的实验到swanlab,只需在脚本的最开头增加,即可实现跟踪:

import swanlab

swanlab.sync_wandb()

测试代码:

import wandb
import random
import swanlab

swanlab.sync_wandb()
# swanlab.init(project="sync_wandb")

wandb.init(
  project="test",
  config={"a": 1, "b": 2},
  name="test",
  )

epochs = 10
offset = random.random() / 5
for epoch in range(2, epochs):
  acc = 1 - 2 ** -epoch - random.random() / epoch - offset
  loss = 2 ** -epoch + random.random() / epoch + offset

  wandb.log({"acc": acc, "loss": loss})

Closes: #784

Details

This pull request introduces a new feature to integrate wandb (Weights & Biases) with swanlab by adding a synchronization mechanism. The changes include importing necessary modules, defining the sync_wandb function, and updating the package's initialization and export lists.

Key changes include:

Integration with wandb:

  • swanlab/sync/wandb.py: Added the sync_wandb function to synchronize wandb with swanlab, including patching wandb.init, wandb.log, and wandb.finish to integrate with swanlab's logging and configuration management.

Module and package updates:

@Zeyi-Lin Zeyi-Lin requested a review from SAKURA-CAT January 16, 2025 15:06
@Zeyi-Lin Zeyi-Lin self-assigned this Jan 16, 2025
@SAKURA-CAT SAKURA-CAT added the 💪 enhancement New feature or request label Jan 17, 2025
@SAKURA-CAT SAKURA-CAT merged commit ffaaf97 into main Jan 17, 2025
5 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat-sync-wandb branch January 17, 2025 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQUEST] sync wandb

2 participants