Views
No views yet
llm.kittens C++/CUDA trainer, which is a fork of Karpathy's llm.c with some optimisations for SM120, and multi-stack kernel optimisations.tinystories-5090), this checkpoint replaces the MLP's GELU nonlinearity with a learnable SD-PReLU activation (the llm.kittens -af sd-prelu activation). Because SD-PReLU is not part of stock Transformers or llama.cpp, the repo ships a small custom module (modeling_gpt_sdprelu.py) and must be loaded with trust_remote_code=True. See Activation: SD-PReLU below.safetensors weights plus custom modeling code.
It was trained on a single RTX 5090 in roughly 14 hours (2595.7 ms average iteration over 20,000 steps).model.safetensors20000 / 200000.7815940.870315198871 tokens/s2642.72 ms38.0%2595.669013 ms248,896,984 bytes124,475,904 base + 24 learnable SD-PReLU scalars (theta_a/theta_b, 2 per layer × 12 layers)0.785740 train / 0.875080 validation loss on the same setup; SD-PReLU lands marginally lower on both (0.781594 / 0.870315) at near-identical throughput, with the activation adding only 24 scalar parameters.1.33 to 1.58 for the 768-hidden-size 1- and 2-layer attention-head ablations in Figure 24. This run's 0.870315 validation loss is lower, but the comparison is not apples-to-apples: this model is a 12-layer GPT-2-style model using GPT-2 tokenization, a 1024-token context, and a different implementation/training setup.c_fc up-projection and the c_proj down-projection) is replaced by SD-PReLU, a self-gated, damped PReLU. Each transformer block learns two scalars (theta_a, theta_b) that are mapped through a bounded reparameterization into a and b:1a = alpha_max * sigmoid(theta_a) # in [0, alpha_max), alpha_max = 0.30
2b = beta_min + softplus(theta_b) # in (beta_min, inf), beta_min = 0.50
3phi(x) = x * (a + (1 - a) * sigmoid(b * x))a is a learnable leak/floor (PReLU-like): the gate output never drops below a, so negative inputs are not fully zeroed.b controls the sharpness of the sigmoid gate. With a = 0, phi reduces to a Swish/SiLU-style x * sigmoid(b * x).[-20, 20]; inputs and outputs stay in the surrounding model dtype (BF16).sdprelu_alpha_max (0.30) and sdprelu_beta_min (0.50). Only 24 extra scalar parameters are introduced over the GELU baseline, so parameter count and on-disk size are essentially unchanged."activation_function": "gelu_new" for GPT-2 compatibility, but it is inert — the custom MLP overrides the activation with SD-PReLU regardless of that field.modeling_gpt_sdprelu.py, which defines:GPTSDPReLUConfig (model_type = "gpt-sdprelu"), a GPT2Config with the two extra sdprelu_* fields.GPTSDPReLUMLP, which reuses GPT-2's c_fc / c_proj / dropout submodules (so weight names stay mlp.c_fc.* / mlp.c_proj.*) and swaps GELU for SD-PReLU, adding theta_a / theta_b per layer.GPTSDPReLULMHeadModel, a GPT2LMHeadModel that installs the SD-PReLU MLP into every block.config.json via auto_map, so trust_remote_code=True is required to load the model. Everything else (attention, layernorms, embeddings, tied head, tokenizer) is standard GPT-2.d121212768102450,257model_type: gpt-sdprelu (custom code, trust_remote_code=True)dev/data/tinystories.py in llm.kittens. The only change from the GELU baseline is the -af sd-prelu activation flag.1./train_gpt2cu \
2 -i "dev/data/tinystories/TinyStories_train.bin" \
3 -j "dev/data/tinystories/TinyStories_val.bin" \
4 -o "log124M/5090_S" \
5 -v 250 -s 20000 -g 144 \
6 -h 0 \
7 -b 64 -t 1024 -d 524288 \
8 -r 0 \
9 -z 1 \
10 -c 0.1 \
11 -l 0.0006 -q 0.0 -u 700 -n 5000 \
12 -y 0 \
13 -e "d12" \
14 -af sd-prelu \
15 -x 20000sd-prelu (-af sd-prelu)641024524,288 tokens20,000llm.kittens6e-4700 steps0.00.115000 steps1Once upon a time, there was a little girl named Lily. She loved to play in the park with her friends. One day, they saw a big, dark cloud in the sky. Lily's friend, Timmy, said, "I think it's going to rain soon."
2Suddenly, they heard a loud noise. It was a big, scary dog! Lily felt very scared and her skin started to shake. But then, a brave man came and scared the dog away. "Thank you," said Lily. "You're welcome," said the man.
3After the storm passed, Lily and her friends went to play on the swings. They saw a beautiful rainbow in the sky. "Look at the pretty colors!" said Lily. "It's so bright and colorful!" Her friends agreed and they all felt happy.model.safetensors: BF16 Transformers weights (including the per-layer theta_a / theta_b SD-PReLU scalars).modeling_gpt_sdprelu.py: custom SD-PReLU model/config code (required, loaded via trust_remote_code=True).config.json: model configuration, including sdprelu_alpha_max / sdprelu_beta_min and the auto_map wiring.generation_config.json: default generation settings.tokenizer.json: GPT-2 tokenizer.vocab.json and merges.txt: GPT-2 BPE vocabulary files.trust_remote_code=True:llama.cpp / LM Studio without implementing the activation there. Use the Transformers loading path above instead. The GELU baseline (tinystories-5090) is available if you need a llama.cpp-compatible variant.generate):0.80.95501.05<|endoftext|> / token id 50256max_new_tokens, since it was trained for continuation and may not emit <|endoftext|> during normal generation.https://github.com/adamdroberts/llm.kittens (SD-PReLU is in an unreleased branch)https://arxiv.org/abs/2305.07759