Skip to main content
Rewind a run to modify the history of a run. When you rewind a run, W&B resets the state of the run to the specified step while maintaining the same run ID.
The option to rewind a run is in private preview and in active development. Due to known performance limitations with Rewind, W&B typically recommends Forking as an alternative.W&B currently does not support:
  • Log rewind: Logs are reset in the new run segment.
  • System metrics rewind: W&B logs only new system metrics after the rewind point.
  • Artifact association: W&B associates artifacts with the source run that produces them.
Contact W&B Support at support@wandb.com to request access to this feature.
W&B recomputes the summary metrics for the run you rewind based on the newly logged history. This means the following behavior:
  • History truncation: W&B truncates the history to the rewind point, allowing new data logging.
  • Summary metrics: Recomputed based on the newly logged history.
  • Configuration preservation: W&B preserves the original configurations and you can merge new configurations.
Rewind and forking compatibilityForking complements a rewind.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.

Prerequisites

Before you rewind a run, ensure you meet the following prerequisites:
  • To rewind a run, you must have W&B Python SDK version >= 0.17.1.
  • You must use monotonically increasing steps. This does not work with non-monotonic steps defined with define_metric() because it disrupts the required chronological order of run history and system metrics.

Rewind a run

Rewind a run from a specific step and log new data from that point in time. Pass both the run ID and the step you want to rewind from as arguments to the resume_from parameter in wandb.init(). The resume_from parameter accepts a string in the format of <run ID>?_step=<step>, where <run ID> is the run ID of the run you want to rewind and <step> is the step you want to rewind from. Suppose you log a linear line for 300 steps:
import wandb

# Initialize the first run and log some metrics
with wandb.init(project="<project>", entity="wandb") as run:
    for i in range(300):
        # Plot a linear line
        run.log({"metric": i, "step": i})
Within your project’s workspace, you see a line plot from step 0 to step 300: Line plot of the original run At a later time, you want to rewind the run from step 200 and you want to log a new metric called additional_metric that logs i*1.1 from step 200 to step 300. From step 250 you want to log a new subtle wavy pattern (i**2 + 2*sin(i/3)) instead of a linear line:
import math

run_ID = "<run_ID>" # Replace with the run ID of the run you want to rewind

# Rewind from the first run at a specific step and log the metric starting from step 200
with wandb.init(project="<project>", entity="wandb", resume_from=f"{run_ID}?_step=200") as run:

    # For the first few steps, log the metric as is from run
    # After step 250, start logging the wavy pattern
    for i in range(200, 300):
        if i < 250:
            run.log({"metric": i, "step": i})  # Continue logging from run without waves
        else:
            # Introduce the wavy behavior starting from step 250
            subtle_wave = i + (2 * math.sin(i / 3.0))  # Apply a subtle wavy pattern
            run.log({"metric": subtle_wave, "step": i})
        # Additionally log the new metric at all steps
        run.log({"additional_metric": i * 1.1, "step": i})
The following image shows the updated project’s workpace. Note the following changes in the plot after the rewind:
  • The line plot shows the original linear line from step 0 to step 200 and the new subtle wavy pattern starts from step 250 (left image).
  • W&B created a new plot (right plot) labeled additional_metric that starts from step 200.
From left to right: original linear line and additional metric

View an archived run

After you rewind a run, you can explore the original archived run in the W&B App. Follow these steps to view an archived run:
  1. Access the Overview Tab: Navigate to the Overview tab on the run’s page. This tab provides a comprehensive view of the run’s details and history.
  2. Locate the Forked From field: Within the Overview tab, find the Forked From field. This field captures the history of the resumptions. The Forked From field includes a link to the source run, allowing you to trace back to the original run and understand the entire rewind history.
By using the Forked From field, you can effortlessly navigate the tree of archived resumptions and gain insights into the sequence and origin of each rewind.

Fork from a run that you rewind

To fork from a rewound run, use the fork_from argument in wandb.init() and specify the source run ID and the step from the source run to fork from:
import wandb

# Fork the run from a specific step
forked_run = wandb.init(
    project="<project>",
    entity="<entity>",
    fork_from=f"{rewind_run.id}?_step=500",
)

# Continue logging in the new run
for i in range(500, 1000):
    forked_run.log({"metric": i*3})
forked_run.finish()