Instructions to use HelloSun/openPangu-R-7B-Diffusion-Q4KM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use HelloSun/openPangu-R-7B-Diffusion-Q4KM with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M # Run inference directly in the terminal: llama cli -hf HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M # Run inference directly in the terminal: llama cli -hf HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M
Use Docker
docker model run hf.co/HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M
- Llama new
- LM Studio
- Jan
- Ollama
How to use HelloSun/openPangu-R-7B-Diffusion-Q4KM with Ollama:
ollama run hf.co/HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use HelloSun/openPangu-R-7B-Diffusion-Q4KM with Docker Model Runner:
docker model run hf.co/HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M
- Lemonade
How to use HelloSun/openPangu-R-7B-Diffusion-Q4KM with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull HelloSun/openPangu-R-7B-Diffusion-Q4KM:Q4_K_M
Run and chat with the model
lemonade run user.openPangu-R-7B-Diffusion-Q4KM-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Upload README.md with huggingface_hub
Browse files
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** β
|
|
|
|
| 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`
|
| 150 |
-
forward passes per block
|
| 151 |
-
`
|
|
|
|
| 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)
|