pssa-300m / README.md
NSC64's picture
Upload README.md with huggingface_hub
5072e99 verified
|
Raw History Blame Contribute Delete
7.17 kB
---
license: gpl-3.0
library_name: model
tags:
- state-space-model
- recurrent
- language-model
- from-scratch
- plastic
- mamba-like
- triton
datasets:
- codeparrot/codeparrot-clean
- vikp/textbook_quality_programming
- open-web-math/open-web-math
- HuggingFaceFW/fineweb-edu
metrics:
- perplexity
- accuracy
---
# pssa-300m
A 299.25M-parameter language model with no attention, trained on 8B tokens of a
code-heavy mix on one RTX PRO 6000 Blackwell. It is a PyTorch port of the
plastic state-space architecture from
[Sparticle62ops/pssa](https://github.com/Sparticle62ops/pssa), scaled from that
repo's 1.5M-parameter reference. The run spanned several Molab sandboxes and
resumed each time from a checkpoint published to this Hub repo every 5,000
steps.
The corpus is 45% codeparrot-clean, 20% textbook_quality_programming, 15%
open-web-math, and 20% fineweb-edu. The model writes code and technical prose
in a convincing register and picks up local grammar fast. It does not know
facts. The web and story samples below are invented in the trained register.
## Architecture
24 stacked blocks of:
```
xn = rmsnorm(x)
delta = softplus(W_delta xn)
h_t = exp(delta_t路A) h_{t-1} + delta_t路B_t路x_t
y_t = <h_t, C_t>
q = poincare(W_qx xn + W_qh y)
w = softmax(-d_H(q, k)/tau)
m = w @ v
z = y/鈭歞_s + gate路W_proj m + rank16-silu-adapter(xn) + MLP
h_i = h_{i-1} + block_i(h)/鈭歞epth
```
Parameters: 283.03M in the core (d_model 1024, depth 24, d_state 16, d_key 32,
untied 32k-token embedding and head, mlp_hidden 2816) and 16.22M across the 24
memory banks (640 slots each, rank-16 adapters). Nothing attends. Compute per
token stays flat as context grows because the recurrent state has a fixed size.
Two changes from the Rust reference, both needed at this scale:
- The memory bank trains by gradient instead of surprise-gated inserts. The
reference's 3.5-nat novelty threshold stops firing a few hundred steps into
a run this size, which would leave the write path idle for the remaining
billions of tokens.
- Backprop is truncated at 256 tokens.
The scan runs as a fused Triton kernel with a hand-written backward pass. It
matches a plain PyTorch loop to about 1e-7 on every gradient.
## Training
8B tokens total, single phase. The four sources were streamed in a 9:4:3:4
byte-interleaved mix (45/20/15/20), giving 967.9M train tokens and 11.4M held-out
tokens after tokenization with a 32,000-token byte-level BPE trained on a
code-heavy sample. The ~968M-token corpus was reused about 8.3 times.
Batch 24 x 512 tokens = 12,288 tokens per step. Learning rate 2e-4 with 500
warmup steps, held flat until the last 15% of the token budget, then cosine
decayed to 2e-5 at 8B. Final state: step 651,042, 8,000,004,096 tokens, training
loss EMA 1.980. Throughput was about 59k tokens/s (4.8 steps/s) at 12,288
tokens per step, roughly 38 GPU-hours of training. Additional wall time went to
rebuilding the corpus and retokenizing after each sandbox reset.
## Results
Held-out, 1M tokens per split, batch 8, sequence length 512, same script and
seed protocol as the 100M model card.
| split | cross-entropy | perplexity | next-token accuracy |
|---|---|---|---|
| code | 1.484 | 4.41 | 70.7% |
| text/math | 3.532 | 34.20 | 39.0% |
| mixed | 2.347 | 10.46 | 56.9% |
The code split is 8 MB of codeparrot-clean documents after the 1.8 GB training
window. The textbook dataset was exhausted at 0.47 GB during corpus build, so
there were no post-quota textbook documents left to sample. The text/math split
is 8 MB each of open-web-math after 0.6 GB and fineweb-edu after 0.8 GB. The
mixed split is the training run's own held-out tail (last 40 MB of the
interleaved corpus). All three splits are unseen. Because the sampling varies
by split, these numbers describe this model on these splits rather than a
continuation of the training curve.
The final training-loop validation loss was 1.964 on the mixed held-out tail.
The 1M-token mixed score above is higher because it averages random 512-token
windows across the whole held-out file rather than repeating a fixed batch.
Samples, temp 0.7, top-k 40:
> def train_step(
> inputs, labels, batch_size, num_steps, epochs,
> epochs_step, per_example_loss, per_batch_loss_step,
> gradient_clip_norm,
> gradient_clip_norm_duration,
> optimizer,
> gradient_clip_problem,
> Once upon a time, the country was a large part of the West African homeland. The Americans moved here in the early 1900s to make room for the Americans and the Americans moved to the west. We may expect that the Americans were getting more and more involved with the American society, but the Americans still kept the "Catholic," outright pledges made during the Civil War to suppress the Americans' attempts to control the country.
> The history of the Roman state in Rome.
> What is Roman History?
> History is a science that talks about the history of Rome from the early days of Rome to the present. While Rome was a Roman city, the Roman people first settled in Rome, and the Roman city of Rome was named after their son, Rome. Roman Rome is a region of the Roman Empire. Rome began to develop during the Roman Empire. The Roman people first moved to Rome during the Roman Empire, before they entered the Roman Empire. During the Roman Empire, Rome became a major
> The derivative of the function $f(x)$ is equal to $x^2 - 2x + 2$.
>
> ## Exercise
> Find the derivative of the following functions:
>
> 1. $f(x) = 2x^3 - 2$
> 2. $g(x) = \sqrt{x^2 - 2}$
>
> ### Solution
> 1. $f(x) = 2x^3 - 2$
> 2. $g(x) = 2x^2 - 2$
## Use
```python
# pip install torch safetensors tokenizers
from pssa_model import from_pretrained, generate
model, tok = from_pretrained(".") # dir with model.safetensors + tokenizer.json
print(generate(model, tok, "def train_step(", max_new=100))
```
`pssa_model.py` holds the config, model, loader, and sampler. On CPU it runs a
plain PyTorch scan. On CUDA it uses the Triton kernel when `pssa_kernels.py`
sits next to it. It does not need transformers.
Weights are bf16 safetensors, about 571 MB. Training state is in
`resume/ckpt.pt`. The training loop is `train_300m_run.py`, published in the
source repo's history and kept alongside the run on each sandbox.
## Files
- `model.safetensors`: weights, bf16
- `pssa_model.py`: model + loader + sampler
- `pssa_kernels.py`: fused Triton scan
- `tokenizer.json`: 32k code-aware byte-level BPE
- `tokenizer_meta.json`, `config.json`: tokenizer and architecture metadata
- `resume/ckpt.pt`: optimizer and model state at the final step
- `train_history.csv`, `val_history.csv`: curves
- `eval_300m.json`, `samples_300m.json`: held-out eval and card samples
- `eval_300m.py`, `eval_data.py`, `samples_300m.py`: scripts used for those
## Credit
The architecture, the Rust reference implementation, and the 1.5M-parameter
comparison against a matched transformer come from
[Sparticle62ops/pssa](https://github.com/Sparticle62ops/pssa), released under
GPL-3.0. This checkpoint is an independent PyTorch port trained on different
data. It is not an official release from that project.