Guide for checkpointing — saving, loading, and resuming training with CheckpointRecord. Use when the user asks about saving weights, resuming training, checkpoint management, or the checkpoint lifecycle.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for training outputs, metrics logging, logtree reports, tracing/profiling, and debugging training runs. Use when the user asks about training logs, metrics, debugging, tracing, profiling, timing, Gantt charts, or understanding training output files.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Every training run writes structured outputs to log_path. This skill covers what's produced and how to use it.
docs/rl/rl-logging.mdx — Complete file reference for RL training outputstinker_cookbook/utils/ml_log.py — Metrics logging APItinker_cookbook/utils/logtree.py — Logtree (structured rollout transcripts)tinker_cookbook/utils/trace.py — Tracing/profiling (@scope, trace_iteration, Gantt charts)Each training run writes to its log_path directory:
| File | Format | Contents |
|---|---|---|
metrics.jsonl | JSONL | Scalar metrics per training iteration |
config.json | JSON | Full serialized training config (reproducibility) |
checkpoints.jsonl | JSONL | Checkpoint metadata (paths, loop state for resume) |
code.diff | text | Git diff at training start |
train_iteration_NNNNNN.html | HTML | Human-readable logtree report |
train_iteration_NNNNNN_logtree.json | JSON | Machine-readable rollout transcripts |
train_iteration_NNNNNN_rollout_summaries.jsonl | JSONL | Per-trajectory rewards and metrics |
eval_<name>_iteration_NNNNNN.* | mixed | Same formats for eval rollouts |
timing_spans.jsonl | JSONL | Per-iteration span timing data (from trace_iteration) |
trace_events.jsonl | JSONL | Perfetto/Chrome Trace format events (from trace_init) |
gantt_NNNNNN.html | HTML | Plotly Gantt chart of span timeline (optional) |
Iteration numbers are zero-padded to 6 digits.
import pandas as pd
df = pd.read_json("path/to/log_path/metrics.jsonl", lines=True)
df.plot(x="progress/batch", y="env/all/reward/total")
Progress:
progress/batch — iteration indexprogress/done_frac — completion fractionRL rewards:
env/all/reward/total — mean total rewardenv/all/<metric> — env-emitted metrics (e.g., correct, format_parse)Training health:
entropy — per-token entropykl_sample_train_v1, kl_sample_train_v2 — KL divergence (should stay < 0.01)optim/lr — current learning rateac_tokens_per_turn — mean generated tokens per turnTiming (from trace_iteration):
time/total — iteration wall-clock durationtime/<name> — single-call duration (e.g., time/train_step)time/<name>:total, time/<name>:count, time/<name>:mean, time/<name>:max — aggregates for functions called multiple times (e.g., time/sample_async:total)import json
with open("train_iteration_000010_rollout_summaries.jsonl") as f:
trajectories = [json.loads(line) for line in f]
for traj in trajectories:
print(f"reward={traj['total_reward']:.2f}, metrics={traj['trajectory_metrics']}")
# Each trajectory has: total_reward, final_reward, trajectory_metrics,
# steps (list of {ob_len, ac_len, reward, episode_done, metrics})
Contains full text of prompts, model responses, grading details. Walk the tree recursively looking for nodes with data.type == "conversation" to extract conversations. See docs/rl/rl-logging.mdx for the full schema.
Open train_iteration_NNNNNN.html in a browser for a human-readable view of rollouts with collapsible sections. num_groups_to_log (default: 4) controls how many trajectory groups get detailed logging.
from tinker_cookbook.utils import ml_log
# Set up logging (done once in training scripts)
ml_logger = ml_log.setup_logging(log_path="/tmp/my_run", wandb_project=None, wandb_name=None)
# Log scalar metrics
ml_logger.log_metrics({"train/loss": 0.5, "eval/accuracy": 0.85}, step=100)
from tinker_cookbook.utils import logtree
with logtree.scope_header("my_section"):
# Nested logging of rollouts, grading, etc.
...
Pass wandb_project and wandb_name in your config to enable W&B logging:
config = train.Config(
wandb_project="my-project",
wandb_name="my-experiment",
...
)
The tinker_cookbook/utils/trace module provides per-iteration profiling across all training modules (RL, SL, DPO, distillation).
from tinker_cookbook.utils import trace
# Initialize Perfetto trace collector (optional — writes trace_events.jsonl)
trace.trace_init()
# In training loop — collect per-iteration timing
for i_batch in range(n_batches):
with trace.trace_iteration(step=i_batch) as window:
# All @scope-decorated calls are automatically recorded
await gather_rollouts(...)
await train_step(...)
# Get timing metrics for this iteration
metrics.update(window.get_timing_metrics())
# Persist span data for post-hoc analysis
window.write_spans_jsonl(log_path / "timing_spans.jsonl", step=i_batch)
# Optional: Gantt chart visualization (requires plotly)
trace.save_gantt_chart_html(window, i_batch, log_path / f"gantt_{i_batch}.html")
from tinker_cookbook.utils import trace
# Decorator — automatically traces function calls
@trace.scope
async def my_training_step(tc, batch):
result = await tc.forward_backward_async(data=batch, loss_fn="cross_entropy")
return result
# Inline span — for timing a code block without a dedicated function
async with trace.scope_span("data_prep"):
batch = prepare_next_batch(...)
# Sync variant
with trace.scope_span_sync("data_prep"):
batch = prepare_next_batch(...)
@scope and scope_span are no-ops when called outside trace_iteration — safe to leave in production.
# Convert JSONL to JSON for visualization
uv run python -m tinker_cookbook.utils.trace trace_events.jsonl trace.json
# Open trace.json in chrome://tracing or https://ui.perfetto.dev/
metrics.jsonl — is loss decreasing? Are rewards increasing?batch_size, group_size, or max_tokensbatch_size, group_size, and max_stepsmetrics.jsonl into a DataFrame and overlay plotsまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Guide for checkpointing — saving, loading, and resuming training with CheckpointRecord. Use when the user asks about saving weights, resuming training, checkpoint management, or the checkpoint lifecycle.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for testing conventions and CI pipelines — unit tests, integration smoke tests, pytest markers, and GitHub Actions workflows. Use when the user asks about testing, CI, running tests, or adding tests for a recipe.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for using completers — TokenCompleter and MessageCompleter for text generation during RL rollouts and evaluation. Use when the user asks about generating text, completing messages, or using completers in RL environments.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for contributing to the tinker-cookbook repo — development setup, code style, type checking, PR process, and design conventions. Use when the user asks about how to contribute, set up the dev environment, code style, or project conventions.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for dataset construction — SupervisedDatasetBuilder, RLDatasetBuilder, ChatDatasetBuilder, and custom dataset creation from JSONL, HuggingFace, or conversation data. Use when the user asks about datasets, data loading, data preparation, or custom data formats.
日本語の概要は準備中です。原文の説明を表示しています。
Set up and run knowledge distillation (on-policy, off-policy, or multi-teacher) from a teacher model to a student model using the Tinker API. Use when the user wants to distill knowledge, compress models, or train a student from a teacher.
日本語の概要は準備中です。原文の説明を表示しています。