tinker_cookbook.rl.Config
Generated from tinker-cookbook at commit 8bf7dd6. Source links point at that snapshot.
class tinker_cookbook.rl.Config()
Configuration for RL training.
This is the main configuration object for main. It controls the
model, dataset, optimizer, loss function, KL penalty, evaluation cadence,
checkpointing, logging, and execution mode (sync, async, or streaming
minibatch).
All fields use chz dataclass semantics and can be overridden via CLI
or YAML configuration files.
Fields:
- learning_rate (float) – Base learning rate used by Adam.
- dataset_builder (RLDatasetBuilder) – Builds the RL dataset; also determines number of groups per batch.
- model_name (str) – Model name (base weights) to train.
- recipe_name (str) – training/sampling calls inherit it.
- max_tokens (int) – Maximum number of generated tokens per rollout trajectory.
- log_path (str) – Directory for checkpoints, logs, and traces.
- eval_every (int, default:
20) – Evaluation cadence in training iterations (0 = disabled). - save_every (int, default:
20) – Checkpoint cadence in training iterations (0 = disabled). - evaluator_builders (list[SamplingClientEvaluatorBuilder], default:
[]) – Optional evaluators run during training. - load_checkpoint_path (str | None, default:
None) – Start training from weights at this checkpoint (fresh optimizer state). - renderer_name (str | None, default:
None) – Renderer used by the training dataset/environment. - wandb_project (str | None, default:
None) – Optional W&B project and run name. - wandb_name (str | None, default:
None) - session_name (str | None, default:
None) – Display name for the Tinker session; defaults to wandb_name when set. - kl_penalty_coef (float, default:
0.0) – KL penalty coefficient against reference policy (0 = disabled). - kl_discount_factor (float, default:
0.0) – Optional position discount for KL penalty terms. - kl_reference_config (KLReferenceConfig | None, default:
None) – Required when kl_penalty_coef > 0. - loss_fn (LossFnType, default:
'importance_sampling') – Async runs use AsyncConfig.loss_fn (default "stable_reinforce") instead. - loss_fn_config (dict[str, Any] | None, default:
None) - num_substeps (int, default:
1) – Useful for very large batch sizes. - lora_rank (int, default:
32) – LoRA rank for the training adapter. - temperature (float, default:
1.0) – well with KL penalty. - compute_post_kl (bool, default:
False) – Compute extra post-update KL metrics (adds overhead). - remove_constant_reward_groups (bool, default:
False) – Remove groups where all trajectories have identical reward. - rollout_error_tolerance (bool | RolloutStrategy | None, default:
None) – RolloutStrategy instance: custom strategy (e.g. RetryOnFailure(max_retries=5)). - termination (TerminationRewardPolicy | None, default:
None) – envs are built (e.g. build_agent_tool_env(rollout_config=...)). - enable_trace (bool, default:
False) – Emit async trace events for debugging/profiling. - span_chart_every (int, default:
0) – Save a Gantt chart HTML every N iterations (0 = disabled). Requires plotly. - async_config (AsyncConfig | None, default:
None) – Enable async/off-policy training mode when set. - stream_minibatch_config (StreamMinibatchConfig | None, default:
None) – Enable sync training with streaming minibatches when set. - base_url (str | None, default:
None) – Optional service base URL override (primarily internal/dev use). - ttl_seconds (int | None, default:
604800) – 7 days - rolling_save_every (int, default:
0) – but skips the sampler-weight export, making it cheaper than periodic checkpoints. - rolling_ttl_seconds (int, default:
7200) – 2 hours - num_groups_to_log (int, default:
4) – Number of groups to log per iteration (0 = disable logging) - rollout_json_export (bool, default:
True) - num_epochs (int, default:
1) – global step across epochs. - max_steps (int | None, default:
None) – max_steps alone stops early, with a warning at startup).
training_loss_fn()
The loss this run trains with: async_config.loss_fn for async runs,
loss_fn otherwise.
Returns: LossFnType
records_stability_info()
Whether sampling must record the information StableReinforce trains on.
Returns: bool
sampling_client_kind()
The kind of sampling client each training step publishes for rollouts:
"inflight" for async runs with inflight_weight_updates whose
sampling_steps_ahead is above 0, "snapshot"
otherwise. With an on-policy buffer no rollout runs during a train
step, so inflight clients would only add sampler saves.
Returns: SamplingClientKind
async_groups_per_step()
Trajectory groups an async run trains per step:
stream_minibatch_config.groups_per_batch with streaming minibatches,
async_config.groups_per_batch otherwise.
Returns: int
async_group_buffer_size()
The maximum number of trajectory groups an async run keeps started but
not yet trained: groups_per_step * (sampling_steps_ahead + 1).
Returns: int
effective_termination()
The termination policy this run trains with.
termination=None (the default) resolves via
~tinker_cookbook.rl.rollout_presets.default_rollout_config_for_model,
so thinkingmachines/Inkling models get the agentic grade-then-clamp
policy and other models get no reward adjustment. An explicit
policy wins.
Returns: TerminationRewardPolicy | None
effective_rollout_strategy()
The group rollout strategy this run trains with.
rollout_error_tolerance=None (the default) resolves via
~tinker_cookbook.rl.rollout_presets.default_rollout_strategy_for_model
(MinViableGroup for thinkingmachines/Inkling models, FailFast
otherwise). Explicit values — False, True, or a strategy
instance — win over the model default.
Returns: RolloutStrategy