Rewind a run

巻き戻し

run の巻き戻し

run を巻き戻して、元のデータを失うことなく、run の履歴を修正または変更します。さらに、run を巻き戻すと、その時点から新しいデータを記録できます。W&B は、新たに記録された履歴に基づいて、巻き戻した run のサマリーメトリクスを再計算します。これは、次の振る舞いを意味します。

  • 履歴の切り捨て: W&B は履歴を巻き戻しポイントまで切り捨て、新しいデータロギングを可能にします。
  • サマリーメトリクス: 新たに記録された履歴に基づいて再計算されます。
  • 設定の保持: W&B は元の設定を保持し、新しい設定をマージできます。

run を巻き戻すと、W&B は run の状態を指定されたステップにリセットし、元のデータを保持し、一貫した run ID を維持します。これは次のことを意味します。

  • run のアーカイブ: W&B は元の run をアーカイブします。アーカイブされた run は、Run Overview タブからアクセスできます。
  • Artifact の関連付け: Artifact をそれを生成する run に関連付けます。
  • 不変の run ID: 正確な状態からのフォークの一貫性のために導入されました。
  • 不変の run ID のコピー: run 管理を改善するために、不変の run ID をコピーするボタン。

run の巻き戻し

resume_from を使用して wandb.init() を使用して、run の履歴を特定のステップに「巻き戻し」ます。巻き戻す run の名前とステップを指定します。

import wandb
import math

# Initialize the first run and log some metrics
# Replace with your_project_name and your_entity_name!
run1 = wandb.init(project="your_project_name", entity="your_entity_name")
for i in range(300):
    run1.log({"metric": i})
run1.finish()

# Rewind from the first run at a specific step and log the metric starting from step 200
run2 = wandb.init(project="your_project_name", entity="your_entity_name", resume_from=f"{run1.id}?_step=200")

# Continue logging in the new run
# For the first few steps, log the metric as is from run1
# After step 250, start logging the spikey pattern
for i in range(200, 300):
    if i < 250:
        run2.log({"metric": i, "step": i})  # Continue logging from run1 without spikes
    else:
        # Introduce the spikey behavior starting from step 250
        subtle_spike = i + (2 * math.sin(i / 3.0))  # Apply a subtle spikey pattern
        run2.log({"metric": subtle_spike, "step": i})
    # Additionally log the new metric at all steps
    run2.log({"additional_metric": i * 1.1, "step": i})
run2.finish()

アーカイブされた run の表示

run を巻き戻した後、W&B App UI でアーカイブされた run を調べることができます。アーカイブされた run を表示するには、次の手順に従います。

  1. Overview タブにアクセスする: run のページの Overview タブ に移動します。このタブには、run の詳細と履歴の包括的なビューが表示されます。
  2. Forked From フィールドを見つける: Overview タブ内で、Forked From フィールドを見つけます。このフィールドは、再開の履歴をキャプチャします。Forked From フィールドには、ソース run へのリンクが含まれており、元の run にトレースバックして、巻き戻し履歴全体を理解できます。

Forked From フィールドを使用すると、アーカイブされた再開の ツリー を簡単にナビゲートし、各巻き戻しのシーケンスとオリジンに関する洞察を得ることができます。

巻き戻した run からフォークする

巻き戻した run からフォークするには、wandb.init()fork_from 引数を使用し、ソース run ID と、フォーク元のソース run からのステップを指定します。

import wandb

# Fork the run from a specific step
forked_run = wandb.init(
    project="your_project_name",
    entity="your_entity_name",
    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()