Instructions to use Dariusfar/GLM-4.7-Flash-DFlash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Dariusfar/GLM-4.7-Flash-DFlash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Dariusfar/GLM-4.7-Flash-DFlash")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("Dariusfar/GLM-4.7-Flash-DFlash") model = AutoModel.from_pretrained("Dariusfar/GLM-4.7-Flash-DFlash", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Dariusfar/GLM-4.7-Flash-DFlash with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Dariusfar/GLM-4.7-Flash-DFlash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dariusfar/GLM-4.7-Flash-DFlash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Dariusfar/GLM-4.7-Flash-DFlash
- SGLang
How to use Dariusfar/GLM-4.7-Flash-DFlash with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Dariusfar/GLM-4.7-Flash-DFlash" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dariusfar/GLM-4.7-Flash-DFlash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Dariusfar/GLM-4.7-Flash-DFlash" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dariusfar/GLM-4.7-Flash-DFlash", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Dariusfar/GLM-4.7-Flash-DFlash with Docker Model Runner:
docker model run hf.co/Dariusfar/GLM-4.7-Flash-DFlash
GLM-4.7-Flash-DFlash
A complete, trained DFlash draft model (~1.1B parameters) that accelerates GLM-4.7-Flash inference via speculative / block-parallel (draft-then-verify) decoding.
What this is
GLM-4.7-Flash-DFlash is a full drafter model trained to predict blocks of future tokens for GLM-4.7-Flash. A DFlash-capable runtime uses it to draft several tokens at once and verify them against GLM-4.7-Flash in a single pass, accelerating generation losslessly β the target model's output distribution is unchanged.
Speculative decoding always runs two models together: a fast drafter (this model) and the
target it accelerates (GLM-4.7-Flash). Both are complete models; pairing them is how the
speedup is obtained. This repo holds the drafter β the full weights (model.safetensors,
~2.1 GB), config, and results below.
Specs
| Architecture | DFlashDraftModel (Qwen3-style) |
| Target / base model | GLM-4.7-Flash (47 layers) |
| Draft block size | 16 tokens/step |
| Draft layers | 8 Β· hidden 2048 Β· 32 heads (4 KV) Β· head_dim 128 Β· intermediate 6144 |
| Parameters | ~1.1B (2.1 GB, bfloat16) |
| Auxiliary hidden states | from target layers [1, 12, 23, 33, 44] |
| Vocab | 154,880 |
| Max positions | 202,752 Β· RoPE ΞΈ = 1e6 |
| Precision | bfloat16 |
Full hyperparameters are in config.json.
Intended use
Load as the drafter in a DFlash / speculative-decoding serving stack alongside GLM-4.7-Flash. The runtime loads both models; this drafter proposes token blocks and GLM-4.7-Flash verifies them, yielding the throughput gains shown below at no cost to output quality.
Method note: decoupling draft width from verification depth
A DFlash-style drafter normally uses a single width k for both the draft pass and the
number of proposals the target verifies. In this work those two knobs are decoupled into
independent, fixed-shape controls:
draft_widthβ the non-causal DFlash draft-query width. Because mask rows attend to one another, a wider draft pass shifts the acceptance profile at early positions.verify_kβ how many of those proposals are actually sent to the target for verification. On a fine-grained MoE target like GLM-4.7-Flash, each verified token is expensive, so this is the real cost driver.
The technique runs the proposer at a wide draft_width, keeps only the first verify_k
proposals, and verifies just that prefix β discarding the tail before it ever enters the
target's KV / sequence state. Draft and verify graphs stay fixed-shape (CUDA-graph
capturable), and target output semantics are preserved (the DeepSpec prediction_shifted row
contract), so the accelerated path is numerically faithful to the target.
Why it helps. A wide draft raises the number of committed tokens at early positions (β3.1 committed through position 4 at width-8, vs β2.1 at width-4), while a short verify avoids paying MoE verification cost on the low-probability tail. The two optima are genuinely different, so tying them together leaves throughput on the table.
Results β vs. vanilla GLM-4.7-Flash
Against plain GLM-4.7-Flash with no speculative decoding, this DFlash drafter delivers roughly 1.3Γ higher generation throughput (β +30%) β about 121 β 157 tokens/s aggregate on 4ΓA100-40GB β while leaving the target model's output distribution unchanged. The speedup holds across every domain and is substantially larger on some (see plot).
Mean per-request output throughput across the full SPEED-Bench qualitative suite (880 prompts, 11 domains). Grey = plain GLM-4.7-Flash (no speculative decoding); DFlash (orange / teal) is faster across every domain. MTP-1 shown for reference.
Against a stronger MTP-1 speculative-decoding baseline the margin is naturally smaller (best DFlash config β 1.16Γ, and β +3% over the matched coupled setting at flat p95 latency) β but against the no-spec vanilla path the gain is large and consistent, which is the comparison that matters when deciding whether to use speculative decoding at all.
The best DFlash configuration is wide draft (8) / short verify (3) β the product of the decoupling described above. The full draft-width Γ verify-depth sweep:
Draft-width Γ verify-depth matrix: acceptance and throughput across configurations. Wide-draft / short-verify (e.g. 8 / 3) sits at the throughput optimum. Gains are workload-dependent, which motivates workload-aware / request-level routing rather than one static setting.
Training
Trained on 4ΓA100-40GB. Draft config: block 16, 8-layer draft (hidden 2048), auxiliary hidden states from target layers [1, 12, 23, 33, 44].
License
Derived from GLM-4.7-Flash β usage is subject to the base model's license. Verify and comply with the upstream terms before use.
- Downloads last month
- 313

