Venugopalan2610 commited on
Commit
e61bbaf
·
verified ·
1 Parent(s): 637bda4

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +53 -0
README.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3.2
3
+ tags:
4
+ - quantization
5
+ - 2-bit
6
+ - llama
7
+ - qat
8
+ pretty_name: Trellis vs Scalar 2-Bit QAT — Single-Layer Snapshots
9
+ ---
10
+
11
+ # Single-Layer 2-Bit QAT Weight Snapshots
12
+
13
+ Per-layer 2-bit quantized weight snapshots for the controlled trellis-vs-scalar
14
+ comparison in **"Small GPU, Small Edge: A Controlled Study of Trellis vs. Scalar
15
+ 2-Bit QAT."** These reproduce **Tables 1, 3, and 4** of the paper.
16
+
17
+ Built on **meta-llama/Llama-3.2-1B** and subject to the **Llama 3.2 Community
18
+ License**. Each snapshot quantizes a *single* decoder layer's 7 projections to
19
+ 2 bits; all other layers stay FP16. **These are experiment artifacts, not a
20
+ deployable model.**
21
+
22
+ ## Contents
23
+ | file | layer | arm | init → train |
24
+ |---|---|---|---|
25
+ | `snapshots/layer04_bcjr_seed{0,1,2}.pt` | 4 (mild) | BCJR-trellis (soft) | PTQ → 10-step BCJR |
26
+ | `snapshots/layer04_ste_trellis_seed0.pt` | 4 | STE-trellis | FP → 10-step STE |
27
+ | `snapshots/layer04_scalar_ctrl_seed0.pt` | 4 | scalar-ctrl (uniform) | FP → 10-step STE |
28
+ | `snapshots/layer01_bcjr_seed0.pt` | 1 (sensitive) | BCJR-trellis | PTQ → 10-step BCJR |
29
+ | `snapshots/layer01_ste_trellis_seed0.pt` | 1 | STE-trellis | FP → 10-step STE |
30
+ | `snapshots/layer01_scalar_ctrl_seed0.pt` | 1 | scalar-ctrl | FP → 10-step STE |
31
+
32
+ The trellis-PTQ and scalar-PTQ arms are **not** included — they carry no training
33
+ and are recomputed on the fly from the FP weights.
34
+
35
+ ## Format
36
+ Each `.pt` is a `torch.save` dict `{proj_name: W_q}` (fp32/bf16, original
37
+ un-rotated basis), with keys `attn_{q,k,v,o}_proj` and `mlp_{gate,up,down}_proj`.
38
+
39
+ ## Usage (reproduce the tables)
40
+ ```python
41
+ import torch
42
+ from transformers import AutoModelForCausalLM
43
+ from src.qat.eval_llama_layer import install_layer_weights # from the code repo
44
+
45
+ m = AutoModelForCausalLM.from_pretrained(
46
+ "meta-llama/Llama-3.2-1B", torch_dtype=torch.bfloat16, device_map="cuda")
47
+ snap = torch.load("snapshots/layer04_bcjr_seed0.pt", weights_only=True)
48
+ install_layer_weights(m, 4, snap, dtype=torch.bfloat16)
49
+ # then eval WikiText-2 PPL / lm-eval 0-shot -> Tables 1, 3, 4
50
+ ```
51
+
52
+ - **Code:** https://github.com/Venugopalan2610/quant-2bit
53
+ - **Paper:** *Small GPU, Small Edge* (arXiv link TBD)