Skip to content

Commit 096b063

Browse files
ash0tsawaelchli
andauthored
Add docs for the Fabric WandbLogger hosted in the wandb SDK (#19451)
Co-authored-by: awaelchli <[email protected]>
1 parent d58c28c commit 096b063

File tree

4 files changed

+139
-1
lines changed

4 files changed

+139
-1
lines changed

docs/source-fabric/api/loggers.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,14 @@ Loggers
1818
Logger
1919
CSVLogger
2020
TensorBoardLogger
21+
22+
23+
Third-party Loggers
24+
^^^^^^^^^^^^^^^^^^^
25+
26+
.. list-table::
27+
:widths: 50 50
28+
:header-rows: 0
29+
30+
* - :doc:`WandbLogger <../guide/loggers/wandb>`
31+
- Log to `Weights & Biases <https://www.wandb.ai/>`_.

docs/source-fabric/glossary/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Glossary
77
:hidden:
88

99
Checkpoint <../guide/checkpoint/index>
10+
Weights and Biases <../guide/loggers/wandb>
1011

1112

1213
.. raw:: html
@@ -204,6 +205,11 @@ Glossary
204205
:button_link: ../guide/trainer_template.html
205206
:col_css: col-md-4
206207

208+
.. displayitem::
209+
:header: Weights and Biases
210+
:button_link: ../guide/loggers/wandb.html
211+
:col_css: col-md-4
212+
207213
.. displayitem::
208214
:header: 16-bit, 8-bit, 4-bit
209215
:button_link: ../fundamentals/precision.html
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
##################
2+
Weights and Biases
3+
##################
4+
5+
`Weights & Biases (W&B) <https://wandb.ai>`_ allows machine learning practitioners to track experiments, visualize data, and share insights with a few lines of code.
6+
7+
It integrates seamlessly with your Lightning ML workflows to log metrics, output visualizations, and manage artifacts.
8+
This integration provides a simple way to log metrics and artifacts from your Fabric training loop to W&B via the ``WandbLogger``.
9+
The ``WandbLogger`` also supports all features of the Weights and Biases library, such as logging rich media (image, audio, video), artifacts, hyperparameters, tables, custom visualizations, and more.
10+
`Check the official documentation here <https://docs.wandb.ai>`_.
11+
12+
13+
----
14+
15+
16+
*************************
17+
Set Up Weights and Biases
18+
*************************
19+
20+
First, you need to install the ``wandb`` package:
21+
22+
.. code-block:: bash
23+
24+
pip install wandb
25+
26+
Then log in with your API key found in your W&B account settings:
27+
28+
.. code-block:: bash
29+
30+
wandb login <your-api-key>
31+
32+
33+
You are all set and can start logging your metrics to Weights and Biases.
34+
35+
36+
----
37+
38+
39+
*************
40+
Track metrics
41+
*************
42+
43+
To start tracking metrics in your training loop, import the WandbLogger and configure it with your settings:
44+
45+
.. code-block:: python
46+
47+
from lightning.fabric import Fabric
48+
49+
# 1. Import the WandbLogger
50+
from wandb.integration.lightning.fabric import WandbLogger
51+
52+
# 2. Configure the logger
53+
logger = WandbLogger(project="my-project")
54+
55+
# 3. Pass it to Fabric
56+
fabric = Fabric(loggers=logger)
57+
58+
59+
Next, add :meth:`~lightning.fabric.fabric.Fabric.log` calls in your code.
60+
61+
.. code-block:: python
62+
63+
value = ... # Python scalar or tensor scalar
64+
fabric.log("some_value", value)
65+
66+
67+
To log multiple metrics at once, use :meth:`~lightning.fabric.fabric.Fabric.log_dict`:
68+
69+
.. code-block:: python
70+
71+
values = {"loss": loss, "acc": acc, "other": other}
72+
fabric.log_dict(values)
73+
74+
75+
----
76+
77+
78+
**************************************************
79+
Logging media, artifacts, hyperparameters and more
80+
**************************************************
81+
82+
With ``WandbLogger`` you can also log images, text, tables, checkpoints, hyperparameters and more.
83+
For a description of all features, check out the official Weights and Biases documentation and examples.
84+
85+
86+
.. raw:: html
87+
88+
<div class="display-card-container">
89+
<div class="row">
90+
91+
.. displayitem::
92+
:header: Official WandbLogger Lightning and Fabric Documentation
93+
:description: Learn about all features from Weights and Biases
94+
:button_link: https://docs.wandb.ai/guides/integrations/lightning
95+
:col_css: col-md-4
96+
:height: 150
97+
98+
.. displayitem::
99+
:header: Fabric WandbLogger Example
100+
:description: Official example of how to use the WandbLogger with Fabric
101+
:button_link: https://colab.research.google.com/github/wandb/examples/blob/master/colabs/pytorch-lightning/Track_PyTorch_Lightning_with_Fabric_and_Wandb.ipynb
102+
:col_css: col-md-4
103+
:height: 150
104+
105+
.. displayitem::
106+
:header: Lightning WandbLogger Example
107+
:description: Official example of how to use the WandbLogger with Lightning
108+
:button_link: wandb.me/lightning
109+
:col_css: col-md-4
110+
:height: 150
111+
112+
113+
.. raw:: html
114+
115+
</div>
116+
</div>
117+
118+
119+
|
120+
|

docs/source-fabric/guide/logging.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ To track a metric, add the following:
3232
fabric = Fabric(loggers=logger)
3333
3434
35-
Built-in loggers you can choose from:
35+
Loggers you can choose from:
3636

3737
- :class:`~lightning.fabric.loggers.TensorBoardLogger`
3838
- :class:`~lightning.fabric.loggers.CSVLogger`
39+
- :doc:`WandbLogger <loggers/wandb>`
3940

4041
|
4142

0 commit comments

Comments
 (0)