EAGLE-3.1 spec-decode head for Chandra-2 (1.36x single-stream, lossless)
Browse files- README.md +58 -0
- config.json +35 -0
- model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: datalab-to/chandra-ocr-2
|
| 4 |
+
tags:
|
| 5 |
+
- speculative-decoding
|
| 6 |
+
- eagle
|
| 7 |
+
- eagle3
|
| 8 |
+
- ocr
|
| 9 |
+
- vllm
|
| 10 |
+
library_name: vllm
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# joecr-chandra-2-eagle3.1
|
| 14 |
+
|
| 15 |
+
An **EAGLE‑3.1 speculative‑decoding draft head** for [`datalab-to/chandra-ocr-2`](https://huggingface.co/datalab-to/chandra-ocr-2) (a 5B Qwen3.5‑based vision‑language OCR model). Drop it into vLLM as the speculator to accelerate single‑stream (latency‑bound) OCR decoding **losslessly** — every drafted token is verified by the target, so output quality is preserved.
|
| 16 |
+
|
| 17 |
+
## Results
|
| 18 |
+
|
| 19 |
+
Measured in vLLM on olmOCR‑bench pages (single‑stream, greedy, CUDA graphs, RTX 3090 Ti @ 450 W):
|
| 20 |
+
|
| 21 |
+
| | tok/s | speedup |
|
| 22 |
+
|---|---|---|
|
| 23 |
+
| baseline (no spec) | 84.1 | 1.0× |
|
| 24 |
+
| **+ this head (num_spec=5)** | **114.3** | **1.36×** |
|
| 25 |
+
|
| 26 |
+
Mean accepted length ≈ 2.0–2.5; per‑position acceptance ≈ [0.58, 0.37, 0.25, 0.20, 0.12]. Quality: median char‑similarity vs baseline 0.9991 (differences confined to bbox‑pixel jitter / equivalent figure captions — i.e. bf16 greedy non‑determinism, not degradation).
|
| 27 |
+
|
| 28 |
+
## Architecture
|
| 29 |
+
|
| 30 |
+
EAGLE‑3.1 (single decoder layer) over Chandra‑2's Qwen3.5 text backbone:
|
| 31 |
+
- `hidden_size` 2560, `head_dim` 256, GQA 16/4 — matched to the target.
|
| 32 |
+
- **EAGLE 3.1**: `fc_norm` (per‑aux‑layer RMSNorm) + `norm_output` (post‑norm recurrence) — fixes attention drift, holds acceptance at depth.
|
| 33 |
+
- **Vocab pruning**: `draft_vocab_size` 32768 (from 248320; 99.99% token coverage) → ~7.6× smaller lm_head, cheaper draft forward. `d2t` buffer maps pruned ids back to the full vocab.
|
| 34 |
+
- Aux hidden states captured from the target's **full‑attention** layers `[3, 15, 27]` (Chandra‑2 is a hybrid 3:1 linear/full‑attention model).
|
| 35 |
+
|
| 36 |
+
## Usage (vLLM)
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
from vllm import LLM
|
| 40 |
+
llm = LLM(
|
| 41 |
+
model="datalab-to/chandra-ocr-2",
|
| 42 |
+
speculative_config={
|
| 43 |
+
"model": "jbarrow/joecr-chandra-2-eagle3.1",
|
| 44 |
+
"method": "eagle3",
|
| 45 |
+
"num_speculative_tokens": 5,
|
| 46 |
+
},
|
| 47 |
+
limit_mm_per_prompt={"image": 1},
|
| 48 |
+
)
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Use the Chandra `ocr_layout` prompt in the user turn (image + instruction). Spec‑decode helps most at **low concurrency**; at high batch the GPU saturates and a smaller `num_speculative_tokens` (1–2) is usually better.
|
| 52 |
+
|
| 53 |
+
## Training
|
| 54 |
+
|
| 55 |
+
- **On‑policy data**: Chandra‑2's own HTML‑with‑layout OCR over ~11k document pages.
|
| 56 |
+
- **Features**: hidden states extracted offline from the frozen 5B target (decoupled from draft training so it fits 24 GB and trains with true DDP gradient sharing).
|
| 57 |
+
- **Objective**: forward‑KL distillation with TTT (length 7), trained in vLLM's EAGLE input‑shift convention so it serves correctly.
|
| 58 |
+
- 4× RTX 3090 Ti, DDP, ~8k steps.
|
config.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Eagle3LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"model_type": "llama",
|
| 6 |
+
"num_hidden_layers": 1,
|
| 7 |
+
"hidden_size": 2560,
|
| 8 |
+
"intermediate_size": 9216,
|
| 9 |
+
"num_attention_heads": 16,
|
| 10 |
+
"num_key_value_heads": 4,
|
| 11 |
+
"head_dim": 256,
|
| 12 |
+
"hidden_act": "silu",
|
| 13 |
+
"rms_norm_eps": 1e-06,
|
| 14 |
+
"rope_theta": 10000000,
|
| 15 |
+
"rope_scaling": null,
|
| 16 |
+
"max_position_embeddings": 32768,
|
| 17 |
+
"attention_bias": false,
|
| 18 |
+
"attention_dropout": 0.0,
|
| 19 |
+
"initializer_range": 0.02,
|
| 20 |
+
"bos_token_id": 248043,
|
| 21 |
+
"eos_token_id": 248044,
|
| 22 |
+
"tie_word_embeddings": false,
|
| 23 |
+
"torch_dtype": "bfloat16",
|
| 24 |
+
"use_cache": true,
|
| 25 |
+
"vocab_size": 248320,
|
| 26 |
+
"draft_vocab_size": 32768,
|
| 27 |
+
"fc_norm": true,
|
| 28 |
+
"norm_output": true,
|
| 29 |
+
"eagle_aux_hidden_state_layer_ids": [
|
| 30 |
+
3,
|
| 31 |
+
15,
|
| 32 |
+
27
|
| 33 |
+
],
|
| 34 |
+
"target_hidden_size": 2560
|
| 35 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6beeccb1b3359cc516f491a1e556f528201ba5bad92ce220e3cb5193ec425883
|
| 3 |
+
size 1704235808
|