beomi commited on
Commit
4d4e6fa
·
verified ·
1 Parent(s): 2a85754

Release DFlash2 agentic drafter (step 9750)

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/agent_speed.png filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model: zai-org/GLM-5.3-Flash
4
+ language:
5
+ - en
6
+ - ko
7
+ tags:
8
+ - speculative-decoding
9
+ - dflash
10
+ - dflash2
11
+ - draft-model
12
+ - glm
13
+ - agent
14
+ - coding
15
+ - sglang
16
+ ---
17
+
18
+ # GLM-5.3-Flash-DFlash2-Agentic
19
+
20
+ A DFlash2 speculative decoding draft model for [GLM-5.3-Flash](https://huggingface.co/zai-org/GLM-5.3-Flash), trained exclusively on **English and Korean agentic coding trajectories**. All training data was generated by GLM-5.3-Flash itself while driving Claude Code, Codex, and OpenCode to resolve real GitHub issues.
21
+
22
+ Because speculative decoding is lossless—the target model verifies every drafted token—output quality is identical to running the target model directly. The drafter only accelerates generation.
23
+
24
+ - **Use case**: Serving GLM-5.3-Flash behind coding agents (Claude Code, Codex, OpenCode, and similar tool-calling harnesses) in English or Korean.
25
+ - **Architecture**: Identical to [incoai/GLM-5.3-Flash-DFlash2](https://huggingface.co/incoai/GLM-5.3-Flash-DFlash2)—a 5-layer non-causal block drafter (1.17B trainable parameters) that reads five target hidden layers and shares the target model's frozen token embeddings and LM head. It serves as a drop-in replacement for SGLang's `DFLASH` speculative decoding algorithm.
26
+ - **Results**: Across live agent sessions on held-out repositories unseen during training, median per-turn decode throughput reaches **291 tok/s (2.31× over non-speculative decoding)**, outperforming both the general-purpose DFlash2 drafter (248 tok/s, 1.97×) and the built-in MTP head (239 tok/s, 1.89×), with equally strong performance in English and Korean.
27
+
28
+ ## Quick start (SGLang)
29
+
30
+ Tested with SGLang 0.5.21 on 2× NVIDIA B200 GPUs using the FP8 target model:
31
+
32
+ ```bash
33
+ python -m sglang.launch_server \
34
+ --model-path zai-org/GLM-5.3-Flash \
35
+ --tp-size 2 --trust-remote-code \
36
+ --context-length 262144 --mem-fraction-static 0.93 \
37
+ --tool-call-parser glm47 --reasoning-parser glm45 \
38
+ --speculative-algorithm DFLASH \
39
+ --speculative-draft-model-path lablup/GLM-5.3-Flash-DFlash2-Agentic \
40
+ --speculative-draft-attention-backend fa4
41
+ ```
42
+
43
+ ## Performance in live agent workflows
44
+
45
+ ![Decode speed in live agent workflows](assets/agent_speed.png)
46
+
47
+ | Model | Overall | EN | KO | Claude Code | Codex | OpenCode | Solo turns | Accept len |
48
+ |:--|--:|--:|--:|--:|--:|--:|--:|--:|
49
+ | **DFlash2 (this model)** | **291 (2.31×)** | **284 (2.29×)** | **297 (2.31×)** | **271 (2.17×)** | **309 (2.40×)** | **297 (2.38×)** | **353 (2.21×)** | **4.80** |
50
+ | DFlash2 (incoai) | 248 (1.97×) | 259 (2.08×) | 240 (1.86×) | 264 (2.11×) | 223 (1.73×) | 252 (2.03×) | 288 (1.81×) | 4.28 |
51
+ | MTP (SGLang EAGLE, 5 steps) | 239 (1.89×) | 238 (1.91×) | 240 (1.87×) | 224 (1.79×) | 229 (1.78×) | 264 (2.12×) | 281 (1.76×) | 4.09 |
52
+ | No speculation | 126 | 124 | 129 | 125 | 129 | 124 | 159 | – |
53
+
54
+ Throughput values show the median per-turn decode speed (in tok/s) across all requests generating at least 16 output tokens. Values in parentheses indicate the speedup relative to non-speculative decoding in the same column.
55
+
56
+ ### Evaluation setup
57
+
58
+ - **Tasks & sessions**: Live end-to-end agent sessions rather than static prompt replays. We evaluated 54 GitHub issues drawn from 16 of the 23 held-out repositories across 3 harnesses (Claude Code, Codex, OpenCode) × 2 languages (English, Korean) × 9 programming language groups, using a mix of reasoning effort levels (`low`, `high`, `max`).
59
+ - **Execution**: Each harness worked to resolve the issue from a fresh repository checkout, running 4 concurrent sessions at a time with a 30-minute timeout per session. All four serving configurations were evaluated on the exact same set of issues.
60
+ - **Serving environment**: GLM-5.3-Flash (FP8) on SGLang 0.5.21 with TP2 across 2× B200 GPUs (`--max-running-requests 16 --chunked-prefill-size 4096`).
61
+ - **MTP**: `--speculative-algorithm EAGLE --speculative-num-steps 5 --speculative-eagle-topk 1 --speculative-num-draft-tokens 6` (the fastest MTP configuration we found for this workload).
62
+ - **DFlash2 drafters**: `--speculative-draft-attention-backend fa4`.
63
+ - **Metrics**:
64
+ - *Decode speed*: Calculated per request as `(completion_tokens − 1) / (end_to_end_latency − ttft)` from SGLang's request logs.
65
+ - *Accept len*: SGLang's `spec_accept_length` (the average number of tokens accepted per verification step), averaged across requests.
66
+ - *Solo turns*: Requests that executed while no other concurrent requests were in flight.
67
+ - **Exclusions**: Two sessions entered degenerate tool-call loops (one with this model and one with `incoai`) and were excluded across all configurations, leaving 52 valid sessions.
68
+ - **Run conditions**: This model was evaluated in a separate pass on the same hardware and issue set as the other three configurations. Because live agent harnesses use non-zero sampling temperatures, exact trajectories vary naturally from run to run.
69
+
70
+ ## Training data
71
+
72
+ All training data was collected by running live coding agents backed by GLM-5.3-Flash. The drafter is trained strictly on tokens generated by the target model under the exact prompt contexts the target model saw during execution.
73
+
74
+ | Metric | Value |
75
+ |:--|--:|
76
+ | GitHub repositories | 977 (across 31 programming languages) |
77
+ | Agent sessions (with logged requests) | 50,268 |
78
+ | Target-model requests | 2,178,249 |
79
+ | Training samples | 80,299 |
80
+ | Total context tokens in samples | 2.58B |
81
+ | Supervised (loss) tokens | 0.611B |
82
+ | Maximum sample length | 262,144 tokens |
83
+
84
+ - **Repositories**: Selected from 1,000 popular GitHub repositories ranked by star count with per-language quotas. The largest language groups are Python (128), TypeScript (106), JavaScript (76), Go (74), Rust (73), Java (60), C++ (59), C (40), C# (40), Ruby (30), Kotlin (29), and PHP (29).
85
+ - **Train / eval split**: 23 repositories (~2%, selected deterministically by hashing the repository name) were held out completely for evaluation. Per-repository sample counts for the 977 training repositories are listed in [`training_repos.json`](training_repos.json), and overall dataset statistics along with the held-out repository list are available in [`data_summary.json`](data_summary.json).
86
+ - **Tasks**: Up to 100 closed issues per repository that were originally resolved by a merged pull request. For each task, the repository was checked out at the commit corresponding to when the issue was filed.
87
+ - **Bilingual sessions**: Each issue was run twice—once with the original English prompt and once with a Korean translation produced by GLM-5.3-Flash (preserving code blocks, logs, and identifiers verbatim). The agent harness (Claude Code, Codex, or OpenCode) and reasoning effort (`low`, `high`, or `max`) were sampled per session.
88
+ - **Data collection**: Each session ran the unmodified agent harness binary inside an isolated git worktree against an SGLang server (TP4, 90-minute timeout). Every completed inference request was logged along with its exact rendered prompt and generated token IDs.
89
+ - **Sample construction**: Consecutive requests whose prompts extend earlier turns are merged into a single multi-turn context chain (one training sample per chain). Training loss is computed only over the target model's generated tokens where they appear verbatim in the final context; re-rendered conversation history receives zero loss.
90
+
91
+ ### Target-model token breakdown (GLM-5.3-Flash)
92
+
93
+ Tokens processed and generated by GLM-5.3-Flash across all training sessions:
94
+
95
+ | Split | Sessions | Requests | Input tokens | Output tokens | Samples | Supervised tokens |
96
+ |:--|--:|--:|--:|--:|--:|--:|
97
+ | **Total** | 50,268 | 2,178,249 | 91.90B | 610.95M | 80,299 | 610.56M |
98
+ | English | 25,151 | 1,073,677 | 45.03B | 294.29M | 40,103 | 293.90M |
99
+ | Korean | 25,117 | 1,104,572 | 46.87B | 316.66M | 39,994 | 316.20M |
100
+ | Claude Code | 16,757 | 799,868 | 34.94B | 278.35M | 39,029 | 277.79M |
101
+ | Codex | 16,682 | 695,268 | 29.34B | 145.45M | 16,999 | 145.44M |
102
+ | OpenCode | 16,829 | 683,113 | 27.61B | 187.15M | 24,069 | 186.87M |
103
+ | Effort: low | 16,699 | 548,492 | 17.65B | 105.75M | 20,424 | 105.56M |
104
+ | Effort: high | 16,736 | 739,352 | 30.20B | 186.05M | 24,981 | 185.76M |
105
+ | Effort: max | 16,833 | 890,405 | 44.05B | 319.15M | 34,692 | 318.78M |
106
+
107
+ - **Input tokens** reflect the full prompt length of every request, including prefix-cached tokens. Because agents resend the accumulating conversation history on each turn, total input tokens across requests are roughly 35× the 2.58B unique context tokens stored in the deduplicated training samples.
108
+ - **Output tokens** cover all tokens generated by GLM-5.3-Flash—including reasoning traces, tool calls, and code—nearly all of which (99.9%) are preserved as supervised training tokens.
109
+
110
+ ## Training details
111
+
112
+ **Framework**: [SpecForge](https://github.com/sgl-project/SpecForge) (commit `53398a8`), using the DFlash training strategy and DFlash2 draft architecture in disaggregated online mode.
113
+
114
+ - A patched SGLang 0.5.21 server runs the frozen FP8 target model (TP2) to extract target hidden states on the fly for each training sample.
115
+ - Extracted hidden states are streamed directly to a 2-rank FSDP trainer over a [Mooncake](https://github.com/kvcache-ai/Mooncake) store.
116
+ - Because hidden states are never materialized to disk, training directly on full 262K-token contexts remains practical.
117
+ - Training ran on a single node equipped with 4× NVIDIA B200 GPUs using PyTorch 2.11 and Transformers 5.13.
118
+
119
+ | Hyperparameter | Value |
120
+ |:--|:--|
121
+ | Optimizer | AdamW |
122
+ | Peak learning rate | 6e-4 |
123
+ | LR schedule | Cosine decay with 4% warmup |
124
+ | Gradient clipping | 1.0 |
125
+ | Feature capture | Online (re-captured every pass with freshly sampled anchors) |
126
+ | Effective batch size | 16 samples / step (2 ranks × 1 sample × 8 grad accum) |
127
+ | Tokens per step | ~1M context tokens (≤16K anchor blocks) |
128
+ | Anchors per sample | 1,024 |
129
+ | Max sample length | 262,144 tokens |
130
+ | Draft loss | DFlash loss with position decay γ = 7 |
131
+ | DFlash2 selector loss | Weight α = 1.0 (0.5% warmup, 1% ramp), strict top-k |
132
+ | Attention backend | FlexAttention |
133
+ | Precision | BF16 drafter, FP8 target |
134
+ | Sharding strategy | FSDP `SHARD_GRAD_OP` |
135
+ | Random seed | 42 |
136
+
137
+ **Released checkpoint**: Step 9,750. Average training metrics over steps 9,560–9,750:
138
+
139
+ - **Training cross-entropy**: 1.88
140
+ - **Greedy accepted length (per 8-token block)**: 4.50
141
+ - **Selector accepted length**: 4.68
142
+
143
+ ## DFlash2 architecture & configuration
144
+
145
+ | Parameter | Value |
146
+ |:--|:--|
147
+ | Target model | GLM-5.3-Flash (320B total / 18B active MoE, 45 layers, hidden size 4096, vocab size 154,880) |
148
+ | Draft layers | 5 non-causal layers with sliding-window attention (window size 2048) |
149
+ | Hidden / FFN dimension | 4096 / 12288 |
150
+ | Attention heads / KV heads / head dim | 32 / 8 / 128 |
151
+ | Block size | 8 (1 anchor token + 7 draft tokens) |
152
+ | Target layers read (`target_layer_ids`) | 5, 14, 24, 33, 42 |
153
+ | Conv kernel / group size | 2 / 16 |
154
+ | Candidate selector rank / top-k | 256 / 16 |
155
+ | Mask token ID | 154856 |
156
+ | Embeddings & LM head | Shared with target model (frozen) |
157
+ | Trainable parameters | 1.17B |
158
+ | Weights dtype | `bfloat16` |
159
+
160
+ The model architecture is identical to `incoai/GLM-5.3-Flash-DFlash2`; only the training dataset and recipe differ. The relevant section of [`config.json`](config.json) is:
161
+
162
+ ```json
163
+ "dflash_config": {
164
+ "block_size": 8,
165
+ "conv_group_size": 16,
166
+ "conv_kernel_size": 2,
167
+ "mask_token_id": 154856,
168
+ "selector_rank": 256,
169
+ "selector_top_k": 16,
170
+ "target_layer_ids": [5, 14, 24, 33, 42]
171
+ }
172
+ ```
173
+
174
+ ## Limitations
175
+
176
+ - **Domain specialization**: Because this drafter was trained exclusively on coding-agent trajectories, it underperforms the general-purpose drafter on non-coding workloads such as competitive math and open-ended chat.
177
+
178
+ ## License
179
+
180
+ This draft model is released under the MIT License. It requires [GLM-5.3-Flash](https://huggingface.co/zai-org/GLM-5.3-Flash) as the target model; please refer to the base model repository for its license terms.
181
+
182
+ ## Acknowledgements
183
+
184
+ - [DFlash](https://github.com/z-lab/dflash) (z-lab) for the block-diffusion speculative decoding method
185
+ - [incoai/GLM-5.3-Flash-DFlash2](https://huggingface.co/incoai/GLM-5.3-Flash-DFlash2) for the DFlash2 model architecture and configuration
186
+ - [SpecForge](https://github.com/sgl-project/SpecForge) and [SGLang](https://github.com/sgl-project/sglang) for the training and serving frameworks
187
+ - [Mooncake](https://github.com/kvcache-ai/Mooncake) for high-throughput online feature transport
188
+ - The maintainers and contributors of the open-source repositories whose public issues made this dataset possible
assets/agent_speed.png ADDED

Git LFS Details

  • SHA256: 38f2579a0e1e61428656444d2eb7ca569b123ec41fdd1882475d666802f2ad4f
  • Pointer size: 131 Bytes
  • Size of remote file: 152 kB
config.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DFlash2DraftModel"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": null,
8
+ "dflash_config": {
9
+ "block_size": 8,
10
+ "conv_group_size": 16,
11
+ "conv_kernel_size": 2,
12
+ "mask_token_id": 154856,
13
+ "selector_rank": 256,
14
+ "selector_top_k": 16,
15
+ "target_layer_ids": [
16
+ 5,
17
+ 14,
18
+ 24,
19
+ 33,
20
+ 42
21
+ ]
22
+ },
23
+ "draft_vocab_size": 154880,
24
+ "dtype": "bfloat16",
25
+ "eos_token_id": [
26
+ 154820,
27
+ 154827,
28
+ 154829
29
+ ],
30
+ "head_dim": 128,
31
+ "hidden_act": "silu",
32
+ "hidden_size": 4096,
33
+ "initializer_range": 0.02,
34
+ "intermediate_size": 12288,
35
+ "is_causal": false,
36
+ "layer_types": [
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "sliding_attention",
40
+ "sliding_attention",
41
+ "sliding_attention"
42
+ ],
43
+ "max_position_embeddings": 1048576,
44
+ "max_window_layers": 5,
45
+ "model_type": "qwen3",
46
+ "num_attention_heads": 32,
47
+ "num_hidden_layers": 5,
48
+ "num_key_value_heads": 8,
49
+ "num_target_layers": 45,
50
+ "pad_token_id": 154820,
51
+ "rms_norm_eps": 1e-05,
52
+ "rope_parameters": {
53
+ "rope_theta": 10000.0,
54
+ "rope_type": "default"
55
+ },
56
+ "rope_theta": 10000.0,
57
+ "sliding_window": 2048,
58
+ "tie_word_embeddings": false,
59
+ "transformers_version": "5.12.1",
60
+ "use_cache": false,
61
+ "use_sliding_window": true,
62
+ "vocab_size": 154880
63
+ }
data_summary.json ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "description": "Training data of this drafter. Sessions: agent runs of GLM-5.3-Flash (FP8) on GitHub issues. input_tokens/output_tokens: prompt and generated tokens of every target-model request (input counts each request's full prompt, prefix-cached or not). samples/sample_tokens/loss_tokens: training samples built from those requests (one per agent context chain, <=262,144 tokens) and their supervised tokens.",
3
+ "train": {
4
+ "sessions": 50268,
5
+ "requests": 2178249,
6
+ "input_tokens": 91895376100,
7
+ "output_tokens": 610952189,
8
+ "samples": 80299,
9
+ "sample_tokens": 2577242915,
10
+ "loss_tokens": 610564069
11
+ },
12
+ "train_repos": 977,
13
+ "train_by": {
14
+ "lang": {
15
+ "en": {
16
+ "sessions": 25151,
17
+ "requests": 1073677,
18
+ "input_tokens": 45030330223,
19
+ "output_tokens": 294291736,
20
+ "samples": 40103,
21
+ "sample_tokens": 1265841626,
22
+ "loss_tokens": 293900891
23
+ },
24
+ "ko": {
25
+ "sessions": 25117,
26
+ "requests": 1104572,
27
+ "input_tokens": 46865045877,
28
+ "output_tokens": 316660453,
29
+ "samples": 39994,
30
+ "sample_tokens": 1310623181,
31
+ "loss_tokens": 316196885
32
+ }
33
+ },
34
+ "harness": {
35
+ "claude_code": {
36
+ "sessions": 16757,
37
+ "requests": 799868,
38
+ "input_tokens": 34937577872,
39
+ "output_tokens": 278354701,
40
+ "samples": 39029,
41
+ "sample_tokens": 1007503352,
42
+ "loss_tokens": 277791545
43
+ },
44
+ "codex": {
45
+ "sessions": 16682,
46
+ "requests": 695268,
47
+ "input_tokens": 29343344680,
48
+ "output_tokens": 145447846,
49
+ "samples": 16999,
50
+ "sample_tokens": 793146154,
51
+ "loss_tokens": 145436917
52
+ },
53
+ "opencode": {
54
+ "sessions": 16829,
55
+ "requests": 683113,
56
+ "input_tokens": 27614453548,
57
+ "output_tokens": 187149642,
58
+ "samples": 24069,
59
+ "sample_tokens": 775815301,
60
+ "loss_tokens": 186869314
61
+ }
62
+ },
63
+ "effort": {
64
+ "high": {
65
+ "sessions": 16736,
66
+ "requests": 739352,
67
+ "input_tokens": 30203058954,
68
+ "output_tokens": 186053140,
69
+ "samples": 24981,
70
+ "sample_tokens": 840089036,
71
+ "loss_tokens": 185760345
72
+ },
73
+ "low": {
74
+ "sessions": 16699,
75
+ "requests": 548492,
76
+ "input_tokens": 17646017619,
77
+ "output_tokens": 105753880,
78
+ "samples": 20424,
79
+ "sample_tokens": 577607655,
80
+ "loss_tokens": 105555688
81
+ },
82
+ "max": {
83
+ "sessions": 16833,
84
+ "requests": 890405,
85
+ "input_tokens": 44046299527,
86
+ "output_tokens": 319145169,
87
+ "samples": 34692,
88
+ "sample_tokens": 1158768116,
89
+ "loss_tokens": 318781743
90
+ }
91
+ }
92
+ },
93
+ "heldout_repos_excluded_from_training": [
94
+ "CherryHQ/cherry-studio",
95
+ "HKUDS/nanobot",
96
+ "Imbad0202/academic-research-skills",
97
+ "LazyVim/LazyVim",
98
+ "SDWebImage/SDWebImage",
99
+ "Significant-Gravitas/AutoGPT",
100
+ "addyosmani/agent-skills",
101
+ "calcom/cal.diy",
102
+ "codewhale-hq/Codewhale",
103
+ "composer/composer",
104
+ "dmtrKovalenko/odiff",
105
+ "evanw/esbuild",
106
+ "heygen-com/hyperframes",
107
+ "immerjs/immer",
108
+ "lobehub/lobehub",
109
+ "markedjs/marked",
110
+ "msitarzewski/agency-agents",
111
+ "pandas-dev/pandas",
112
+ "qbittorrent/qBittorrent",
113
+ "reasonml/reason",
114
+ "rustfs/rustfs",
115
+ "thunderbird/thunderbird-android",
116
+ "usebruno/bruno"
117
+ ]
118
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad025341c4ee1fc297b9f2bb95351c7ef5727d1232696b3e26c671d0faabc2a1
3
+ size 2342169824
training_repos.json ADDED
The diff for this file is too large to render. See raw diff