Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chronos/webui/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
"field.recompute_policy.label": "Recompute blocks",
"field.recompute_scope.help": "block: recompute whole blocks (most memory saved). mlp: recompute only each block's MoE/FFN, which keeps the attention results and costs less time.",
"field.recompute_scope.label": "Recompute scope",
"field.recurrent_attention_mode.help": "How attention runs inside the loop. shared_first: every iteration attends, K/V from iteration 0 (exact cache, KV does not grow with depth). per_iteration: one KV per iteration (D× KV). first_only: v2 behaviour.",
"field.recurrent_attention_mode.help": "How attention runs inside the loop. shared_first (default): every iteration attends, K/V from iteration 0; KV does not grow with depth and both inference-time depth override and recurrent-depth speculative decoding work. per_iteration: one KV per iteration (recurrent layers hold depth× KV); at the 15M ABC setting it matches shared_first on validation CE (4.727 vs 4.735) and produces much cleaner greedy output (max_4gram 10.67 vs 18.58, see docs/LOOP_DEPTH.md §4.3), but max_inference_depth is forced to the trained depth and speculative decoding falls back to plain. first_only: v2 behaviour.",
"field.recurrent_attention_mode.label": "Recurrent attention",
"field.recurrent_depth.help": "Iterations of each recurrent group during training. Virtual layers = prelude + groups × depth + coda.",
"field.recurrent_depth.label": "Training depth",
Expand Down
2 changes: 1 addition & 1 deletion chronos/webui/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
"field.recompute_policy.label": "再計算するブロック",
"field.recompute_scope.help": "block: ブロック全体を再計算(メモリ削減が最大)。mlp: 各ブロックの MoE/FFN のみ再計算し、アテンション結果を保持して時間を抑えます。",
"field.recompute_scope.label": "再計算の範囲",
"field.recurrent_attention_mode.help": "ループ内でのアテンションの実行方法。shared_first:毎反復でアテンションし、K/V は反復 0 のもの(キャッシュは厳密で、KV は深さで増えない)。per_iteration:反復ごとに KV を持つ(KV が D 倍)。first_only:v2 の挙動。",
"field.recurrent_attention_mode.help": "ループ内でのアテンションの実行方法。shared_first(既定):毎反復でアテンションし、K/V は反復 0 のもの。KV は深さで増えず、推論時に max_inference_depth を変えられ、再帰深度の自推測デコードも使える。per_iteration:反復ごとに KV を持つ(再帰層は depth 倍 KV)。15M ABC 実験では検証 CE が shared_first と同等(4.727 vs 4.735)で、貪欲生成は明らかにきれいになる(max_4gram 10.67 vs 18.58、docs/LOOP_DEPTH.md §4.3 参照)が、max_inference_depth は学習深度に固定され、自推測デコードは通常デコードに退化する。first_only:v2 の挙動。",
"field.recurrent_attention_mode.label": "再帰内アテンション",
"field.recurrent_depth.help": "学習中に各再帰グループを反復する回数。仮想層数 = プレリュード + グループ数 × 深さ + コーダ。",
"field.recurrent_depth.label": "学習時の深さ",
Expand Down
2 changes: 1 addition & 1 deletion chronos/webui/i18n/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
"field.recompute_policy.label": "重算的块",
"field.recompute_scope.help": "block:重算整个块(最省内存)。mlp:只重算每块的 MoE/FFN,保留注意力结果,耗时更少。",
"field.recompute_scope.label": "重算范围",
"field.recurrent_attention_mode.help": "循环内注意力的运行方式。shared_first:每轮都做注意力,K/V 取第 0 轮(缓存精确,KV 不随深度增长)。per_iteration:每轮一份 KV(D 倍 KV)。first_only:v2 行为。",
"field.recurrent_attention_mode.help": "循环内注意力的运行方式。shared_first(默认):每轮都做注意力,K/V 取第 0 轮;KV 不随深度增长,推理时可改 max_inference_depth,也支持循环深度自推测解码。per_iteration:每轮一份 KV(循环层 depth 倍 KV);15M ABC 实验中验证 CE 与 shared_first 持平(4.727 vs 4.735),而贪心输出显著更干净(max_4gram 10.67 vs 18.58,见 docs/LOOP_DEPTH.md §4.3),但 max_inference_depth 必须等于训练深度,自推测解码会退化为普通解码。first_only:v2 行为。",
"field.recurrent_attention_mode.label": "循环注意力",
"field.recurrent_depth.help": "训练时每个循环组的迭代次数。虚拟层数 = 前置 + 组数 × 深度 + 收尾。",
"field.recurrent_depth.label": "训练深度",
Expand Down
2 changes: 1 addition & 1 deletion chronos/webui/i18n/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
"field.recompute_policy.label": "重算的區塊",
"field.recompute_scope.help": "block:重算整個區塊(最省記憶體)。mlp:只重算每個區塊的 MoE/FFN,保留注意力結果,耗時較少。",
"field.recompute_scope.label": "重算範圍",
"field.recurrent_attention_mode.help": "循環內注意力的執行方式。shared_first:每輪都做注意力,K/V 取第 0 輪(快取精確,KV 不隨深度成長)。per_iteration:每輪一份 KV(D 倍 KV)。first_only:v2 行為。",
"field.recurrent_attention_mode.help": "循環內注意力的執行方式。shared_first(預設):每輪都做注意力,K/V 取第 0 輪;KV 不隨深度成長,推論時可改 max_inference_depth,也支援循環深度自推測解碼。per_iteration:每輪一份 KV(循環層 depth 倍 KV);15M ABC 實驗中驗證 CE 與 shared_first 相當(4.727 vs 4.735),而貪心輸出明顯更乾淨(max_4gram 10.67 vs 18.58,見 docs/LOOP_DEPTH.md §4.3),但 max_inference_depth 必須等於訓練深度,自推測解碼會退化為一般解碼。first_only:v2 行為。",
"field.recurrent_attention_mode.label": "循環注意力",
"field.recurrent_depth.help": "訓練時每個循環組的迭代次數。虛擬層數 = 前置 + 組數 × 深度 + 收尾。",
"field.recurrent_depth.label": "訓練深度",
Expand Down
24 changes: 24 additions & 0 deletions docs/LOOP_DEPTH.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ For the sigmoid pair, the signed difference `b4sig − d4sig` is positive at ste

*Figure L7. Recorded order-comparison trajectories and an exact common-step sigmoid gap. The image plots `CE(layer) − CE(block)`, so its sign is opposite to the `b4sig − d4sig` convention in the preceding paragraph. A positive plotted gap means lower block-order CE. CE, cross-entropy. Common-step pairing does not control all possible differences in code revision or optimization state.*

### 4.3 Attention-mode comparison at matched recipe

The `base` and `C_periter` arms in the ABC experiment set differ only in `recurrent_attention_mode`. Both use $P=1$, $G=4$, $C=1$, $R=4$, block order, sigmoid dt with range [0.05, 1], seed 1234, context 512, and a 1,800-second wall budget. The arm JSONs are [arm_base.json](../experiments/loop_depth_15m/results_abc/arm_base.json) and [arm_C_periter.json](../experiments/loop_depth_15m/results_abc/arm_C_periter.json); greedy-probe outputs are [probes/base.json](../experiments/loop_depth_15m/results_abc/probes/base.json) and [probes/C_periter.json](../experiments/loop_depth_15m/results_abc/probes/C_periter.json).

| Arm | Final step | `train_wall_s` | Tokens (M) | `final.valid_ce_64` | `peak_gb` |
|---|---:|---:|---:|---:|---:|
| `base` (`shared_first`) | 1,290 | 1,804.3 | 84.5 | 4.735 | 7.43 |
| `C_periter` (`per_iteration`) | 1,235 | 1,800.0 | 80.9 | 4.727 | 7.54 |

*Table L5. Final recorded fields for the attention-mode pair, from each arm's `final` block.*

At the latest shared step 1,000, recorded `valid_ce` is 4.920 (`base`) and 4.867 (`C_periter`); the signed gap is −0.053. The per-corpus gap at the final stopping point `C_periter − base` is +0.021 on Cosmopedia, −0.038 on Edu-ZH, +0.019 on FineWeb-Edu, +0.032 on Wiki EN, and −0.078 on Wiki ZH. Steps per logged minute are 42.9 (`base`) and 41.2 (`C_periter`). Peak memory is approximately tied at 512 context, so cache-slot growth does not dominate here.

The greedy-probe averages over the twelve EN/ZH prompts in [probes/prompts.jsonl](../experiments/loop_depth_15m/results_abc/probes/prompts.jsonl) are:

| Arm | `unique_ratio` | `max_run` | `max_4gram` |
|---|---:|---:|---:|
| `base` | 0.151 | 13.08 | 18.58 |
| `C_periter` | 0.144 | 3.58 | 10.67 |

*Table L6. Per-prompt averages written by [probes/probe_arm.py](../experiments/loop_depth_15m/results_abc/probes/probe_arm.py) at `--max-tokens 60`. `max_run` is the longest contiguous same-token stretch. `max_4gram` is the maximum 4-gram repetition count across the continuation.*

KV accounting under this skeleton: `shared_first` maintains one cache slot per physical block, so the model stores six slots. `per_iteration` maintains one slot per repeat on the recurrent blocks, so the model stores $P+RG+C=1+4\cdot 4+1=18$ slots: four times as many on the recurrent blocks and three times as many across the whole six-block model. The two inference-side consequences, both enforced at serving time, are that `max_inference_depth` cannot differ from `recurrent_depth` because the cache binds to a specific repeat, and that recurrent-depth self-speculative decoding falls back to the plain path because the draft depth cannot be shortened.

## 5. Step-size trajectories and what they establish

The effective sigmoid step is
Expand Down
107 changes: 107 additions & 0 deletions experiments/loop_depth_15m/results_abc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# ABC experiments — five 15M arms at 30 min each

Five arms share one data recipe (`chronos_data_30m`), one tokenizer, one
1800-s wall budget. Each arm varies one knob against `base`. Every arm's
`.pth` was probed on the same 12 EN/ZH greedy continuations, 60 tokens
each, no sampling, no penalty.

The shared skeleton is `prelude_layers=1`, `recurrent_groups=4`,
`coda_layers=1`, `recurrent_depth=4` (`B_plain` is depth 1). The `dt sum`
in the last column is the sum of the four per-group `dt` values after
the sigmoid, not a cumulative step across iterations (every iteration
runs all four groups).

## Arms

| arm | depth | attn_mode | aux_losses | valid_ce | steps | wall_s | unique | max_run | max_4gram | dt per group (sum) |
|---|---:|---|---|---:|---:|---:|---:|---:|---:|---|
| `base` | 4 | shared_first | on | 4.735 | 1290 | 1804 | 0.151 | 13.08 | 18.58 | 0.25/0.22/0.25/0.23 (0.96) |
| `A_dtcap` | 4 | shared_first | on, dt_max=0.5 | 4.768 | 1290 | 1801 | 0.124 | 15.67 | 19.67 | 0.14/0.14/0.14/0.16 (0.58) |
| `B_plain` | 1 | — | on | **4.528** | 2195 | 1803 | 0.150 | 6.42 | 15.33 | — |
| `C_periter` | 4 | **per_iteration** | on | 4.727 | 1235 | 1800 | 0.144 | **3.58** | **10.67** | 0.23/0.23/0.24/0.26 (0.97) |
| `obj_lm` | 4 | shared_first | **off** | **4.533** | 1335 | 1806 | **0.201** | 10.67 | 16.75 | 0.42/0.46/0.56/0.42 (1.86) |

## What each arm tests

- `base` is the 0.3.3 preset at 15M scale.
- `A_dtcap` tightens `recurrent_dt_max` to 0.5. Learned per-group dt
halves; under-steps the recurrence; worst greedy of the lot.
- `B_plain` drops `recurrent_depth` to 1. 1.7× more steps per second;
wins by 0.21 nat at matched wall time, loses by 0.15 nat at matched
steps. Direction: depth=4 is over-budget at this scale.
- `C_periter` swaps `recurrent_attention_mode` to `per_iteration`. CE
tied with `base`; `max_run` 3.58 vs 13.08 is the cleanest greedy
output. Costs: KV grows by `recurrent_depth` on the recurrent layers
only (4× those layers, 3× the whole 6-layer model), inference-time
depth override is refused, and speculative decoding falls back to
plain.
- `obj_lm` zeroes every non-structural auxiliary loss (cluster_locality,
router_locality, temporal, three lookahead terms, iteration_cluster,
router_anchor, distill, stability, ponder — `balance` kept). 0.20 nat
CE win over `base` at matched wall time, about 0.17 nat at matched
step, on all five sources; best `unique_ratio`. The learned per-group
`dt` is about twice base's ([0.42, 0.46, 0.56, 0.42] vs
[0.25, 0.22, 0.25, 0.23]). Each group still interpolates (dt < 1), so
this is not an overshoot. The arm removes all eleven terms at once, so
it cannot say which term drives the CE gain or the larger `dt`.

## What 0.3.4 took from this

- Decoding-side: `repetition_penalty` kwarg across speculative /
streaming / adapter / HTTP serving (default 1.0). CTRL rule applied on
raw logits in both draft `pick` and the greedy verify step, so
rejection sampling and greedy acceptance both stay consistent.
- `max_inference_depth` is exposed as an explicit `INFERENCE_OVERRIDE`
key, so a caller can run the recurrent loop at a shallower depth than
the one it was trained at. On the local 30M CPT checkpoint
(`latest.state.pkl`), setting it to 3 lifts 60-token greedy
`unique_ratio` from 0.129 to 0.220 without a penalty; combined with
`repetition_penalty=1.15` it reaches 0.692.
- No kernel structure change. `shared_first` remains the default: the
per_iteration win on decoding does not pay for its inference-time
inflexibility (4× KV, no depth override, no speculative decoding).
- There is no "auto" depth selector in 0.3.4. An earlier draft of the
release added one that would have read a trained `dt` schedule off
`ChronosConfig`, but that schedule only lives on
`recurrent_controller.step_sizes` in the state dict — the helper
no-opped on every real load and was removed before this release.

## Files

- `design.md` — pre-registered arm definitions and pass rule.
- `arm_<name>.json` — per-step metrics the trainer wrote (`evals`,
`train_curve`, final checkpoint path, `config` with the arm's resolved
recipe).
- `arm_<name>.log` — the training-process stdout.
- `queue.log`, `queue_obj.log` — arm-level queue transitions.
- `probes/prompts.jsonl` — the 12 EN/ZH prompts used for greedy probing.
- `probes/<name>.json` — per-prompt greedy continuations and the
`unique_ratio` / `max_run` / `max_4gram` averages in the arms table.
- `probes/probe_arm.py` — the greedy probe. Runs the Torch state dict
through MLX via `ChronosMLXModel.from_chronos_pytorch` so experts are
included.

The final `.pth` and training-output subdirectories are not committed;
`arm_<name>.json`'s `checkpoint` field is written relative
(`run_<name>/arm_<name>.pth`) for readers who rerun the arms locally.

## Reproducibility

Each arm's resolved recipe is captured in `arm_<name>.json` under
`config`. Only `recurrent_attention_mode` differs between `base` and
`C_periter`; only `recurrent_dt_init`/`recurrent_dt_max` differ for
`A_dtcap`; `B_plain` sets `recurrent_depth=1`; `obj_lm` zeroes the
auxiliary-loss weights listed above and keeps every other field at
`base`. All five arms share seed 1234, context 512, 65,536 tokens per
step, peak LR 1.5e-3, and the same 30-min wall budget.

To rerun a probe:

```
python experiments/loop_depth_15m/results_abc/probes/probe_arm.py \
--pth run_<name>/arm_<name>.pth \
--tokenizer <training tokenizer.json> \
--prompts experiments/loop_depth_15m/results_abc/probes/prompts.jsonl \
--max-tokens 60 \
--out experiments/loop_depth_15m/results_abc/probes/<name>.json
```
Loading
Loading