You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use job api for WandB example.
Fix WandBReceiver bug.
### Description
Use job api for WandB example.
Fix WandBReceiver bug.
### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Quick tests passed locally by running `./runtest.sh`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated.
---------
Co-authored-by: Chester Chen <[email protected]>
Copy file name to clipboardExpand all lines: examples/advanced/experiment-tracking/wandb/README.md
+30-26Lines changed: 30 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,19 +8,14 @@ This example also highlights the Weights and Biases streaming capability from th
8
8
9
9
> **_NOTE:_** This example uses the [CIFAR-10](https://www.cs.toronto.edu/~kriz/cifar.html) dataset and will load its data within the trainer code.
10
10
11
-
### 1. Install requirements and configure PYTHONPATH
11
+
### 1. Install requirements
12
12
13
13
Install additional requirements (if you already have a specific version of nvflare installed in your environment, you may want to remove nvflare in the requirements to avoid reinstalling nvflare):
14
14
15
15
```
16
16
python -m pip install -r requirements.txt
17
17
```
18
18
19
-
Set `PYTHONPATH` to include custom files of this example:
20
-
```
21
-
export PYTHONPATH=${PWD}/..
22
-
```
23
-
24
19
### 2. Make sure the FL server is logged into Weights and Biases
25
20
26
21
Import the W&B Python SDK and log in:
@@ -35,42 +30,51 @@ Provide your API key when prompted.
By default, Weights and Biases will create a directory named "wandb" in the server workspace. With "mode": "online" in the WandBReceiver, the
47
42
files will be synced with the Weights and Biases server. You can visit https://wandb.ai/ and log in to see your run data.
48
43
49
-
### 4. Weights and Biases tracking
44
+
### 5. How it works
50
45
51
-
For the job `hello-pt-wandb`, on the client side, the client code in `PTLearner` uses the syntax for Weights and Biases:
46
+
To enable tracking with Weights & Biases (WandB), you can use the `WandBWriter` utility provided by NVFlare. Here's a basic example of how to integrate it into your training script:
The `WandBWriter` mimics the syntax from Weights and Biases to send the information in events to the server through NVFlare events
60
-
of type `analytix_log_stats` for the server to write the data for the WandB tracking server.
56
+
The `WandBWriter` follows a syntax similar to the native WandB API, making it easy to adopt.
57
+
58
+
Internally, `WandBWriter` leverages the NVFlare client API to send metrics and trigger an `analytix_log_stats` event. This event can be received and processed by our `AnalyticsReceiver`, with the `WandBReceiver` being one implementation of it.
61
59
62
-
The `ConvertToFedEvent` widget turns the event `analytix_log_stats` into a fed event `fed.analytix_log_stats`,
63
-
which will be delivered to the server side.
60
+
In `wandb_job.py`, we configure the following components by default:
64
61
65
-
On the server side, the `WandBReceiver` is configured to process `fed.analytix_log_stats` events,
66
-
which writes received data from these events.
62
+
- The `ConvertToFedEvent` widget on the NVFlare client side, which transfroms the event `analytix_log_stats` into a fed event `fed.analytix_log_stats`. This enables the event to be sent from the NVFlare client to the NVFlare server.
67
63
68
-
This allows for the server to be the only party that needs to deal with authentication for the WandB tracking server, and the server
69
-
can buffer the events from many clients to better manage the load of requests to the tracking server.
64
+
- The `WandBReceiver` on the NVFlare server side, which listens for `fed.analytix_log_stats` events and forwards the metric data to the WandB tracking server.
70
65
71
-
### 5. Sends to WandB server directly from client side
66
+
This setup ensures that the server handles all authentication with the WandB tracking server and buffers events from multiple clients, effectively managing the load of requests to the server.
67
+
68
+
### 6. Optional: Stream Metrics Directly from Clients
69
+
70
+
Alternatively, you can stream metrics **directly from each NVFlare client** to WandB, bypassing the NVFlare server entirely.
71
+
72
+
To enable this mode, run your training script with the following flags:
0 commit comments