dhenneberger1 commited on
Commit
c69238e
·
verified ·
1 Parent(s): 79842f7

Add int8 (Q8_0-style) RT-J checkpoints + model card

Browse files
README.md ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-sa-4.0
3
+ base_model: stanford-star/rt-j
4
+ tags:
5
+ - relational-deep-learning
6
+ - relational-databases
7
+ - tabular
8
+ - tabular-classification
9
+ - tabular-regression
10
+ - foundation-model
11
+ - in-context-learning
12
+ - quantized
13
+ - int8
14
+ - relational-transformer
15
+ datasets:
16
+ - stanford-star/the-join
17
+ - stanford-star/relbench
18
+ ---
19
+
20
+ # RT-J — int8 (Q8_0-style) quantized checkpoints
21
+
22
+ Int8 quantizations of [stanford-star/rt-j](https://huggingface.co/stanford-star/rt-j),
23
+ the Relational Transformer foundation model for in-context learning over
24
+ relational databases. Produced and consumed by the
25
+ [RelativeDB](https://github.com/RelativeDB) native inference engine
26
+ (`cpp/rt_quantize`); runs on its CPU (Accelerate / portable SIMD), Metal/MPS,
27
+ and CUDA backends.
28
+
29
+ | File | Task head | Size |
30
+ |---|---|---|
31
+ | `classification/model.q8.safetensors` | classification / ranking (logits — apply sigmoid) | 86 MB |
32
+ | `regression/model.q8.safetensors` | regression / forecasting (normalized values) | 86 MB |
33
+
34
+ (vs. 171 MB bf16 upstream, 342 MB fp32 in memory.)
35
+
36
+ ## Quantization format
37
+
38
+ Q8_0-style, plain safetensors — no custom container:
39
+
40
+ - Every **transformer-block projection** (`wq/wk/wv/wg`, `wo`, `ffn.w1/w2/w3`
41
+ across all 12 blocks — ~99% of parameters) is stored as an `I8` tensor with
42
+ a per-output-row symmetric fp32 scale in a `<name>.q_scale` companion
43
+ tensor: `W[o,i] ≈ q[o,i] * scale[o]`, `scale[o] = max|W[o,:]| / 127`.
44
+ - The value/col-name **encoders, decoder head, norms, biases and mask
45
+ embeddings stay fp32** (like llama.cpp's embedding/output layers):
46
+ input-side quantization error would propagate through all 12 blocks for a
47
+ negligible size win.
48
+
49
+ Any safetensors reader can load these files; dequantization is one line per
50
+ row. The RelativeDB loader dequantizes at load time and runs its
51
+ golden-verified fp32 pipeline on all backends.
52
+
53
+ ## Accuracy
54
+
55
+ Measured on the RelativeDB golden batch (B=5, S=16 churn example) against the
56
+ PyTorch reference, identical on CPU and Metal/MPS:
57
+
58
+ | Metric | fp32 | int8 |
59
+ |---|---|---|
60
+ | `yhat` max abs. error vs. torch | 3.9e-3 | 1.1e-2 |
61
+ | `yhat` mean abs. error | 5.1e-4 | 3.5e-3 |
62
+ | target-score sign / ranking | preserved | preserved |
63
+
64
+ Worst per-row mean relative weight error: ≈5%.
65
+
66
+ ## Usage (RelativeDB native engine)
67
+
68
+ ```bash
69
+ # direct path
70
+ ./build/rt_test testdata classification/model.q8.safetensors --quantized --device mps
71
+
72
+ # via the Java / Python / Rust bindings: place the .q8 file next to the fp32
73
+ # checkpoint (or point at a directory containing it) and opt in with
74
+ export RELATIVEDB_RT_QUANTIZED=1
75
+ ```
76
+
77
+ The C ABI (`rt_model_load`) accepts these files directly — the format is
78
+ auto-detected from the tensor dtypes.
79
+
80
+ ## Reproduce
81
+
82
+ ```bash
83
+ cmake -B build -S cpp && cmake --build build -j
84
+ ./build/rt_quantize <rt-j>/classification/model.safetensors classification/model.q8.safetensors
85
+ ./build/rt_quantize <rt-j>/regression/model.safetensors regression/model.q8.safetensors
86
+ ```
87
+
88
+ ## License & attribution
89
+
90
+ Derivative of [stanford-star/rt-j](https://huggingface.co/stanford-star/rt-j)
91
+ (Stanford STAR lab), redistributed under the same
92
+ **CC-BY-NC-SA-4.0** license. Architecture and training details are described
93
+ in the upstream model card; only the weight storage format differs here.
classification/config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "codename": "rt-j-clf",
3
+ "name": "RT-J Classifier",
4
+ "task_type": "clf",
5
+ "checkpoint_file": "model.q8.safetensors",
6
+ "embedding_model": "all-MiniLM-L12-v2",
7
+ "d_text": 384,
8
+ "model": {
9
+ "num_blocks": 12,
10
+ "d_model": 512,
11
+ "d_text": 384,
12
+ "num_heads": 8,
13
+ "d_ff": 2048,
14
+ "materialize_attn_masks": true
15
+ },
16
+ "provenance": {
17
+ "run_id": "pjbmgvu2",
18
+ "swa_step": 58000,
19
+ "project": "2026-04-17",
20
+ "recipe": "real_mixed_v6_5_486t"
21
+ }
22
+ }
classification/model.q8.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c68e3b5e1631434fb646f196bce04cd7e41e8f64f346370280df19cdc7fba52a
3
+ size 88107204
regression/config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "codename": "rt-j-reg",
3
+ "name": "RT-J Regressor",
4
+ "task_type": "reg",
5
+ "checkpoint_file": "model.q8.safetensors",
6
+ "embedding_model": "all-MiniLM-L12-v2",
7
+ "d_text": 384,
8
+ "model": {
9
+ "num_blocks": 12,
10
+ "d_model": 512,
11
+ "d_text": 384,
12
+ "num_heads": 8,
13
+ "d_ff": 2048,
14
+ "materialize_attn_masks": true
15
+ },
16
+ "provenance": {
17
+ "run_id": "fsuj4wdl",
18
+ "swa_step": 18000,
19
+ "project": "2026-04-17",
20
+ "recipe": "real_mixed_v6_5_486t"
21
+ }
22
+ }
regression/model.q8.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19e5023af00d8410c8e3c394b03538b224cfeccc7703c1825c766f647e15276a
3
+ size 88107204