train: frozen-width keeps GQA 3:1; report peak_gpu_gb and per-run tok/s
Browse files- train/train_ounce100m.py +23 -4
train/train_ounce100m.py
CHANGED
|
@@ -47,8 +47,12 @@ def build_config(seq_len, layers=None, hidden=None):
|
|
| 47 |
parameter count and makes T1 compare two different models."""
|
| 48 |
h = hidden or BASE["hidden"]
|
| 49 |
L = layers or BASE["layers"]
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
cfg = LlamaConfig(vocab_size=BASE["vocab"], hidden_size=h, intermediate_size=inter,
|
| 53 |
num_hidden_layers=L, num_attention_heads=BASE["heads"],
|
| 54 |
num_key_value_heads=kv,
|
|
@@ -331,6 +335,7 @@ def main():
|
|
| 331 |
step = tr.state.global_step
|
| 332 |
samples = samples_at(step, start_sample, seqs_per_step)
|
| 333 |
consumed = samples * args.seq_len
|
|
|
|
| 334 |
hist = [h for h in tr.state.log_history if "loss" in h]
|
| 335 |
final_loss = hist[-1]["loss"] if hist else None
|
| 336 |
say(f"TRAIN DONE step={step}/{steps_planned} elapsed={elapsed/60:.1f} min "
|
|
@@ -369,8 +374,22 @@ def main():
|
|
| 369 |
token=os.environ.get("HF_TOKEN"), prune=args.prune)
|
| 370 |
say("final push:", json.dumps({k: r[k] for k in ("verify", "pruned", "free_after_gb")})[:900])
|
| 371 |
say("RUN_JSON " + json.dumps({"final_step": step, "val_ppl": ppl, "tokens_consumed": consumed,
|
| 372 |
-
"tok_per_s": round(
|
| 373 |
-
"final_loss": final_loss, "prior_loss": prior
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
|
| 375 |
|
| 376 |
if __name__ == "__main__":
|
|
|
|
| 47 |
parameter count and makes T1 compare two different models."""
|
| 48 |
h = hidden or BASE["hidden"]
|
| 49 |
L = layers or BASE["layers"]
|
| 50 |
+
# "variant" means a different WIDTH, not merely a different layer count: the frozen GQA ratio (9 Q /
|
| 51 |
+
# 3 KV) belongs to the frozen width, and passing --hidden 576 explicitly must not quietly turn the
|
| 52 |
+
# model into MHA-9 and make test T1 measure something else.
|
| 53 |
+
frozen_width = (h == BASE["hidden"])
|
| 54 |
+
inter = BASE["ffn"] if frozen_width else (int(round(8 * h / 3)) // 64) * 64
|
| 55 |
+
kv = BASE["kv_heads"] if frozen_width else _kv_dividing(BASE["heads"], h)
|
| 56 |
cfg = LlamaConfig(vocab_size=BASE["vocab"], hidden_size=h, intermediate_size=inter,
|
| 57 |
num_hidden_layers=L, num_attention_heads=BASE["heads"],
|
| 58 |
num_key_value_heads=kv,
|
|
|
|
| 335 |
step = tr.state.global_step
|
| 336 |
samples = samples_at(step, start_sample, seqs_per_step)
|
| 337 |
consumed = samples * args.seq_len
|
| 338 |
+
consumed_this_run = step * tokens_per_step
|
| 339 |
hist = [h for h in tr.state.log_history if "loss" in h]
|
| 340 |
final_loss = hist[-1]["loss"] if hist else None
|
| 341 |
say(f"TRAIN DONE step={step}/{steps_planned} elapsed={elapsed/60:.1f} min "
|
|
|
|
| 374 |
token=os.environ.get("HF_TOKEN"), prune=args.prune)
|
| 375 |
say("final push:", json.dumps({k: r[k] for k in ("verify", "pruned", "free_after_gb")})[:900])
|
| 376 |
say("RUN_JSON " + json.dumps({"final_step": step, "val_ppl": ppl, "tokens_consumed": consumed,
|
| 377 |
+
"tok_per_s": round(consumed_this_run / max(1, elapsed)),
|
| 378 |
+
"final_loss": final_loss, "prior_loss": prior,
|
| 379 |
+
"micro_batch": args.micro_batch, "seq_len": args.seq_len,
|
| 380 |
+
"accum": args.accum, "world": world,
|
| 381 |
+
"params": pc["sum_numel"],
|
| 382 |
+
"peak_gpu_gb": peak_gb()}, sort_keys=True))
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
def peak_gb():
|
| 386 |
+
"""Peak CUDA allocation, in GB. The batch size at seq 2048 is the one thing p0c could not tell us
|
| 387 |
+
(it measured seq 1024), and an OOM mid-main-run is a lost session, so this number is part of every
|
| 388 |
+
preflight cell's evidence rather than something to discover at step 300 of the real run."""
|
| 389 |
+
try:
|
| 390 |
+
return round(torch.cuda.max_memory_allocated() / 1e9, 2) if torch.cuda.is_available() else None
|
| 391 |
+
except Exception:
|
| 392 |
+
return None
|
| 393 |
|
| 394 |
|
| 395 |
if __name__ == "__main__":
|