gorbatjovy commited on
Commit
b55399a
·
verified ·
1 Parent(s): 4a69f24

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. .gitattributes +2 -35
  2. FC_SOLVE_META.json +8 -0
  3. README.md +150 -0
  4. config.json +61 -0
  5. model.safetensors +3 -0
.gitattributes CHANGED
@@ -1,35 +1,2 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz 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
 
1
+ assets/dflash2-figure.png filter=lfs diff=lfs merge=lfs -text
2
+ model.safetensors filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
FC_SOLVE_META.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "method": "closed-form fc recalibration (streamed, key-aligned)",
3
+ "ridge": 0.001,
4
+ "paired_rows": 83101,
5
+ "rel_move": 0.06703612953424454,
6
+ "fit_old": 0.012050002627370349,
7
+ "fit_new": 0.008628943737344049
8
+ }
README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model:
4
+ - incoai/GLM-5.3-Flash-DFlash2
5
+ - drowzeys/keys-GLM-5.3-Flash-NVFP4-ablit-l15-45-anchorstock
6
+ tags:
7
+ - speculative-decoding
8
+ - dflash2
9
+ - glm
10
+ - draft-model
11
+ library_name: transformers
12
+ ---
13
+
14
+ # GLM-5.3-Flash-DFlash2 — `fc` recalibrated for the abliterated NVFP4 target
15
+
16
+ A drop-in replacement for [`incoai/GLM-5.3-Flash-DFlash2`](https://huggingface.co/incoai/GLM-5.3-Flash-DFlash2)
17
+ when the **target model is abliterated**. Exactly **one tensor** differs from the
18
+ original: `fc.weight`.
19
+
20
+ ## Why this exists
21
+
22
+ DFlash2's drafter does not read the target's tokens — it reads the target's
23
+ **hidden states**, tapped at 5 layers and concatenated:
24
+
25
+ ```
26
+ target_layer_ids = [5, 14, 24, 33, 42] # 5 x 4096 = 20480 dims
27
+ fc.weight = [4096, 20480] # projects aux -> drafter width
28
+ ```
29
+
30
+ `fc` is the entire coupling between target and drafter.
31
+
32
+ Abliteration rewrites `o_proj` on **layers 15–45**. Three of those five taps
33
+ (24, 33, 42) sit *inside* that range, so the drafter's input distribution shifts
34
+ and acceptance drops. Measured drift on the abliterated target:
35
+
36
+ | tap | drift ‖Δh‖/‖h‖ | |
37
+ |---|---:|---|
38
+ | L5 | 0.14% | stock anchor (below the edited range) |
39
+ | L14 | 0.27% | stock anchor |
40
+ | L24 | 0.52% | **abliterated** |
41
+ | L33 | 0.84% | **abliterated** |
42
+ | L42 | **2.03%** | **abliterated** |
43
+ | overall (20480-dim) | 1.50% | mean per-row cosine 0.9257 |
44
+
45
+ Drift is ~zero below L15 and grows monotonically with depth — exactly what the
46
+ edit predicts.
47
+
48
+ ## What was done
49
+
50
+ **A closed-form ridge solve. No training, no SGD, no epochs.**
51
+
52
+ ```
53
+ min_W ‖ W·H_ablit − (fc_old·H_stock) ‖²_F + λ‖ W − fc_old ‖²_F
54
+ ```
55
+
56
+ Make `fc_new(h_ablit)` reproduce what `fc_old(h_stock)` produced, so the drafter
57
+ sees the residual it was originally trained on. Rows are key-matched on
58
+ `(seq, pos)` so a dropped sequence cannot silently misalign pairs; the normal
59
+ equations accumulate in **fp64** because hidden states are collinear.
60
+
61
+ ```json
62
+ {
63
+ "method": "closed-form fc recalibration (streamed, key-aligned)",
64
+ "ridge": 0.001,
65
+ "paired_rows": 83101,
66
+ "rel_move": 0.0670,
67
+ "fit_old": 0.012050,
68
+ "fit_new": 0.008629
69
+ }
70
+ ```
71
+
72
+ Capture: 83,101 aligned pairs, domain-tagged `[chat, code, prose, technical,
73
+ uncensored]` (50% code, 9.7% prose).
74
+
75
+ ### Ridge choice — 1e-3, chosen empirically
76
+
77
+ | ridge | weight move | fit_new (in-sample) | result |
78
+ |---:|---:|---:|---|
79
+ | **1e-3** | **6.7%** | 0.008629 | **shipped** |
80
+ | 1e-4 | 16.8% | 0.008226 | benchmarked → regression |
81
+ | 1e-5 | 44.6% | 0.007935 | benchmarked → regression |
82
+
83
+ **Lower ridge fit better in-sample and performed worse in practice.**
84
+ `fit_new` is a *training-set* residual with no held-out split, so it cannot
85
+ detect this — the 44.6% weight move at 1e-5 was the tell. **Judge these by
86
+ benchmark, never by `fit_new`.**
87
+
88
+ ## Per-domain effect — and an honest limitation
89
+
90
+ | domain | n | residual before | after | reduction |
91
+ |---|---:|---:|---:|---:|
92
+ | chat | 11,123 | 1.18% | 0.86% | 27.3% |
93
+ | code | 41,853 | 1.23% | 0.89% | 27.6% |
94
+ | prose | 8,022 | 1.07% | 0.68% | **36.3%** |
95
+ | technical | 8,452 | 1.28% | 0.93% | 27.1% |
96
+ | uncensored | 13,651 | 1.18% | 0.89% | 24.4% |
97
+ | **overall** | 83,101 | 1.20% | 0.87% | 27.7% |
98
+
99
+ Prose is corrected **best** of all five domains — and prose acceptance still sits
100
+ near 0.33 against ~0.98 for structured output.
101
+
102
+ **Conclusion: the prose bottleneck is the target's token entropy, not
103
+ abliteration drift.** This recalibration will not make prose fast. It recovers
104
+ acceptance on context-sensitive, high-draftability output (code, structured,
105
+ tool calls), which is where speculative decoding pays anyway.
106
+
107
+ ## Usage
108
+
109
+ Identical to the stock drafter — same architecture, same config, same
110
+ `num_speculative_tokens`. Only the weights differ.
111
+
112
+ ```bash
113
+ vllm serve <abliterated-target> \
114
+ --speculative-config '{"method":"dflash",
115
+ "model":"/path/to/this/repo",
116
+ "num_speculative_tokens":7}'
117
+ ```
118
+
119
+ Measured on 2× DGX Spark (GB10), TP=2, against the abliterated NVFP4 target:
120
+ structured ~67 tok/s at 0.978 acceptance / 6.84 accepted per step.
121
+
122
+ ## ⚠️ This drafter is target-specific
123
+
124
+ `fc` was fitted to the hidden states of **one specific abliterated checkpoint**
125
+ ([`drowzeys/keys-GLM-5.3-Flash-NVFP4-ablit-l15-45-anchorstock`](https://huggingface.co/drowzeys/keys-GLM-5.3-Flash-NVFP4-ablit-l15-45-anchorstock)).
126
+
127
+ Point it at a **differently** abliterated model, a finetune, or the stock
128
+ censored model and three of the five taps carry a different distribution again.
129
+ **It will not error — acceptance just quietly drops.** For a different target,
130
+ re-run the solve rather than reusing this.
131
+
132
+ Conversely, if you run that abliterated target with the *stock* `incoai`
133
+ drafter, you are silently leaving acceptance on the table.
134
+
135
+ ## Judging acceptance
136
+
137
+ Use **mean accepted length**, not acceptance ratio. The ratio rises when you
138
+ simply stop drafting the low-probability tail; throughput tracks accepted
139
+ length.
140
+
141
+ ## Credits
142
+
143
+ - [`zai-org/GLM-5.3-Flash`](https://huggingface.co/zai-org/GLM-5.3-Flash) — the original model (MIT)
144
+ - [`incoai/GLM-5.3-Flash-DFlash2`](https://huggingface.co/incoai/GLM-5.3-Flash-DFlash2) — the DFlash2 drafter this is derived from; **all architecture and training credit is theirs**, this repo changes one matrix
145
+ - [`drowzeys/keys-GLM-5.3-Flash-NVFP4-ablit-l15-45-anchorstock`](https://huggingface.co/drowzeys/keys-GLM-5.3-Flash-NVFP4-ablit-l15-45-anchorstock) — the abliterated target this was calibrated against
146
+ - [`LibertAIDAI/GLM-5.3-Flash-NVFP4`](https://huggingface.co/LibertAIDAI/GLM-5.3-Flash-NVFP4) — the NVFP4 parent quant
147
+ - [`dealignai/GLM-5.3-Flash-UNCENSORED-NVFP4`](https://huggingface.co/dealignai/GLM-5.3-Flash-UNCENSORED-NVFP4) — abliteration donor
148
+ - [`tonyd2wild/GLM-5.3-Flash-NVFP4-DFlash2-2x-DGX-Spark`](https://github.com/tonyd2wild/GLM-5.3-Flash-NVFP4-DFlash2-2x-DGX-Spark) — the 2-node deployment recipe, and the prior work identifying that abliteration costs drafter acceptance via hidden-state drift
149
+
150
+ License follows the base model (MIT).
config.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DFlash2DraftModel"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": null,
8
+ "dflash_config": {
9
+ "block_size": 8,
10
+ "conv_group_size": 16,
11
+ "conv_kernel_size": 2,
12
+ "mask_token_id": 154856,
13
+ "selector_rank": 256,
14
+ "selector_top_k": 16,
15
+ "target_layer_ids": [
16
+ 5,
17
+ 14,
18
+ 24,
19
+ 33,
20
+ 42
21
+ ]
22
+ },
23
+ "dtype": "bfloat16",
24
+ "eos_token_id": [
25
+ 154820,
26
+ 154827,
27
+ 154829
28
+ ],
29
+ "head_dim": 128,
30
+ "hidden_act": "silu",
31
+ "hidden_size": 4096,
32
+ "initializer_range": 0.02,
33
+ "intermediate_size": 12288,
34
+ "is_causal": false,
35
+ "layer_types": [
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "sliding_attention",
40
+ "sliding_attention"
41
+ ],
42
+ "max_position_embeddings": 1048576,
43
+ "max_window_layers": 5,
44
+ "model_type": "qwen3",
45
+ "num_attention_heads": 32,
46
+ "num_hidden_layers": 5,
47
+ "num_key_value_heads": 8,
48
+ "num_target_layers": 45,
49
+ "pad_token_id": 154820,
50
+ "rms_norm_eps": 1e-05,
51
+ "rope_parameters": {
52
+ "rope_theta": 10000.0,
53
+ "rope_type": "default"
54
+ },
55
+ "sliding_window": 2048,
56
+ "tie_word_embeddings": false,
57
+ "transformers_version": "5.7.0",
58
+ "use_cache": false,
59
+ "use_sliding_window": true,
60
+ "vocab_size": 154880
61
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb4774debbf9416fc1ef78a62b33e26219aa5a389a8ae7fa3adc47b50e079a99
3
+ size 2342169824