StillDeadcode commited on
Commit
5fdbcc9
·
verified ·
1 Parent(s): a94f1df

IQ8R container

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +112 -0
  3. minicpm5-2b-iq8r.rad +3 -0
  4. minicpm5-2b-iq8r.recipe +34 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ minicpm5-2b-iq8r.rad filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - openbmb/MiniCPM5-2B
5
+ - openbmb/MiniCPM5-2B-DSpark
6
+ base_model_relation: quantized
7
+ pipeline_tag: text-generation
8
+ language:
9
+ - en
10
+ - zh
11
+ tags:
12
+ - radiance
13
+ - rocm
14
+ - amd
15
+ - rdna4
16
+ - int8
17
+ - w8a8
18
+ - iq8r
19
+ - hadamard
20
+ - speculative-decoding
21
+ - dspark
22
+ ---
23
+
24
+ # MiniCPM5-2B IQ8R + DSpark — radiance container
25
+
26
+ [openbmb/MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B) as a single `.rad` container for
27
+ the [radiance](https://codeberg.org/StillDeadcode/radiance) inference engine (AMD RDNA4, ROCm), with
28
+ the [MiniCPM5-2B-DSpark](https://huggingface.co/openbmb/MiniCPM5-2B-DSpark) block drafter merged in
29
+ for speculative decoding.
30
+
31
+ It replaces [StillDeadcode/minicpm5-2b-fp8](https://huggingface.co/StillDeadcode/minicpm5-2b-fp8): the
32
+ same eight bits a weight, closer to the bf16 model and a little faster. A bf16 version is at
33
+ [StillDeadcode/minicpm5-2b-bf16](https://huggingface.co/StillDeadcode/minicpm5-2b-bf16).
34
+
35
+ | | |
36
+ |---|---|
37
+ | File | `minicpm5-2b-iq8r.rad` — 3.04 GiB |
38
+ | Weights | every linear of the model and of the drafter int8 (codes −127..127) with a u8 scale per row and 256 of K under a bf16 scale a row, each 128 of K rotated by the unnormalised Hadamard, round to nearest; the lm_head int8 with a bf16 scale per row and 128; embeddings and norms bf16 |
39
+ | Activations | int8 under the same rotation (W8A8) |
40
+ | Speculator | DSpark (5 layers, block size 7), IQ8R; its vocabulary head as 2-bit codes |
41
+ | Context | 131,072 tokens (the checkpoint's trained length) |
42
+ | Modalities | text |
43
+ | Needs | radiance built from main after 1.17.0: IQ8R at one scale a 256 of K and the int8 KV cache are not in 1.17.0 and come with the next release |
44
+
45
+ ## Quality and speed
46
+
47
+ KL divergence from the next-token distribution of radiance's bf16 container of the same model
48
+ (82,066 positions of mixed text, one card, bf16 KV cache unless named):
49
+
50
+ | | mean KLD | top-1 agreement |
51
+ |---|---|---|
52
+ | this file | 0.0103 | 97.3% |
53
+ | this file, `kv-cache-dtype: i8` | 0.0113 | |
54
+ | minicpm5-2b-fp8 | 0.0688 | 91.7% |
55
+ | minicpm5-2b-fp8, `kv-cache-dtype: fp8` | 0.0837 | |
56
+
57
+ One Radeon AI PRO R9700 (gfx1201), milliseconds a speculative step at 1 / 4 concurrent sequences:
58
+ 6.87 / 7.92, against 7.14 / 8.17 for minicpm5-2b-fp8; both accept 8.7 to 9.1 drafted tokens a step
59
+ over 24 chat prompts. Without the drafter a decode step is 5.17 ms (FP8 5.40).
60
+
61
+ ## Serve
62
+
63
+ ```yaml
64
+ # radiance.yaml
65
+ server:
66
+ host: 0.0.0.0
67
+ port: 8000
68
+ models:
69
+ minicpm5-2b:
70
+ model: minicpm5-2b-iq8r.rad
71
+ tp: 1
72
+ max-model-len: 131072
73
+ max-num-seqs: 8
74
+ kv-cache-dtype: i8
75
+ ```
76
+
77
+ ```sh
78
+ radiance --config radiance.yaml
79
+ ```
80
+
81
+ `tp: 2` splits it over two cards. The server speaks the OpenAI API (`/v1/chat/completions`,
82
+ `/v1/completions`), with tool calls and structured output; the drafter's depth is chosen
83
+ automatically (`num-speculative-tokens: N` states one, `0` turns speculation off).
84
+
85
+ Built and tested on Radeon AI PRO R9700 (gfx1201), one card and two.
86
+
87
+ ## How this file was made
88
+
89
+ ```sh
90
+ rad-convert openbmb/MiniCPM5-2B --draft-model openbmb/MiniCPM5-2B-DSpark \
91
+ --tokenizer openbmb/MiniCPM5-2B/tokenizer.json \
92
+ --recipe minicpm5-2b-iq8r.recipe -o minicpm5-2b-iq8r.rad
93
+ ```
94
+
95
+ The recipe (`minicpm5-2b-iq8r.recipe` in this repository); everything it does not name is the
96
+ checkpoint's own:
97
+
98
+ ```
99
+ output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
100
+ dspark.draft_head.weight rtn codes=u2 zero=u8 group=128 scale=f16
101
+ blk.*.attn_qkv.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
102
+ blk.*.attn_output.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
103
+ blk.*.ffn_gate_up.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
104
+ blk.*.ffn_down.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
105
+ dspark.fc.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
106
+ dspark.blk.*.attn_q.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
107
+ dspark.blk.*.attn_k.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
108
+ dspark.blk.*.attn_v.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
109
+ dspark.blk.*.attn_output.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
110
+ dspark.blk.*.ffn_gate_up.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
111
+ dspark.blk.*.ffn_down.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
112
+ ```
minicpm5-2b-iq8r.rad ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6048448b1ffbb29df9ed44d5277cc00fc71db686959cc67f678c203e4d1d80ac
3
+ size 3267162112
minicpm5-2b-iq8r.recipe ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # minicpm5-2b-iq8r.recipe -- MiniCPM5-2B with the DSpark drafter at IQ8R: every linear of the trunk
2
+ # and of the drafter as rotated int8, read against int8 activations (arch/llama_dense_fp8).
3
+ #
4
+ # OpenBMB publishes MiniCPM5-2B in bf16 only. IQ8R is int8 codes in the 128-wide Hadamard domain
5
+ # with a u8 scale per [1 x 256] of K under a bf16 scale per row, so a weight costs eight bits and
6
+ # 1/256 of a byte a parameter plus two bytes a row. Round to nearest with a scale search: no
7
+ # calibration data is read. Also:
8
+ #
9
+ # - the lm_head, int8 with a bf16 scale per [1 x 128], unrotated: the widest GEMM in the model
10
+ # at half the bytes
11
+ # - the drafter's 2-bit copy of the target's head (u2 codes, an f16 scale and a u8 zero a group
12
+ # of 128), read by its draft passes only
13
+ #
14
+ # Every norm, the embedding and the drafter's Markov codebooks stay bf16.
15
+ #
16
+ # rad-convert openbmb/MiniCPM5-2B --draft-model openbmb/MiniCPM5-2B-DSpark \
17
+ # --tokenizer openbmb/MiniCPM5-2B/tokenizer.json \
18
+ # --recipe data/recipes/minicpm5-2b-iq8r.recipe -o minicpm5-2b-iq8r.rad
19
+
20
+ output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym rule=search
21
+ dspark.draft_head.weight rtn codes=u2 zero=u8 group=128 scale=f16
22
+
23
+ blk.*.attn_qkv.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
24
+ blk.*.attn_output.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
25
+ blk.*.ffn_gate_up.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
26
+ blk.*.ffn_down.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
27
+
28
+ dspark.fc.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
29
+ dspark.blk.*.attn_q.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
30
+ dspark.blk.*.attn_k.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
31
+ dspark.blk.*.attn_v.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
32
+ dspark.blk.*.attn_output.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
33
+ dspark.blk.*.ffn_gate_up.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search
34
+ dspark.blk.*.ffn_down.weight rtn codes=i8 group=256 scale=u8 scale2=bf16 block2=1x* transform=fwht128 clamp=sym rule=search