Supersede unsupported legacy artifact
Browse filesPreserve the original card while withdrawing unsupported evaluation and runtime claims. Current work is FinStruct.
- LEGACY_CARD.md +265 -0
- README.md +16 -251
LEGACY_CARD.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: uraionspec
|
| 3 |
+
license: mit
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- speculative-decoding
|
| 9 |
+
- dspark
|
| 10 |
+
- deepseek
|
| 11 |
+
- llm-inference
|
| 12 |
+
- model-optimization
|
| 13 |
+
- transformer
|
| 14 |
+
- pytorch
|
| 15 |
+
- efficient-llm
|
| 16 |
+
- inference-acceleration
|
| 17 |
+
- draft-model
|
| 18 |
+
- torch
|
| 19 |
+
- uraion-labs
|
| 20 |
+
- uraion
|
| 21 |
+
- systems-research
|
| 22 |
+
- icml-2026
|
| 23 |
+
- acceptance-scheduling
|
| 24 |
+
- semi-autoregressive
|
| 25 |
+
- confidence-prediction
|
| 26 |
+
- calibration
|
| 27 |
+
sdk: docker
|
| 28 |
+
sdk_version: "1.0"
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
<p align="center">
|
| 32 |
+
<picture>
|
| 33 |
+
<source media="(prefers-color-scheme: dark)" srcset="https://uraionlabs.com/public/icons/icon-192.png">
|
| 34 |
+
<img src="https://uraionlabs.com/public/icons/icon-192.png" alt="Uraion Labs" width="80" height="80">
|
| 35 |
+
</picture>
|
| 36 |
+
</p>
|
| 37 |
+
|
| 38 |
+
<p align="center">
|
| 39 |
+
<strong style="font-family: 'Instrument Serif', Georgia, serif; font-size: 2rem; color: #F7F4ED; letter-spacing: -0.02em;">
|
| 40 |
+
Uraion Labs
|
| 41 |
+
</strong>
|
| 42 |
+
<br>
|
| 43 |
+
<span style="font-family: 'Inter', sans-serif; font-size: 0.875rem; color: #8A8478;">Foundational systems research.</span>
|
| 44 |
+
</p>
|
| 45 |
+
|
| 46 |
+
<p align="center">
|
| 47 |
+
<strong style="font-family: 'Inter', sans-serif; font-size: 1.15rem; color: #E45A1A;">
|
| 48 |
+
UraionSpec
|
| 49 |
+
</strong>
|
| 50 |
+
<br>
|
| 51 |
+
<span style="font-family: 'Inter', sans-serif; font-size: 0.875rem; color: #8A8478;">
|
| 52 |
+
Faithful DSpark-style Speculative Decoding — modular, runnable, verified.
|
| 53 |
+
</span>
|
| 54 |
+
</p>
|
| 55 |
+
|
| 56 |
+
<p align="center">
|
| 57 |
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"/>
|
| 58 |
+
<img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python"/>
|
| 59 |
+
<img src="https://img.shields.io/badge/pytorch-2.1+-orange.svg" alt="PyTorch"/>
|
| 60 |
+
<img src="https://img.shields.io/badge/build-passing-brightgreen.svg" alt="Build"/>
|
| 61 |
+
<img src="https://img.shields.io/badge/tests-80%20passing-brightgreen.svg" alt="Tests"/>
|
| 62 |
+
</p>
|
| 63 |
+
|
| 64 |
+
---
|
| 65 |
+
|
| 66 |
+
**UraionSpec** is a clean, modular, and runnable implementation of [**DSpark**](https://www.alphaxiv.org/abs/2026.dspark) — Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation — accepted at **ICML 2026**. It faithfully reproduces the core DSpark algorithm while being practical for small-scale experimentation, training, and evaluation.
|
| 67 |
+
|
| 68 |
+
This is **research infrastructure** — not a model checkpoint. It provides the training, evaluation, calibration, and decoding pipeline so you can train and evaluate draft models for speculative decoding on your own target models and data.
|
| 69 |
+
|
| 70 |
+
**Intelligence is a systems problem.** This codebase is one piece of that system.
|
| 71 |
+
|
| 72 |
+
## What is DSpark?
|
| 73 |
+
|
| 74 |
+
DSpark is a state-of-the-art speculative decoding framework from DeepSeek-AI that introduces two key innovations:
|
| 75 |
+
|
| 76 |
+
1. **Semi-Autoregressive Generation** — A parallel backbone handles bulk compute while a lightweight sequential head (Markov or RNN) injects inter-token dependency, combining the speed of parallel drafters with the quality of autoregressive ones.
|
| 77 |
+
2. **Confidence-Scheduled Verification** — A confidence head predicts per-position acceptance probabilities, and a hardware-aware scheduler dynamically tailors the verification length based on prefix survival probabilities and engine throughput profiles. This prevents wasted compute on high-rejection tokens under heavy load.
|
| 78 |
+
|
| 79 |
+
### Architecture
|
| 80 |
+
|
| 81 |
+
```
|
| 82 |
+
UraionSpec/
|
| 83 |
+
├── src/uraionspec/
|
| 84 |
+
│ ├── models/ # DSpark draft model
|
| 85 |
+
│ │ ├── markov_head.py # Low-rank transition bias (r=256)
|
| 86 |
+
│ │ ├── rnn_head.py # GRU-like recurrent sequential head
|
| 87 |
+
│ │ ├── confidence_head.py # Per-position acceptance predictor
|
| 88 |
+
│ │ ├── dflash_backbone.py # DFlash-style backbone with KV injection ⭐
|
| 89 |
+
│ │ └── draft_model.py # Combined parallel backbone + heads
|
| 90 |
+
│ ├── decoding/ # Speculative decoding core
|
| 91 |
+
│ │ ├── acceptance.py # Lossless rejection sampling (min ratio)
|
| 92 |
+
│ │ ├── scheduler.py # Algorithm 1: Hardware-aware prefix scheduler
|
| 93 |
+
│ │ └── speculative.py # Orchestration: draft → verify → accept
|
| 94 |
+
│ ├── training/ # Training pipeline
|
| 95 |
+
│ │ ├── dataset.py # Anchor-block dataset preparation
|
| 96 |
+
│ │ ├── losses.py # CE + TV + Confidence (position-weighted)
|
| 97 |
+
│ │ ├── train_drafter.py # Training loop (frozen target)
|
| 98 |
+
│ │ └── cache_targets.py # Target logit cache generation
|
| 99 |
+
│ ├── calibration/ # Sequential Temperature Scaling
|
| 100 |
+
│ │ └── sts.py # Left-to-right ECE minimization
|
| 101 |
+
│ ├── evaluation/ # Evaluation & benchmarking
|
| 102 |
+
│ │ ├── eval_acceptance.py # Acceptance rate / length metrics
|
| 103 |
+
│ │ └── benchmark_latency.py # Vanilla vs speculative latency
|
| 104 |
+
│ └── utils/ # HF helpers, logging, seeding
|
| 105 |
+
├── scripts/ # Runnable entry points
|
| 106 |
+
│ ├── smoke_train.py
|
| 107 |
+
│ ├── smoke_eval.py
|
| 108 |
+
│ └── run_benchmark.py
|
| 109 |
+
├── tests/ # 80 unit & integration tests
|
| 110 |
+
└── docs/ # Implementation notes, reports
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
## Installation
|
| 114 |
+
|
| 115 |
+
```bash
|
| 116 |
+
# Install directly from HuggingFace
|
| 117 |
+
pip install git+https://huggingface.co/UraionLabs/UraionSpec
|
| 118 |
+
|
| 119 |
+
# Or clone from HuggingFace
|
| 120 |
+
git clone https://huggingface.co/UraionLabs/UraionSpec
|
| 121 |
+
cd UraionSpec
|
| 122 |
+
pip install -e .
|
| 123 |
+
|
| 124 |
+
# With development dependencies (tests, linting)
|
| 125 |
+
pip install -e ".[dev]"
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
## Quick Start
|
| 129 |
+
|
| 130 |
+
### Smoke Training
|
| 131 |
+
Train a DSpark draft model on a tiny dataset to verify end-to-end gradient flow:
|
| 132 |
+
|
| 133 |
+
```bash
|
| 134 |
+
python scripts/smoke_train.py \
|
| 135 |
+
--target Qwen/Qwen2.5-0.5B-Instruct \
|
| 136 |
+
--samples 32 \
|
| 137 |
+
--steps 5 \
|
| 138 |
+
--batch-size 2 \
|
| 139 |
+
--block-size 4
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
### Smoke Evaluation
|
| 143 |
+
Evaluate a trained draft model's acceptance characteristics:
|
| 144 |
+
|
| 145 |
+
```bash
|
| 146 |
+
python scripts/smoke_eval.py \
|
| 147 |
+
--target Qwen/Qwen2.5-0.5B-Instruct \
|
| 148 |
+
--checkpoint /path/to/checkpoint.pt \
|
| 149 |
+
--gamma 7 \
|
| 150 |
+
--steps 5
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
### Benchmark
|
| 154 |
+
Compare speculative decoding against vanilla autoregressive generation:
|
| 155 |
+
|
| 156 |
+
```bash
|
| 157 |
+
python scripts/run_benchmark.py \
|
| 158 |
+
--target Qwen/Qwen2.5-0.5B-Instruct \
|
| 159 |
+
--prompts examples/prompts.jsonl \
|
| 160 |
+
--gamma 7 \
|
| 161 |
+
--steps 10
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
### Run Tests
|
| 165 |
+
```bash
|
| 166 |
+
pytest tests/ -v
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
## Key Components
|
| 170 |
+
|
| 171 |
+
### Markov Sequential Head
|
| 172 |
+
Implements low-rank transition bias `B(x_{k-1}, x_k) = W1[x_{k-1}] @ W2` where `W1 ∈ R^{V×r}`, `W2 ∈ R^{r×V}` (r=256 default). Available as `VanillaMarkov` or `GatedMarkovHead` (modulated by backbone hidden state).
|
| 173 |
+
|
| 174 |
+
### RNN Sequential Head
|
| 175 |
+
GRU-like gated recurrent state across positions:
|
| 176 |
+
```
|
| 177 |
+
s_k = sigmoid(W_g z_k) ⊙ s_{k-1} + (1 - sigmoid(W_g z_k)) ⊙ tanh(W_c z_k)
|
| 178 |
+
```
|
| 179 |
+
where `z_k = [s_{k-1}; W1[x_{k-1}]; h_k]`. Captures full prefix history.
|
| 180 |
+
|
| 181 |
+
### Confidence Head
|
| 182 |
+
Predicts per-position conditional acceptance probability:
|
| 183 |
+
```
|
| 184 |
+
c_k = sigmoid(w^T [h_k; W1[x_{k-1}])
|
| 185 |
+
```
|
| 186 |
+
Supervised by analytical acceptance rate `c*_k = 1 - 0.5 × ||p_d - p_t||_1`.
|
| 187 |
+
|
| 188 |
+
### Hardware-Aware Prefix Scheduler (Algorithm 1)
|
| 189 |
+
Maximizes expected throughput `Θ = τ × SPS(B)` by:
|
| 190 |
+
1. Computing prefix survival probabilities `a_{r,j} = ∏_{i≤j} c_{r,i}`
|
| 191 |
+
2. Globally sorting candidates by `a_{r,j}`
|
| 192 |
+
3. Greedily admitting tokens with early stopping to preserve non-anticipating property
|
| 193 |
+
|
| 194 |
+
### Sequential Temperature Scaling
|
| 195 |
+
Calibrates cumulative confidence products left-to-right via 1D grid search minimizing Expected Calibration Error (ECE) at each position.
|
| 196 |
+
|
| 197 |
+
### Loss Functions (DSpark Eq. 12)
|
| 198 |
+
```
|
| 199 |
+
L = 0.1 × L_ce + 0.9 × L_tv + 1.0 × L_conf
|
| 200 |
+
```
|
| 201 |
+
- `L_ce`: Cross-entropy for next-token prediction
|
| 202 |
+
- `L_tv`: Total variation distance `||p_d - p_t||_1`
|
| 203 |
+
- `L_conf`: Binary cross-entropy on confidence predictions
|
| 204 |
+
|
| 205 |
+
All position-weighted by `w_k = exp(-(k-1)/γ)` emphasizing earlier positions.
|
| 206 |
+
|
| 207 |
+
## Verification
|
| 208 |
+
|
| 209 |
+
| Component | Status |
|
| 210 |
+
|---|---|
|
| 211 |
+
| 80 unit & integration tests | ✅ All passing |
|
| 212 |
+
| DFlash backbone with KV injection | ✅ 17 tests, all shapes & gradients verified |
|
| 213 |
+
| Sampling utilities (residual, GQA) | ✅ 8 tests |
|
| 214 |
+
| Package import | ✅ Clean |
|
| 215 |
+
| Linting (ruff) | ✅ All checks passed |
|
| 216 |
+
| Smoke training (CPU) | ✅ 3 steps, all losses decreasing |
|
| 217 |
+
| Confidence head training | ✅ Supervised by analytical acceptance rate |
|
| 218 |
+
|
| 219 |
+
## Reproducing Paper Results
|
| 220 |
+
|
| 221 |
+
The DSpark paper trains on the full [Open-PerfectBlend](https://huggingface.co/datasets/mlabonne/open-perfectblend) dataset (1.3M samples) across multiple GPUs. For production-scale reproduction, see the official [DeepSpec](https://github.com/deepseek-ai/DeepSpec) repository.
|
| 222 |
+
|
| 223 |
+
For small-scale experimentation:
|
| 224 |
+
```bash
|
| 225 |
+
# Train on Colab A100
|
| 226 |
+
colab run -s uraionspec-train --gpu A100 --keep --timeout 28800 \
|
| 227 |
+
python scripts/smoke_train.py --target Qwen/Qwen3-4B --samples 10000 --steps 1000
|
| 228 |
+
```
|
| 229 |
+
|
| 230 |
+
## Relation to DeepSpec
|
| 231 |
+
|
| 232 |
+
UraionSpec is an independent, faithful implementation of the DSpark algorithm described in the [paper](https://www.alphaxiv.org/abs/2026.dspark) and the [DeepSpec](https://github.com/deepseek-ai/DeepSpec) repository (MIT license). While DeepSpec is a production-grade codebase with multi-GPU training, 38 TB target caches, and vLLM integration, UraionSpec focuses on:
|
| 233 |
+
|
| 234 |
+
- **Clarity** — Modular, documented Python with clean separations
|
| 235 |
+
- **Runability** — Smoke tests that work on a single GPU or CPU
|
| 236 |
+
- **Completeness** — Every algorithm component from the paper is implemented
|
| 237 |
+
|
| 238 |
+
## Current Limitations
|
| 239 |
+
|
| 240 |
+
- **Parallel backbone**: Uses `nn.TransformerEncoder` — not the full DFlash-style backbone with target model KV injection described in Section 3.1 of the paper.
|
| 241 |
+
- **No multi-GPU**: Single-device only.
|
| 242 |
+
- **Synthetic SPS profile**: Uses a default throughput curve — for real systems, profile your engine and pass the table.
|
| 243 |
+
- **No vLLM integration**: For production serving, see DeepSpec's integration.
|
| 244 |
+
|
| 245 |
+
## License
|
| 246 |
+
|
| 247 |
+
MIT License. Built with reference to [DeepSpec](https://github.com/deepseek-ai/DeepSpec) (MIT) and the DSpark paper. Copyright © 2026 Uraion Labs.
|
| 248 |
+
|
| 249 |
+
## Citation
|
| 250 |
+
|
| 251 |
+
```bibtex
|
| 252 |
+
@software{uraionspec2026,
|
| 253 |
+
author = {Uraion Labs},
|
| 254 |
+
title = {UraionSpec: Faithful DSpark-style Speculative Decoding},
|
| 255 |
+
year = {2026},
|
| 256 |
+
url = {https://huggingface.co/UraionLabs/UraionSpec}
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
@article{cheng2026dspark,
|
| 260 |
+
title={DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation},
|
| 261 |
+
author={Cheng, Xin and Yu, Xingkai and Shao, Chenze and Li, Jiashi and Xiong, Yunfan and others},
|
| 262 |
+
journal={ICML},
|
| 263 |
+
year={2026}
|
| 264 |
+
}
|
| 265 |
+
```
|
README.md
CHANGED
|
@@ -3,263 +3,28 @@ library_name: uraionspec
|
|
| 3 |
license: mit
|
| 4 |
language:
|
| 5 |
- en
|
| 6 |
-
pipeline_tag: text-generation
|
| 7 |
tags:
|
|
|
|
|
|
|
|
|
|
| 8 |
- speculative-decoding
|
| 9 |
- dspark
|
| 10 |
-
- deepseek
|
| 11 |
-
- llm-inference
|
| 12 |
-
- model-optimization
|
| 13 |
-
- transformer
|
| 14 |
-
- pytorch
|
| 15 |
-
- efficient-llm
|
| 16 |
-
- inference-acceleration
|
| 17 |
-
- draft-model
|
| 18 |
-
- torch
|
| 19 |
-
- uraion-labs
|
| 20 |
-
- uraion
|
| 21 |
-
- systems-research
|
| 22 |
-
- icml-2026
|
| 23 |
-
- acceptance-scheduling
|
| 24 |
-
- semi-autoregressive
|
| 25 |
-
- confidence-prediction
|
| 26 |
-
- calibration
|
| 27 |
-
sdk: docker
|
| 28 |
-
sdk_version: "1.0"
|
| 29 |
---
|
| 30 |
|
| 31 |
-
|
| 32 |
-
<picture>
|
| 33 |
-
<source media="(prefers-color-scheme: dark)" srcset="https://uraionlabs.com/public/icons/icon-192.png">
|
| 34 |
-
<img src="https://uraionlabs.com/public/icons/icon-192.png" alt="Uraion Labs" width="80" height="80">
|
| 35 |
-
</picture>
|
| 36 |
-
</p>
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
Uraion Labs
|
| 41 |
-
</strong>
|
| 42 |
-
<br>
|
| 43 |
-
<span style="font-family: 'Inter', sans-serif; font-size: 0.875rem; color: #8A8478;">Foundational systems research.</span>
|
| 44 |
-
</p>
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
<br>
|
| 51 |
-
<span style="font-family: 'Inter', sans-serif; font-size: 0.875rem; color: #8A8478;">
|
| 52 |
-
Faithful DSpark-style Speculative Decoding — modular, runnable, verified.
|
| 53 |
-
</span>
|
| 54 |
-
</p>
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
<img src="https://img.shields.io/badge/pytorch-2.1+-orange.svg" alt="PyTorch"/>
|
| 60 |
-
<img src="https://img.shields.io/badge/build-passing-brightgreen.svg" alt="Build"/>
|
| 61 |
-
<img src="https://img.shields.io/badge/tests-80%20passing-brightgreen.svg" alt="Tests"/>
|
| 62 |
-
</p>
|
| 63 |
|
| 64 |
-
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
This is **research infrastructure** — not a model checkpoint. It provides the training, evaluation, calibration, and decoding pipeline so you can train and evaluate draft models for speculative decoding on your own target models and data.
|
| 69 |
-
|
| 70 |
-
**Intelligence is a systems problem.** This codebase is one piece of that system.
|
| 71 |
-
|
| 72 |
-
## What is DSpark?
|
| 73 |
-
|
| 74 |
-
DSpark is a state-of-the-art speculative decoding framework from DeepSeek-AI that introduces two key innovations:
|
| 75 |
-
|
| 76 |
-
1. **Semi-Autoregressive Generation** — A parallel backbone handles bulk compute while a lightweight sequential head (Markov or RNN) injects inter-token dependency, combining the speed of parallel drafters with the quality of autoregressive ones.
|
| 77 |
-
2. **Confidence-Scheduled Verification** — A confidence head predicts per-position acceptance probabilities, and a hardware-aware scheduler dynamically tailors the verification length based on prefix survival probabilities and engine throughput profiles. This prevents wasted compute on high-rejection tokens under heavy load.
|
| 78 |
-
|
| 79 |
-
### Architecture
|
| 80 |
-
|
| 81 |
-
```
|
| 82 |
-
UraionSpec/
|
| 83 |
-
├── src/uraionspec/
|
| 84 |
-
│ ├── models/ # DSpark draft model
|
| 85 |
-
│ │ ├── markov_head.py # Low-rank transition bias (r=256)
|
| 86 |
-
│ │ ├── rnn_head.py # GRU-like recurrent sequential head
|
| 87 |
-
│ │ ├── confidence_head.py # Per-position acceptance predictor
|
| 88 |
-
│ │ ├── dflash_backbone.py # DFlash-style backbone with KV injection ⭐
|
| 89 |
-
│ │ └── draft_model.py # Combined parallel backbone + heads
|
| 90 |
-
│ ├── decoding/ # Speculative decoding core
|
| 91 |
-
│ │ ├── acceptance.py # Lossless rejection sampling (min ratio)
|
| 92 |
-
│ │ ├── scheduler.py # Algorithm 1: Hardware-aware prefix scheduler
|
| 93 |
-
│ │ └── speculative.py # Orchestration: draft → verify → accept
|
| 94 |
-
│ ├── training/ # Training pipeline
|
| 95 |
-
│ │ ├── dataset.py # Anchor-block dataset preparation
|
| 96 |
-
│ │ ├── losses.py # CE + TV + Confidence (position-weighted)
|
| 97 |
-
│ │ ├── train_drafter.py # Training loop (frozen target)
|
| 98 |
-
│ │ └── cache_targets.py # Target logit cache generation
|
| 99 |
-
│ ├── calibration/ # Sequential Temperature Scaling
|
| 100 |
-
│ │ └── sts.py # Left-to-right ECE minimization
|
| 101 |
-
│ ├── evaluation/ # Evaluation & benchmarking
|
| 102 |
-
│ │ ├── eval_acceptance.py # Acceptance rate / length metrics
|
| 103 |
-
│ │ └── benchmark_latency.py # Vanilla vs speculative latency
|
| 104 |
-
│ └── utils/ # HF helpers, logging, seeding
|
| 105 |
-
├── scripts/ # Runnable entry points
|
| 106 |
-
│ ├── smoke_train.py
|
| 107 |
-
│ ├── smoke_eval.py
|
| 108 |
-
│ └── run_benchmark.py
|
| 109 |
-
├── tests/ # 80 unit & integration tests
|
| 110 |
-
└── docs/ # Implementation notes, reports
|
| 111 |
-
```
|
| 112 |
-
|
| 113 |
-
## Installation
|
| 114 |
-
|
| 115 |
-
```bash
|
| 116 |
-
# Install directly from HuggingFace
|
| 117 |
-
pip install git+https://huggingface.co/UraionLabs/UraionSpec
|
| 118 |
-
|
| 119 |
-
# Or clone from HuggingFace
|
| 120 |
-
git clone https://huggingface.co/UraionLabs/UraionSpec
|
| 121 |
-
cd UraionSpec
|
| 122 |
-
pip install -e .
|
| 123 |
-
|
| 124 |
-
# With development dependencies (tests, linting)
|
| 125 |
-
pip install -e ".[dev]"
|
| 126 |
-
```
|
| 127 |
-
|
| 128 |
-
## Quick Start
|
| 129 |
-
|
| 130 |
-
### Smoke Training
|
| 131 |
-
Train a DSpark draft model on a tiny dataset to verify end-to-end gradient flow:
|
| 132 |
-
|
| 133 |
-
```bash
|
| 134 |
-
python scripts/smoke_train.py \
|
| 135 |
-
--target Qwen/Qwen2.5-0.5B-Instruct \
|
| 136 |
-
--samples 32 \
|
| 137 |
-
--steps 5 \
|
| 138 |
-
--batch-size 2 \
|
| 139 |
-
--block-size 4
|
| 140 |
-
```
|
| 141 |
-
|
| 142 |
-
### Smoke Evaluation
|
| 143 |
-
Evaluate a trained draft model's acceptance characteristics:
|
| 144 |
-
|
| 145 |
-
```bash
|
| 146 |
-
python scripts/smoke_eval.py \
|
| 147 |
-
--target Qwen/Qwen2.5-0.5B-Instruct \
|
| 148 |
-
--checkpoint /path/to/checkpoint.pt \
|
| 149 |
-
--gamma 7 \
|
| 150 |
-
--steps 5
|
| 151 |
-
```
|
| 152 |
-
|
| 153 |
-
### Benchmark
|
| 154 |
-
Compare speculative decoding against vanilla autoregressive generation:
|
| 155 |
-
|
| 156 |
-
```bash
|
| 157 |
-
python scripts/run_benchmark.py \
|
| 158 |
-
--target Qwen/Qwen2.5-0.5B-Instruct \
|
| 159 |
-
--prompts examples/prompts.jsonl \
|
| 160 |
-
--gamma 7 \
|
| 161 |
-
--steps 10
|
| 162 |
-
```
|
| 163 |
-
|
| 164 |
-
### Run Tests
|
| 165 |
-
```bash
|
| 166 |
-
pytest tests/ -v
|
| 167 |
-
```
|
| 168 |
-
|
| 169 |
-
## Key Components
|
| 170 |
-
|
| 171 |
-
### Markov Sequential Head
|
| 172 |
-
Implements low-rank transition bias `B(x_{k-1}, x_k) = W1[x_{k-1}] @ W2` where `W1 ∈ R^{V×r}`, `W2 ∈ R^{r×V}` (r=256 default). Available as `VanillaMarkov` or `GatedMarkovHead` (modulated by backbone hidden state).
|
| 173 |
-
|
| 174 |
-
### RNN Sequential Head
|
| 175 |
-
GRU-like gated recurrent state across positions:
|
| 176 |
-
```
|
| 177 |
-
s_k = sigmoid(W_g z_k) ⊙ s_{k-1} + (1 - sigmoid(W_g z_k)) ⊙ tanh(W_c z_k)
|
| 178 |
-
```
|
| 179 |
-
where `z_k = [s_{k-1}; W1[x_{k-1}]; h_k]`. Captures full prefix history.
|
| 180 |
-
|
| 181 |
-
### Confidence Head
|
| 182 |
-
Predicts per-position conditional acceptance probability:
|
| 183 |
-
```
|
| 184 |
-
c_k = sigmoid(w^T [h_k; W1[x_{k-1}])
|
| 185 |
-
```
|
| 186 |
-
Supervised by analytical acceptance rate `c*_k = 1 - 0.5 × ||p_d - p_t||_1`.
|
| 187 |
-
|
| 188 |
-
### Hardware-Aware Prefix Scheduler (Algorithm 1)
|
| 189 |
-
Maximizes expected throughput `Θ = τ × SPS(B)` by:
|
| 190 |
-
1. Computing prefix survival probabilities `a_{r,j} = ∏_{i≤j} c_{r,i}`
|
| 191 |
-
2. Globally sorting candidates by `a_{r,j}`
|
| 192 |
-
3. Greedily admitting tokens with early stopping to preserve non-anticipating property
|
| 193 |
-
|
| 194 |
-
### Sequential Temperature Scaling
|
| 195 |
-
Calibrates cumulative confidence products left-to-right via 1D grid search minimizing Expected Calibration Error (ECE) at each position.
|
| 196 |
-
|
| 197 |
-
### Loss Functions (DSpark Eq. 12)
|
| 198 |
-
```
|
| 199 |
-
L = 0.1 × L_ce + 0.9 × L_tv + 1.0 × L_conf
|
| 200 |
-
```
|
| 201 |
-
- `L_ce`: Cross-entropy for next-token prediction
|
| 202 |
-
- `L_tv`: Total variation distance `||p_d - p_t||_1`
|
| 203 |
-
- `L_conf`: Binary cross-entropy on confidence predictions
|
| 204 |
-
|
| 205 |
-
All position-weighted by `w_k = exp(-(k-1)/γ)` emphasizing earlier positions.
|
| 206 |
-
|
| 207 |
-
## Verification
|
| 208 |
-
|
| 209 |
-
| Component | Status |
|
| 210 |
-
|---|---|
|
| 211 |
-
| 80 unit & integration tests | ✅ All passing |
|
| 212 |
-
| DFlash backbone with KV injection | ✅ 17 tests, all shapes & gradients verified |
|
| 213 |
-
| Sampling utilities (residual, GQA) | ✅ 8 tests |
|
| 214 |
-
| Package import | ✅ Clean |
|
| 215 |
-
| Linting (ruff) | ✅ All checks passed |
|
| 216 |
-
| Smoke training (CPU) | ✅ 3 steps, all losses decreasing |
|
| 217 |
-
| Confidence head training | ✅ Supervised by analytical acceptance rate |
|
| 218 |
-
|
| 219 |
-
## Reproducing Paper Results
|
| 220 |
-
|
| 221 |
-
The DSpark paper trains on the full [Open-PerfectBlend](https://huggingface.co/datasets/mlabonne/open-perfectblend) dataset (1.3M samples) across multiple GPUs. For production-scale reproduction, see the official [DeepSpec](https://github.com/deepseek-ai/DeepSpec) repository.
|
| 222 |
-
|
| 223 |
-
For small-scale experimentation:
|
| 224 |
-
```bash
|
| 225 |
-
# Train on Colab A100
|
| 226 |
-
colab run -s uraionspec-train --gpu A100 --keep --timeout 28800 \
|
| 227 |
-
python scripts/smoke_train.py --target Qwen/Qwen3-4B --samples 10000 --steps 1000
|
| 228 |
-
```
|
| 229 |
-
|
| 230 |
-
## Relation to DeepSpec
|
| 231 |
-
|
| 232 |
-
UraionSpec is an independent, faithful implementation of the DSpark algorithm described in the [paper](https://www.alphaxiv.org/abs/2026.dspark) and the [DeepSpec](https://github.com/deepseek-ai/DeepSpec) repository (MIT license). While DeepSpec is a production-grade codebase with multi-GPU training, 38 TB target caches, and vLLM integration, UraionSpec focuses on:
|
| 233 |
-
|
| 234 |
-
- **Clarity** — Modular, documented Python with clean separations
|
| 235 |
-
- **Runability** — Smoke tests that work on a single GPU or CPU
|
| 236 |
-
- **Completeness** — Every algorithm component from the paper is implemented
|
| 237 |
-
|
| 238 |
-
## Current Limitations
|
| 239 |
-
|
| 240 |
-
- **Parallel backbone**: Uses `nn.TransformerEncoder` — not the full DFlash-style backbone with target model KV injection described in Section 3.1 of the paper.
|
| 241 |
-
- **No multi-GPU**: Single-device only.
|
| 242 |
-
- **Synthetic SPS profile**: Uses a default throughput curve — for real systems, profile your engine and pass the table.
|
| 243 |
-
- **No vLLM integration**: For production serving, see DeepSpec's integration.
|
| 244 |
-
|
| 245 |
-
## License
|
| 246 |
-
|
| 247 |
-
MIT License. Built with reference to [DeepSpec](https://github.com/deepseek-ai/DeepSpec) (MIT) and the DSpark paper. Copyright © 2026 Uraion Labs.
|
| 248 |
-
|
| 249 |
-
## Citation
|
| 250 |
-
|
| 251 |
-
```bibtex
|
| 252 |
-
@software{uraionspec2026,
|
| 253 |
-
author = {Uraion Labs},
|
| 254 |
-
title = {UraionSpec: Faithful DSpark-style Speculative Decoding},
|
| 255 |
-
year = {2026},
|
| 256 |
-
url = {https://huggingface.co/UraionLabs/UraionSpec}
|
| 257 |
-
}
|
| 258 |
-
|
| 259 |
-
@article{cheng2026dspark,
|
| 260 |
-
title={DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation},
|
| 261 |
-
author={Cheng, Xin and Yu, Xingkai and Shao, Chenze and Li, Jiashi and Xiong, Yunfan and others},
|
| 262 |
-
journal={ICML},
|
| 263 |
-
year={2026}
|
| 264 |
-
}
|
| 265 |
-
```
|
|
|
|
| 3 |
license: mit
|
| 4 |
language:
|
| 5 |
- en
|
|
|
|
| 6 |
tags:
|
| 7 |
+
- legacy
|
| 8 |
+
- unsupported
|
| 9 |
+
- research-code
|
| 10 |
- speculative-decoding
|
| 11 |
- dspark
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Legacy research code — no model or speedup result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
**Status as of 2026-07-27:** this repository is retained as historical research code. It is not a
|
| 17 |
+
model checkpoint, is not an active Uraion Labs product, and is disconnected from FinStruct.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
The repository's own reproduction report records 80/80 unit tests, but it also states that target
|
| 20 |
+
model smoke training was blocked, GPU smoke evaluation was not run, and no meaningful speculative
|
| 21 |
+
latency benchmark was produced. It uses a simplified `nn.TransformerEncoder` rather than the full
|
| 22 |
+
paper backbone, a synthetic throughput profile, no multi-GPU path, and no vLLM integration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
Accordingly, prior wording such as “faithful,” “verified,” or “runnable” must not be read as a paper
|
| 25 |
+
reproduction, trained checkpoint, latency improvement, or production claim. The full pre-audit card
|
| 26 |
+
is preserved in [`LEGACY_CARD.md`](LEGACY_CARD.md).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
Current Uraion Labs work is [FinStruct](https://github.com/arnavprabhu/uraion-finstruct): auditable,
|
| 29 |
+
local-first structured intelligence from financial documents. See
|
| 30 |
+
[uraionlabs.com](https://uraionlabs.com).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|