HelloSun commited on
Commit
646980b
Β·
verified Β·
1 Parent(s): 328fe35

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +40 -4
README.md CHANGED
@@ -79,6 +79,18 @@ Recommended sampling (from the official model card):
79
  `top_p = 1`, `temperature = 0`. For coding tasks the authors suggest
80
  `alg = entropy, num_small_blocks = 32 (β†’ --diffusion-small-block 1), top_p = 0.8, temperature = 1`.
81
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  `--diffusion-algorithm` values: `0` origin, `1` entropy, `2` margin, `3` random, `4` confidence.
83
  `-ub N` is the maximum sequence length; the tail that does not fill a whole block is dropped.
84
 
@@ -139,16 +151,18 @@ experience while using it:
139
  |---|---|---|
140
  | **Input** β€” waiting for the prompt to be read before output starts | both | **β‰ˆ 78 t/s** short prompt; **β‰ˆ 132 t/s** for longer prompts (`llama-bench` pp512) |
141
  | **Output** β€” text generated (autoregressive, streamed live) | `llama-cli` | **11.9 t/s** (llama-bench tg128: 11.1 t/s) |
142
- | **Output** β€” text generated (block diffusion, block 32 / small-block 4, `alg=entropy`, `temp=0`) | `llama-diffusion-cli` | **β‰ˆ 4.4 t/s** |
 
143
 
144
  Notes:
145
  - Input (prompt processing) is the same causal prefill for both paths; it is what you wait
146
  for before the answer appears.
147
  - The AR output speed (β‰ˆ 12 t/s) is what `llama-cli` prints as `Generation: X t/s`; the
148
  diffused text is only flushed at the end of a run (unless `--diffusion-visual`).
149
- - Block diffusion reveals one token per denoising step, i.e. up to `block_length` (= 32)
150
- forward passes per block, so its tokens/s is inherently lower. The authors' faster
151
- `alg=confidence_threshold` mode is not implemented here (fixed 1-token steps).
 
152
  - The AR figures are the best reference for raw model throughput on this hardware.
153
 
154
  ## What the patch does
@@ -191,6 +205,28 @@ tokenizer.ggml.mask_token_id = 45830
191
  - Quantization may slightly affect the tricky reasoning cases; use `alg = entropy`,
192
  `temp = 0` for the most stable results.
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  ## Original model
195
 
196
  - Weights: [`openpangu/openPangu-R-7B-Diffusion`](https://huggingface.co/openpangu/openPangu-R-7B-Diffusion)
 
79
  `top_p = 1`, `temperature = 0`. For coding tasks the authors suggest
80
  `alg = entropy, num_small_blocks = 32 (β†’ --diffusion-small-block 1), top_p = 0.8, temperature = 1`.
81
 
82
+ **Fast mode** (higher throughput): reveal every masked token whose confidence exceeds a
83
+ threshold in a single denoising step, with one small block per block:
84
+
85
+ ```bash
86
+ ./build/bin/llama-diffusion-cli \
87
+ -m pangu-diffusion-Q4_K_M.gguf \
88
+ -p "[unused9]系统:[unused10][unused9]η”¨ζˆ·οΌš<question>[unused10][unused9]εŠ©ζ‰‹οΌš" \
89
+ -ub 256 --diffusion-block-length 32 --diffusion-small-block 32 \
90
+ --diffusion-confidence-threshold 0.9 --diffusion-algorithm 4 \
91
+ --temp 0 -t 16 --seed 42
92
+ ```
93
+
94
  `--diffusion-algorithm` values: `0` origin, `1` entropy, `2` margin, `3` random, `4` confidence.
95
  `-ub N` is the maximum sequence length; the tail that does not fill a whole block is dropped.
96
 
 
151
  |---|---|---|
152
  | **Input** β€” waiting for the prompt to be read before output starts | both | **β‰ˆ 78 t/s** short prompt; **β‰ˆ 132 t/s** for longer prompts (`llama-bench` pp512) |
153
  | **Output** β€” text generated (autoregressive, streamed live) | `llama-cli` | **11.9 t/s** (llama-bench tg128: 11.1 t/s) |
154
+ | **Output** β€” block diffusion (quality: block 32 / small-block 4, `alg=entropy`, `temp=0`) | `llama-diffusion-cli` | **β‰ˆ 4.4 t/s** |
155
+ | **Output** β€” block diffusion (fast: `--diffusion-confidence-threshold 0.9`, small-block 32, `alg=confidence`) | `llama-diffusion-cli` | **β‰ˆ 5.2 t/s** |
156
 
157
  Notes:
158
  - Input (prompt processing) is the same causal prefill for both paths; it is what you wait
159
  for before the answer appears.
160
  - The AR output speed (β‰ˆ 12 t/s) is what `llama-cli` prints as `Generation: X t/s`; the
161
  diffused text is only flushed at the end of a run (unless `--diffusion-visual`).
162
+ - Block diffusion normally reveals one token per denoising step, i.e. up to `block_length`
163
+ (= 32) forward passes per block. With `--diffusion-confidence-threshold T` every masked
164
+ token whose confidence exceeds `T` is revealed in the same step, which raises throughput
165
+ (the authors report up to 2.5Γ— vs. autoregressive on Ascend NPUs).
166
  - The AR figures are the best reference for raw model throughput on this hardware.
167
 
168
  ## What the patch does
 
205
  - Quantization may slightly affect the tricky reasoning cases; use `alg = entropy`,
206
  `temp = 0` for the most stable results.
207
 
208
+ ## Supported features
209
+
210
+ Implemented (matching the reference `inference/generation_utils.py`):
211
+
212
+ | Feature | Status |
213
+ |---|---|
214
+ | Context-causal block diffusion β€” full attention inside a block, causal attention over the preceding context | βœ“ |
215
+ | Block-by-block decoding (block length 32) | βœ“ `--diffusion-block-length` |
216
+ | Committed-block KV cache with a causal mask; first token of the next block decoded from the last position | βœ“ |
217
+ | Small blocks inside a block (`num_small_blocks`, optimum 4 or 8) | βœ“ `--diffusion-small-block` |
218
+ | Variable-length inference / flexible context | βœ“ |
219
+ | Logit shift (`diffusion.shift_logits`) | βœ“ |
220
+ | Dedicated mask token (`tokenizer.ggml.mask_token_id = 45830`) | βœ“ |
221
+ | Reveal order: `confidence`, `entropy`, `topk_margin` | βœ“ `--diffusion-algorithm 4/1/2` |
222
+ | `confidence_threshold` fast mode (multi-token reveal per step) | βœ“ `--diffusion-confidence-threshold` |
223
+ | EOS early stop | βœ“ |
224
+ | Autoregressive decoding | βœ“ `llama-cli` |
225
+
226
+ Not implemented:
227
+ - Batched (multi-sequence) block diffusion β€” the example CLI runs a single sequence.
228
+ - Vendor NPU kernels β€” this uses whatever backend llama.cpp was built with (CPU here).
229
+
230
  ## Original model
231
 
232
  - Weights: [`openpangu/openPangu-R-7B-Diffusion`](https://huggingface.co/openpangu/openPangu-R-7B-Diffusion)