text stringlengths 0 201 |
|---|
import os |
import sys |
# Read the current file and the kernels file code ASAP, for logging |
with open(sys.argv[0], 'r') as f: |
code = f.read() |
with open(os.path.join(os.path.dirname(sys.argv[0]), 'triton_kernels.py'), 'r') as f: |
code += f"\n\n{'-'*40}\n# triton_kernels.py\n{'-'*40}\n\n" |
code += f.read() |
import copy |
import glob |
import math |
import threading |
import time |
import uuid |
from dataclasses import dataclass |
from itertools import accumulate, pairwise |
from pathlib import Path |
import gc |
os.environ["PYTORCH_ALLOC_CONF"] = "expandable_segments:True" |
import torch |
import triton |
import numpy as np |
torch.empty( |
1, device=f"cuda:{os.environ['LOCAL_RANK']}", requires_grad=True |
).backward() # prevents a bug on some systems |
import torch._dynamo as dynamo |
import torch.distributed as dist |
import torch.nn.functional as F |
# torch._inductor.config.coordinate_descent_tuning = True # we have banned this flag for new records because it causes compilation to take 30min |
from kernels import get_kernel |
from torch import Tensor, nn |
from triton_kernels import XXT, XTX, ba_plus_cAA, FusedLinearReLUSquareFunction, FusedSoftcappedCrossEntropy, transpose_add, transpose_copy |
# Fused triton kernel: relu(x @ W1.T)^2 @ W2.T |
# https://arxiv.org/abs/2109.08668v2; ~1-2% better than GELU; suggested by @SKYLINEZ007 and @Grad62304977 |
ReLUSqrdMLP = FusedLinearReLUSquareFunction.apply |
dynamo.config.recompile_limit = 64 |
# ----------------------------------------------------------------------------- |
# Distributed training setup |
rank = int(os.environ["RANK"]) |
world_size = int(os.environ["WORLD_SIZE"]) |
assert 8 % world_size == 0, "world_size must be a divisor of 8" |
grad_accum_steps = 8 // world_size |
grad_scale = 1 / grad_accum_steps # consistent grad magnitudes between different num_devices |
assert torch.cuda.is_available() |
device = torch.device("cuda", int(os.environ["LOCAL_RANK"])) |
torch.cuda.set_device(device) |
dist.init_process_group(backend="cuda:nccl,cpu:gloo", device_id=device) |
dist.barrier() |
master_process = (rank == 0) # this process will do logging, checkpointing etc. |
# ----------------------------------------------------------------------------- |
# Custom operators: FP8 matmul by @YouJiacheng |
# Transposed layout by @ChrisJMcCormick allows for faster gradient accumulation. |
@torch.library.custom_op("nanogpt::mm_t", mutates_args=()) |
def mm_t_op(x: Tensor, w: Tensor, x_s: float, w_s: float, grad_s: float) -> tuple[Tensor, Tensor, Tensor]: |
"""Computes y = x @ w with F8 weights stored as (in_features, out_features).""" |
@torch.compile |
def impl(x: Tensor, w: Tensor): |
assert x.is_contiguous() and w.is_contiguous() |
assert x.shape[1] == w.shape[0] # x: (batch, in), w: (in, out) |
x_f8 = x.div(x_s).to(torch.float8_e4m3fn) |
w_f8 = w.div(w_s).to(torch.float8_e4m3fn) |
# _scaled_mm requires column-major B. w_f8 is row-major (in, out). |
# .T.contiguous().T creates a column-major view without changing logical shape. |
w_f8_col_major = w_f8.T.contiguous().T |
out = torch._scaled_mm( |
x_f8, |
w_f8_col_major, |
out_dtype=torch.bfloat16, |
scale_a=x.new_tensor(x_s, dtype=torch.float32), |
scale_b=x.new_tensor(w_s, dtype=torch.float32), |
use_fast_accum=True, |
) |
return out, x_f8, w_f8 |
return impl(x, w) |
@mm_t_op.register_fake |
def _(x: Tensor, w: Tensor, *_): |
assert x.ndim == w.ndim == 2 |
assert x.shape[1] == w.shape[0] |
assert x.device == w.device |
assert x.is_contiguous() and w.is_contiguous() |
return x @ w, x.to(torch.float8_e4m3fn), w.to(torch.float8_e4m3fn) |
@torch.library.custom_op("nanogpt::mm_t_backward", mutates_args=()) |
def mm_t_backward_op(g: Tensor, x_f8: Tensor, w_f8: Tensor, x_s: float, w_s: float, grad_s: float) -> tuple[Tensor, Tensor]: |
@torch.compile |
End of preview. Expand in Data Studio
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Tokenbender Kaon Track 3 Artifacts
Artifact export from the 4x NVIDIA RTX PRO 6000 Blackwell pod cosmic-comet-e3 / tokenbender-kaon-track3.
This repository preserves run scripts, command lines, environment snapshots, GPU snapshots, status files, and logs. Generated torchinductor_cache directories and data/venv files are intentionally excluded.
Source GitHub issue: https://github.com/tokenbender/modded-nanogpt/issues/1 Source repo commit on pod: 292d87a98bbec49f1cde7b052b19d716a20538ae (tokenbender/modded-nanogpt), with upstream latest baseline parent 890aeba91b5f3c8b32c22d520c07991ee6ca2e2f. Export generated UTC: 2026-05-14T04:44:59Z
High-signal runs
| run | status | last validation point |
|---|---|---|
baseline-muon-4x-torch27-paddedcollectives-20260513T173211Z |
state=finished; exit_code=0; finished_at=2026-05-13T18:36:35Z; train_log=logs/0cf54a35-808b-4d0d-b3b3-bfe73aac5398.txt | val_loss=3.27839, train_time=3716.838s, step_avg=1111.24ms |
kaon-pure-4x-torch27-paddedcollectives-20260513T184645Z |
state=finished; exit_code=0; finished_at=2026-05-13T19:50:51Z; train_log=logs/305d0baf-2111-4c61-a468-24ded0d07b04.txt | val_loss=3.28719, train_time=3675.555s, step_avg=1077.29ms |
kaon-tuned-lr030-wd015-4x-torch27-paddedcollectives-20260513T211243Z |
state=finished; exit_code=0; finished_at=2026-05-13T22:16:53Z; train_log=logs/00a6c2ea-192a-4637-886b-97505fca32a6.txt | val_loss=3.28890, train_time=3679.902s, step_avg=1076.72ms |
kaon-tuned-lr035-wd015-cd060-4x-torch27-paddedcollectives-20260513T221845Z |
state=stopped; reason=worse_than_muon_and_previous_tuned_by_step1375; stopped_at=2026-05-13T22:47:59Z | val_loss=3.53769, train_time=1686.92s, step_avg=1120.71ms |
kaon-tuned-lr030-wd015-cd060-4x-torch27-paddedcollectives-20260513T224846Z |
state=stopped; reason=worse_than_muon_and_previous_tuned_by_step1375; stopped_at=2026-05-13T23:17:16Z | val_loss=3.56422, train_time=1542.053s, step_avg=1112.39ms |
Notes
- The clean 4x Muon baseline finished at val_loss=3.27839 after 3716.838s on this pod.
- Pure Kaon finished at val_loss=3.28719 after 3675.555s, materially worse than Muon at comparable wall time/steps.
- The best full tuned Kaon run here (lr030/wd015) finished at val_loss=3.28890 after 3679.902s, still worse than the 4x Muon baseline.
- Cooldown variants were stopped at step 1375 because their intermediate losses were worse than both Muon and the previous tuned Kaon run.
- Early high-LR probes are included for auditability but were intentionally stopped once they were clearly underperforming.
Layout
- runs//command.sh: exact launch command
- runs//train_gpt*.py: exact transient training script when applicable
- runs//stdout.log and train-log.txt: captured run output
- runs//status.env: run state and stop reason
- summary.json: machine-readable run summary
- Downloads last month
- 20