simak31 commited on
Commit
03ea399
·
verified ·
1 Parent(s): f4a7ec3

Upload config.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. config.py +63 -0
config.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Config for the redesigned run: small custom vocab (not GPT-2's 50k) so
3
+ embedding overhead doesn't dominate the parameter budget, sized to hit a
4
+ genuine ~20:1 token:param ratio on a free-tier T4.
5
+
6
+ Run `python model.py` after building this to confirm the exact param count
7
+ before launching a long run.
8
+ """
9
+ from dataclasses import dataclass
10
+
11
+
12
+ @dataclass
13
+ class ModelConfig:
14
+ vocab_size: int = 8192 # custom BPE, trained on YOUR corpus (tokenizer_train.py)
15
+ # -- NOT GPT-2's 50304. At small model sizes, a 50k vocab's
16
+ # embedding table alone eats 60-75% of total params, leaving
17
+ # almost nothing for actual transformer capacity. 8192 keeps
18
+ # embedding overhead to ~17-20% of total.
19
+ context_len: int = 256 # countdown prompts are short; halving context vs. the previous
20
+ # 512 also halves the quadratic attention cost, for free
21
+ d_model: int = 384
22
+ n_layer: int = 10
23
+ n_head: int = 6
24
+ n_kv_head: int = 2 # GQA
25
+ d_ff: int = 1024 # SwiGLU inner dim
26
+ rope_theta: float = 10000.0
27
+ dropout: float = 0.0
28
+ tie_embeddings: bool = True
29
+ # -> this config lands at ~18.9M params, verified by model.py
30
+
31
+
32
+ @dataclass
33
+ class TrainConfig:
34
+ data_dir: str = "data"
35
+ train_bin: str = "data/train.bin"
36
+ val_bin: str = "data/val.bin"
37
+
38
+ # ---- the ratio that actually matters ----
39
+ target_tokens: int = 380_000_000 # ~20:1 tokens:params -- genuinely Chinchilla-optimal,
40
+ # not a compromise like the 1.3:1 ratio last time
41
+
42
+ # ---- optimization ----
43
+ micro_batch_size: int = 32 # smaller model + shorter context = bigger batch fits
44
+ grad_accum_steps: int = 4 # effective batch = 32*4*256 = 32,768 tokens/step
45
+ max_lr: float = 8e-4 # slightly higher than the 116M run's 6e-4 -- smaller
46
+ # models generally tolerate a higher LR
47
+ min_lr: float = 8e-5
48
+ warmup_steps: int = 300
49
+ weight_decay: float = 0.1
50
+ grad_clip: float = 1.0
51
+ beta1: float = 0.9
52
+ beta2: float = 0.95
53
+
54
+ precision: str = "fp16" # T4 = Turing, no bf16 tensor cores -- same reasoning as before
55
+
56
+ ckpt_dir: str = "checkpoints"
57
+ log_path: str = "logs/train_log.csv"
58
+ save_every_steps: int = 250
59
+ eval_every_steps: int = 250
60
+ eval_iters: int = 50
61
+ log_every_steps: int = 20
62
+
63
+ seed: int = 1337