Run forking is in Public Preview for Multi-tenant Cloud and Dedicated Cloud. It is not currently available for Self-Managed deployments.Public Preview features are available for production evaluation, but functionality, APIs, and behavior are in active development and may change before General Availability.
- Forking a run requires
wandbSDK version 0.16.5 or later. - Forking a run requires monotonically increasing steps. You can’t fork from a run that uses non-monotonic steps defined with
define_metric(). Non-monotonic steps break the chronological order of run history and system metrics.
fork_from in wandb.init().
The following sections describe two common ways to fork a run: fork from a run that already exists in W&B, and fork from a run that you create in the same script.
Fork from a previously logged run
Use this approach when the source run already exists in W&B (for example, a completed training run whose ID you can look up in the W&B App). The following code snippet shows how to fork from a run that you previously logged to W&B. First, obtain the run ID of the run you want to fork from. Next, specify the run ID and the step you want to fork from as arguments tofork_from in wandb.init().
Copy and paste the following code into a Python script or notebook cell. Replace [SOURCE-RUN-ID], [PROJECT], and [ENTITY] with your own values.
Fork from a run in the same script
Use this approach when you want to fork from a run that you just created without looking up the run ID in the W&B App. The following code snippet shows how to create a run and fork from that run within the same script. First, initialize a run and log some data. Next, use the original run object’sid property to obtain the run ID of that run. Finally, initialize a new run and pass the original run’s ID and the step you want to fork from as arguments to fork_from in wandb.init().
Example script
The following end-to-end example shows how to first fork a run and then log metrics to the forked run starting from a training step of 200. It demonstrates a full workflow that you can run as-is to see forking in action. Copy and paste the following code into a Python script or notebook cell. Replace[PROJECT] and [ENTITY] with your own values.
run1) with the full training history, and the forked run (run2) that branches from step 200 and logs its own diverging metrics from there.
Rewind and forking compatibilityForking complements a rewind by providing more flexibility to manage and experiment with your runs.When you fork from a run, W&B creates a new branch off a run at a specific point so you can try different parameters or models.When you rewind a run, you can correct or modify the run history itself.