> This page is for version Nightly (default).
> For other versions, use one of these documentation indexes:
> - Nightly (default): https://docs.nvidia.com/nemo/automodel/nightly/llms.txt
> - Latest: https://docs.nvidia.com/nemo/automodel/latest/llms.txt
> - 0.5.0 · 26.06: https://docs.nvidia.com/nemo/automodel/v0.5/llms.txt
> - 0.4.0 · 26.04: https://docs.nvidia.com/nemo/automodel/v0.4/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/automodel/_mcp/server.

# SwanLab Logging in NeMo AutoModel

> Log NeMo AutoModel training runs to SwanLab alongside or instead of Weights & Biases, including offline clusters.

## Introduction

[SwanLab](https://swanlab.cn) is an experiment tracker with a W\&B-compatible API. NeMo AutoModel can log every run to SwanLab in addition to Weights & Biases, which is also useful where the W\&B servers are not reachable.

SwanLab logging mirrors the W\&B logger instead of adding a second set of logging calls to every recipe: when it is enabled, each `wandb.init`, `wandb.log`, `wandb.config.update`, and `finish` a recipe makes is forwarded to SwanLab. SwanLab therefore records the same items as W\&B: the project, run name, tags, group, notes, the full run config, and every logged metric at the same step (see [Notes](#notes) for one difference).

## Prerequisites

Install the `swanlab` extra (it pulls in `wandb` as well):

```bash
uv pip install "nemo-automodel[swanlab]"
```

Provide your SwanLab API key through the `SWANLAB_API_KEY` environment variable (or run `swanlab login` once). The key is never part of the YAML.

## Configuration

Add a `swanlab` sub-block to the recipe's `wandb` section:

```yaml
wandb:
  project: my-project
  name: qwen3_0p6b_hellaswag
  swanlab:
    mode: online
```

The run keeps logging to W\&B as before and is also logged to SwanLab under the same project and run name.

### Configuration Parameters

| Parameter         | Type | Default  | Description                                                                                                                                          |
| ----------------- | ---- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mode`            | str  | `online` | `online` uploads to SwanLab, `offline` writes the run locally for a later `swanlab sync`, `local` keeps it local only, `disabled` turns SwanLab off. |
| `workspace`       | str  | null     | SwanLab workspace (user or organization). If null, uses the account's default workspace.                                                             |
| `log_dir`         | str  | null     | Local directory for SwanLab run files. If null, uses the SDK default.                                                                                |
| `upload_to_wandb` | bool | `true`   | Keep uploading to W\&B. Set to `false` where W\&B is not reachable: W\&B then runs in offline mode and only SwanLab receives the run.                |

### SwanLab Only

Where W\&B is not reachable, keep the `wandb` block (it drives the logging calls) and stop the W\&B upload:

```yaml
wandb:
  project: my-project
  swanlab:
    mode: online
    upload_to_wandb: false
```

### Offline Clusters

On a cluster without internet access, write the run locally and upload it later from a machine that can reach SwanLab:

```yaml
wandb:
  project: my-project
  swanlab:
    mode: offline
    upload_to_wandb: false
    log_dir: /path/to/swanlog
```

```bash
swanlab sync /path/to/swanlog/run-<id>
```

## Notes

* Numbers, strings, and images are mirrored. String values (for example the per-step `timestamp`) appear in SwanLab as text. Other W\&B types such as `wandb.Table` and histograms are not mirrored.
* When a recipe logs the same key twice at one step (for example a training and a validation record at the same step), W\&B keeps the last value and SwanLab keeps the first.
* A resumed W\&B run (`id` / `resume` in the `wandb` block) starts a new SwanLab run.
* With `upload_to_wandb: false`, W\&B always runs in `offline` mode, even if the `wandb` block sets another `mode`.
* The mirror is installed once per process; a second recipe in the same process keeps the first run's SwanLab settings.