Dynamic_DeltaNet / README.md
CrazyJames26's picture
Add round2_shared_kv/deltanet/distillation_lr1e-3
e915a4a verified
|
Raw History Blame Contribute Delete
4.12 kB
---
license: apache-2.0
base_model: Qwen/Qwen3-0.6B
language:
- en
tags:
- linear-attention
- deltanet
- distillation
- long-context
datasets:
- CrazyJames26/Dynamic_DeltaNet_Dataset
---
# Dynamic DeltaNet students (Qwen3-0.6B)
Students of [Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B) in which all 28 attention layers are replaced by DeltaNet-family mixers (16 query heads, 8 shared KV heads, head dim 128). Code: [github.com/Crazy-James26/Dynamic_DeltaNet](https://github.com/Crazy-James26/Dynamic_DeltaNet). Training data: [CrazyJames26/Dynamic_DeltaNet_Dataset](https://huggingface.co/datasets/CrazyJames26/Dynamic_DeltaNet_Dataset).
Write modes: `deltanet` keeps one state per head. `latest`, `all` and `novelty_top1` keep a bank of states whose size grows logarithmically with context length (7 at 8K, capped at 8 from 11,193 tokens) and differ in which states receive each token.
## Checkpoints
Each directory is a self-contained inference bundle: `student.safetensors`, `student_config.json`, the Qwen3 tokenizer, and the stage config used to train it. Optimizer states are not included.
| Path | Mode | Stage | Learning rate |
|---|---|---|---|
| `round2_shared_kv/latest/distillation_lr1e-4` | latest | Distillation, 4,360 steps (15.0B tokens) | 1e-4 |
| `round2_shared_kv/latest/distillation_lr5e-4` | latest | Distillation, 4,360 steps | 5e-4 |
| `round2_shared_kv/latest/distillation_lr1e-3` | latest | Distillation, 4,360 steps — **selected**; starting point of the `latest` student | 1e-3 |
| `round2_shared_kv/latest/continued_pretraining_step4222` | latest | + full-parameter continued pretraining, 4,222 steps (15.0B tokens) | 1e-3 cosine |
| `round2_shared_kv/latest/sft_step442` | latest | + SFT, 442 steps | 1e-4 linear |
| `round2_shared_kv/deltanet/distillation_lr1e-3` | deltanet | Distillation from the original weights, 4,360 steps (15.0B tokens) | 1e-3 |
| `round2_shared_kv/deltanet_lr1e-4_v0/distillation_step4360` | deltanet (v0) | Distillation, 4,360 steps | 1e-4 |
| `round2_shared_kv/deltanet_lr1e-4_v0/continued_pretraining_step4222` | deltanet (v0) | + full-parameter continued pretraining, 4,222 steps (15.0B tokens) | 5e-5 cosine |
| `round2_shared_kv/deltanet_lr1e-4_v0/sft_step442` | deltanet (v0) | + SFT, 442 steps | 1e-5 cosine |
Distillation trains only the replacement mixers against the frozen teacher (final hidden MSE + mean per-layer mixer-output MSE). Continued pretraining and SFT train all parameters with next-token cross-entropy.
The `latest` learning-rate sweep selects one rate by held-out composite MSE (final hidden MSE + mean of 28 mixer-output MSEs, 128 samples): **1e-4: 2.511, 5e-4: 1.523, 1e-3: 1.376**. The selected 1e-3 is used for all four students (continued pretraining peak 1e-3 cosine, SFT peak 1e-4 linear). Students trained at the selected rate live under `round2_shared_kv/<mode>/` and are added as each stage finishes. `deltanet_lr1e-4_v0` is an earlier end-to-end run at the pre-sweep rates and will be superseded.
## Results so far
1,510-sample evaluation (1,200 RULER items prompted as `input + answer_prefix`, plus 310 general and reading-comprehension items). RULER mean retrieval (4K / 8K / 16K):
| Model | 4K | 8K | 16K |
|---|---:|---:|---:|
| Qwen3-0.6B (native) | 94.50 | 91.19 | 82.75 |
| `latest/sft_step442` | 29.19 | 21.12 | 7.94 |
| `deltanet_lr1e-4_v0/sft_step442` (pre-sweep rates) | 0.81 | 0.25 | 0.50 |
Full per-task scores are in each `sft_step442/evaluation/scores.json`.
## Loading
The bundles need the `dynamic_deltanet` package from the GitHub repository and [Flash Linear Attention](https://github.com/fla-org/flash-linear-attention).
```python
from huggingface_hub import snapshot_download
from dynamic_deltanet.student import StudentForCausalLM
path = snapshot_download("CrazyJames26/Dynamic_DeltaNet",
allow_patterns="round2_shared_kv/deltanet_lr1e-4_v0/sft_step442/*")
model = StudentForCausalLM.from_pretrained(f"{path}/round2_shared_kv/deltanet_lr1e-4_v0/sft_step442",
device="cuda", compute_precision="float32")
```