Skip to main content
App version: 3.4.12

Fork an experiment

Forking refers to creating a run based on an existing experiment run. This way, you can restart a run at a particular step.

To fork an experiment, create a run and specify the parent run and step to fork from:

from neptune_scale import Run


run = Run(
experiment_name="swim-further",
fork_run_id="likable-barracuda", # parent run ID
fork_step=100,
)

To get a link to the experiment in the Neptune web app:

run = Run(experiment_name=...)
run.get_experiment_url()

For details, see Construct Neptune URLs.

Forking and inheritance

The new run inherits all metrics up to and including the fork point specified by the fork_step argument.

A child run inherits the following metadata from its parent:

MetadataAttribute type or pathHow you log it
MetricsFloatSeries attributesrun.log_metrics=(...)
TagsStringSetrun.add_tags(tags=...) or via tags management in the app
Descriptionsys/descriptionrun.log_configs(data={"sys/description": "..."}) or in the app

Configs and other single values logged with log_configs() aren't inherited automatically.

When the child run continues logging values to metrics, points logged at or after the fork step become part of the experiment lineage:

run = Run(
...,
fork_step: 100,
)

for step in epoch:
# your training loop
run.log_metrics(
data={"loss": 0.11, "acc": 0.81},
step=101, # also OK: 100 or 100.1
)

Logging points before the fork step

For an inherited series, a child run can log points for pre-fork steps, as long as they come after the parent's last logged step:

ParentMaxStep < ChildStep ≤ ForkStep
→ OK

ChildStep ≤ ParentMaxStep ≤ ForkStep
→ Error

When viewing the child run's metrics and the mode in the table toolbar is set to Runs:

  • Show inherited metrics enabled: Points inherited from the parent are displayed for steps before the fork point, otherwise points logged directly by the child run are displayed.
  • Show inherited metrics disabled: Only points directly logged by the child run itself are displayed.

If a series attribute doesn't exist in the parent run, the child run can log points starting from any step:

run = Run(
...,
fork_step: 100,
)

for step in some_range:
run.log_metrics(
data={"new_metric": 0.123}, # "new_metric" doesn't exist in the parent run
step=1, # OK
)

Such points are passed on to further descendant runs.