Frameworks and notebooks¶
NuBoard plugs into PyTorch Lightning, the Hugging Face Trainer and Jupyter
without adding a dependency. Each integration lives in its own module and uses
the framework your script already has; import nuboard never imports one.
PyTorch Lightning¶
import lightning as L
from nuboard.integrations.lightning import NuBoardLogger
logger = NuBoardLogger("mnist", run_name="baseline", tags=["cnn"])
trainer = L.Trainer(max_epochs=10, logger=logger)
trainer.fit(model, datamodule)
trainer.test(model, datamodule)
- Every
self.log(...)becomes a scalar at the trainer's global step. self.save_hyperparameters()goes into the run's config, together withconfig=if you pass one.- Only global rank 0 creates and writes the run, so the same logger works with any strategy (DDP, FSDP, ...).
- The run is finished when
fit,validateortestends:finishedon success,crashedon an exception. Using the trainer again (atestafter afit) resumes the same run as a new session, so one run holds the training and the test scores. - For images, figures, audio and text, log on the run itself:
self.logger.experimentis thenb.Run.
def validation_step(self, batch, i):
...
if i == 0:
self.logger.experiment.add_image("val/samples", grid, step=self.global_step)
log_model=True records the best checkpoint of your ModelCheckpoint (the
last one without a monitored metric) as a "checkpoint" artifact version named
model (model_name= to change it) when the run ends, with the monitored
metric and score in its metadata. Checkpoints themselves stay where Lightning
writes them, under default_root_dir.
Every other keyword goes to nb.init, such as group,
notes, dir, run_id and resume. To log into a run you opened yourself,
pass run=: the logger then never finishes it. Both lightning and the older
pytorch_lightning package work.
Hugging Face Trainer¶
from transformers import Trainer, TrainingArguments
from nuboard.integrations.huggingface import NuBoardCallback
args = TrainingArguments("out", report_to="none", logging_steps=20, eval_strategy="epoch")
trainer = Trainer(model, args, train_dataset=train, eval_dataset=val,
callbacks=[NuBoardCallback("glue-mrpc")])
trainer.train()
trainer.evaluate()
- Whatever the trainer logs becomes a scalar at its global step: keys that
start with
eval_go undereval/(eval/loss),test_undertest/, and the rest undertrain/(train/loss,train/learning_rate,train/grad_norm). - The
TrainingArgumentsare the run's config (tokens masked, as the trainer does), with the model's config undermodel. - Only the main process writes.
- The run starts with
train()and is finished when training ends.trainer.evaluate()afterwards resumes the same run as a new session; in a notebook, callcallback.finish()when you are done with it. - In
trainer.hyperparameter_search, each trial is a run of its own, with the trial's parameters undertrialin its config. run_name=names the run; without it,TrainingArguments.run_nameis used when you set one.
Set report_to="none" (or leave "tensorboard" out of the list) so the
trainer does not add its own loggers as well. log_model=True records the
best checkpoint folder (or the newest checkpoint-<step>) as a "checkpoint"
artifact when training ends. The callback does not need transformers to be
imported to work, and ignores events it does not use, including ones newer
versions add.
Jupyter¶

Runs and projects show a summary when they end a cell:
import nuboard as nb
run = nb.init("mnist", config={"lr": 3e-4})
run # name, status, folder, config and the last value of each scalar
nb.load("mnist") # the newest runs of the project
nb.load("mnist").run(run.id) # one run read from disk
nb.show() opens the viewer inside the notebook:
nb.show(run) # this run's charts, updating as it trains
nb.show("mnist") # the project's runs
nb.show() # every project in $NUBOARD_DIR (or ./experiments)
nb.show(run, page="media", height=900)
The first call starts the viewer on a free port of this computer, on a
background thread of the kernel, and later calls for the same folder reuse it.
The returned object shows the viewer in the cell, has the address in .url
(the frame also links to it, to open in a tab) and stops the viewer with
.stop(). The viewer needs nothing beyond pip install nuboard.
The viewer listens on 127.0.0.1 only, so the browser showing the notebook
must reach that address: Jupyter and JupyterLab on your computer and VS Code
(which forwards the port of a remote kernel) work as they are. For a kernel on
another machine, forward the port with ssh -L and open .url in a tab, as in
Sharing from a cloud machine. Hosted notebooks that serve their
pages from another site, such as Colab, are not supported yet.
A normal viewer refuses to be shown inside another site's page. The one
nb.show starts allows it for pages on localhost and 127.0.0.1 (any port)
and VS Code; frame_ancestors=["https://notebooks.example.com"] adds another
notebook server.