You can explore different hyperparameters or models from a specific point in an experiment without impacting the original run. To do this, fork from an existing W&B run. When you fork from a run, W&B creates a new run using the source run’s unique ID and a specified step. Summary metrics from the source run are copied to the forked run. The forked run shares all history and files from the source run up to the specified step. After the fork step, you can log new data to the forked run independently of the original run. View a live demo of a forked run produced by the code below.Documentation Index
Fetch the complete documentation index at: https://wb-21fd5541-john-wbdocs-2044-rename-serverless-products.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
- Forking a run requires
wandbSDK version >= 0.16.5 - Forking a run requires monotonically increasing steps. You cannot 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.
run ID and the step you want to start the forked run from as arguments to fork_from in wandb.init().
Fork from a previously logged run
The following code snippet shows how to fork from a run that was 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
The following code snippet shows how to create a run and fork from that run within the same script. This might occur if you want to fork from a run that you just created without having to look up the run ID in the W&B App. 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
For example, the following code example shows how to first fork a run and then how to log metrics to the forked run starting from a training step of 200. Copy and paste the following code into a Python script or notebook cell. Replace<project> and <entity> with your own values.
Rewind and forking compatibilityForking complements a
rewind by providing more flexibility in managing and experimenting with your runs.When you fork from a run, W&B creates a new branch off a run at a specific point to try different parameters or models.When you rewind a run, W&B lets you correct or modify the run history itself.