ax-engine-sglang 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. ax_engine_sglang-0.2.0/LICENSE +202 -0
  2. ax_engine_sglang-0.2.0/NOTICE +35 -0
  3. ax_engine_sglang-0.2.0/PKG-INFO +350 -0
  4. ax_engine_sglang-0.2.0/README.md +330 -0
  5. ax_engine_sglang-0.2.0/ax_engine_sglang/__init__.py +5 -0
  6. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_chain.py +640 -0
  7. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_dflash_sampling.py +43 -0
  8. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_eagle_sampling.py +73 -0
  9. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_fast.py +116 -0
  10. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_fp8_probe.py +93 -0
  11. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_gdn_recurrent.py +59 -0
  12. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_lattice.py +182 -0
  13. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_nvfp4_verify.py +78 -0
  14. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_nxt_debug.py +103 -0
  15. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_qsa.py +327 -0
  16. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_rng.py +70 -0
  17. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_state_cap.py +102 -0
  18. ax_engine_sglang-0.2.0/ax_engine_sglang/ax_verify_attention.py +138 -0
  19. ax_engine_sglang-0.2.0/ax_engine_sglang/cli.py +57 -0
  20. ax_engine_sglang-0.2.0/ax_engine_sglang/compat.py +80 -0
  21. ax_engine_sglang-0.2.0/ax_engine_sglang/config.py +150 -0
  22. ax_engine_sglang-0.2.0/ax_engine_sglang/contracts.py +67 -0
  23. ax_engine_sglang-0.2.0/ax_engine_sglang/defaults.py +284 -0
  24. ax_engine_sglang-0.2.0/ax_engine_sglang/fc1_block_inverse.py +83 -0
  25. ax_engine_sglang-0.2.0/ax_engine_sglang/fc1_branch64.py +81 -0
  26. ax_engine_sglang-0.2.0/ax_engine_sglang/fc1_builder.py +54 -0
  27. ax_engine_sglang-0.2.0/ax_engine_sglang/fc1_conv.py +47 -0
  28. ax_engine_sglang-0.2.0/ax_engine_sglang/fc1_fused.py +196 -0
  29. ax_engine_sglang-0.2.0/ax_engine_sglang/fc1_plan.py +44 -0
  30. ax_engine_sglang-0.2.0/ax_engine_sglang/fc1_verify.py +26 -0
  31. ax_engine_sglang-0.2.0/ax_engine_sglang/ngram_gpu.py +70 -0
  32. ax_engine_sglang-0.2.0/ax_engine_sglang/plugin.py +130 -0
  33. ax_engine_sglang-0.2.0/ax_engine_sglang/policy.py +31 -0
  34. ax_engine_sglang-0.2.0/ax_engine_sglang/qsa_topk.py +32 -0
  35. ax_engine_sglang-0.2.0/ax_engine_sglang/runtime.py +50 -0
  36. ax_engine_sglang-0.2.0/ax_engine_sglang/tree_kernels.py +208 -0
  37. ax_engine_sglang-0.2.0/ax_engine_sglang/tree_ops.py +102 -0
  38. ax_engine_sglang-0.2.0/ax_engine_sglang/worker_gen.py +123 -0
  39. ax_engine_sglang-0.2.0/ax_engine_sglang.egg-info/PKG-INFO +350 -0
  40. ax_engine_sglang-0.2.0/ax_engine_sglang.egg-info/SOURCES.txt +57 -0
  41. ax_engine_sglang-0.2.0/ax_engine_sglang.egg-info/dependency_links.txt +1 -0
  42. ax_engine_sglang-0.2.0/ax_engine_sglang.egg-info/entry_points.txt +5 -0
  43. ax_engine_sglang-0.2.0/ax_engine_sglang.egg-info/requires.txt +2 -0
  44. ax_engine_sglang-0.2.0/ax_engine_sglang.egg-info/top_level.txt +1 -0
  45. ax_engine_sglang-0.2.0/licenses/FLASH_LINEAR_ATTENTION-LICENSE +21 -0
  46. ax_engine_sglang-0.2.0/pyproject.toml +32 -0
  47. ax_engine_sglang-0.2.0/setup.cfg +4 -0
  48. ax_engine_sglang-0.2.0/tests/test_benchmark_recovery.py +95 -0
  49. ax_engine_sglang-0.2.0/tests/test_benchmark_tools.py +183 -0
  50. ax_engine_sglang-0.2.0/tests/test_cli.py +57 -0
  51. ax_engine_sglang-0.2.0/tests/test_contracts.py +40 -0
  52. ax_engine_sglang-0.2.0/tests/test_defaults.py +169 -0
  53. ax_engine_sglang-0.2.0/tests/test_distribution.py +59 -0
  54. ax_engine_sglang-0.2.0/tests/test_forward_probe.py +30 -0
  55. ax_engine_sglang-0.2.0/tests/test_gdn_recurrent.py +60 -0
  56. ax_engine_sglang-0.2.0/tests/test_maintenance.py +347 -0
  57. ax_engine_sglang-0.2.0/tests/test_qa_tools.py +143 -0
  58. ax_engine_sglang-0.2.0/tests/test_runtime_tools.py +546 -0
  59. ax_engine_sglang-0.2.0/tests/test_verify_attention.py +28 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,35 @@
1
+ ax-engine-sglang (SGLang plugin for NVIDIA GPUs)
2
+ Copyright 2026 ax-engine-sglang contributors.
3
+
4
+ Distribution `ax-engine-sglang`, import package `ax_engine_sglang`, SGLang plugin name `ax-engine`
5
+ (`SGLANG_PLUGINS=ax-engine`). `ax-engine` / `ax_engine` is the AX Engine Apple Silicon runtime,
6
+ a separate package; the two can be installed side by side.
7
+
8
+ This package is a derivative of DForkTree v0.1.0 (commit eeed8b6),
9
+ Copyright 2026 Zhicheng Zheng, Cheng Zhang, and Chenkai Tang, licensed under Apache-2.0.
10
+ Files taken from it and modified: plugin.py (from fc1_plugin.py), fc1_branch64.py, fc1_fused.py,
11
+ fc1_conv.py, tree_kernels.py, tree_ops.py. Files taken unchanged: fc1_block_inverse.py,
12
+ fc1_builder.py, fc1_plan.py, fc1_verify.py, ngram_gpu.py.
13
+
14
+ Changes made here (see benchmarks/sglang/patch_dforktree.py for each one as a text patch, and
15
+ results/track_l_l0/REPORT.md for the measurements):
16
+ - tree_ops.ngram_path_fn: the scoring closure that the release returns but never defines,
17
+ reconstructed from the paper and the README defaults (not the authors' code).
18
+ - fc1_branch64: prefix length when the scheduler's host mirror is absent; optional overhead fixes
19
+ (ax_fast.py, AX_FAST=1); DFlash2 lattice trees (ax_lattice.py, AX_LATTICE=1).
20
+ - fc1_fused: target sizes other than Qwen3.5-9B (AX_GDN_LAYERS / AX_GDN_HEADS); 64-bit layer, slot
21
+ and intermediate-slot offsets in the state-commit kernel (the 32-bit layer offset wrote outside
22
+ the state buffer on Qwen3.8-27B); optional diagnostics (AX_GDN_DEBUG=1).
23
+ - Several running requests (ax_chain.py, new): chain rounds on SGLang's own DFlash verify next to
24
+ the one-request tree; the fused tree hooks in fc1_fused.py and fc1_conv.py run only in tree
25
+ rounds; 64-bit slot offsets in fc1_conv.py and tree_kernels.py.
26
+ - The release's copy of SGLang 0.5.22's dflash_worker_v2.py is not included: worker_gen.py builds
27
+ the tree worker from the installed SGLang at start-up.
28
+
29
+ DForkTree's own notice:
30
+ The SGLang worker integration is adapted from SGLang 0.5.22
31
+ (https://github.com/sgl-project/sglang), licensed under Apache-2.0.
32
+ The implementation uses the native SGLang speculative verification API.
33
+ The diagonal triangular recurrence in fc1_block_inverse.py is adapted from Flash Linear
34
+ Attention's solve_tril implementation (MIT license). Its license is reproduced in
35
+ licenses/FLASH_LINEAR_ATTENTION-LICENSE.
@@ -0,0 +1,350 @@
1
+ Metadata-Version: 2.4
2
+ Name: ax-engine-sglang
3
+ Version: 0.2.0
4
+ Summary: AX Engine for SGLang: speculative decoding and inference acceleration on Linux NVIDIA CUDA
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/defai-digital/ax-engine-sglang
7
+ Project-URL: Documentation, https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/README.md
8
+ Project-URL: Changelog, https://github.com/defai-digital/ax-engine-sglang/releases
9
+ Classifier: Operating System :: POSIX :: Linux
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Python: <3.13,>=3.11
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ License-File: NOTICE
16
+ License-File: licenses/FLASH_LINEAR_ATTENTION-LICENSE
17
+ Requires-Dist: sglang==0.5.23
18
+ Requires-Dist: numpy
19
+ Dynamic: license-file
20
+
21
+ # AX Engine for SGLang
22
+
23
+ `ax-engine-sglang` is the SGLang add-on for AX Engine's Linux CUDA edition.
24
+ Deploy it on Linux amd64 (x86_64) or arm64 (aarch64) with a CUDA-enabled
25
+ SGLang environment and NVIDIA GPU. SGLang 0.5.23 is the reference release.
26
+ [Platform and model support](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/README.md) · [Side-by-side throughput](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/performance.md)
27
+
28
+ The Python distribution is `ax-engine-sglang`, the import is
29
+ `ax_engine_sglang`, and the SGLang plugin name is `ax-engine`. The plugin
30
+ integrates with the installed SGLang worker for DFlash-family speculative
31
+ verification. Its tree worker is generated at startup from installed
32
+ SGLang code and validates the expected upstream integration points.
33
+ [DForkTree attribution](https://github.com/defai-digital/ax-engine-sglang/blob/main/ax-engine-sglang/NOTICE)
34
+
35
+ ## Install and run
36
+
37
+ Use Python 3.11 or 3.12 and a CUDA 13-compatible NVIDIA driver on Linux. In a
38
+ fresh virtual environment, run `python -m pip install ./ax-engine-sglang` from
39
+ the repository root to install the add-on and SGLang 0.5.23. In an
40
+ existing SGLang 0.5.23 environment, run
41
+ `python -m pip install --no-deps ./ax-engine-sglang` or pass the 0.2.0 wheel
42
+ path instead. The Jetson Thor smoke test used this wheel install in
43
+ `lmsysorg/sglang:v0.5.23-cu130`.
44
+
45
+ Install published PyPI releases by name with `python -m pip install ax-engine-sglang`.
46
+
47
+ ```bash
48
+ ax-engine-sglang serve RadixArk/Qwen3.8-27B-NVFP4 \
49
+ --speculative-algorithm FC1_DFLASH_TREE \
50
+ --speculative-draft-model-path incoai/Qwen3.8-27B-DFlash2 \
51
+ --speculative-num-draft-tokens 16
52
+ ```
53
+
54
+ The command enables the plugin, passes the server flags to SGLang and stops
55
+ startup if AX fails to load. An existing `SGLANG_PLUGINS` allowlist retains
56
+ its entries. To use the upstream launcher directly, set `SGLANG_PLUGINS=ax-engine`.
57
+ On Jetson Thor, the installed wheel served a 32-token request with six tree
58
+ rounds and rejected a checkpoint setting mismatch before loading weights.
59
+ [Smoke test and exact launch flags](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/README.md#installed-wheel-smoke-on-jetson-thor)
60
+
61
+ ## B200 benchmark results
62
+
63
+ Tested on SGLang 0.5.23 (and 0.5.22 for the single-request tree), one B200, greedy unless noted,
64
+ 64 prompts per family, 1,024 tokens. Full records:
65
+ [dual attention backend](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/decisions/2026-11-16-dual-attention-backend.md),
66
+ [Flash-Next](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/decisions/2026-11-17-qwen38-flash-next-feasibility.md).
67
+ Jetson Thor (SM110, aarch64) is measured separately with 12 prompts and 512 tokens; see
68
+ [Jetson Thor](#jetson-thor).
69
+
70
+ | Model | Mode | Result vs. stock SGLang |
71
+ |---|---|---|
72
+ | Qwen3.8-27B NVFP4 | tree at 1 request, chain width 8 / 16 above (32-64 slots) | c = 1: code 1.42x, math 1.33x, chat 1.14x; c = 2-64: 1.01x-1.21x |
73
+ | Qwen3.8-27B bf16 | same (16 slots) | c = 1: 1.09x-1.15x vs. the faster stock block; c = 2-16: 0.93x-1.09x |
74
+ | Qwen3.8-27B, both | vs. TensorRT-LLM 1.4 DFlash2 | c = 1: 1.07x-1.72x; c = 16 chat 0.81x-0.90x (engine round cost) |
75
+ | Qwen3.8-Flash-Next NVFP4 | stock MTP 7 + `AX_QSA_RING=16` vs. stock MTP 3 | code 1.22x-1.30x, math 1.05x-1.15x, chat 0.80x-0.86x |
76
+
77
+ Correctness checks: greedy token identity against the plugin's earlier builds (192 / 192), fp32
78
+ teacher audit at the stock mismatch rate, stress runs with aborts, sampled tree verify matching plain
79
+ decoding on 28 / 28 distribution tests (bf16), QSA ring consistency check (Flash-Next).
80
+
81
+ Limits:
82
+ - Tree rounds serve one greedy request without grammar or logprobs. Every other batch, and one
83
+ sampled request unless `AX_TREE_SAMPLING=1`, runs a stock DFlash2 chain round.
84
+ - Tested targets: Qwen3.5-9B and Qwen3.8-27B (Gated-DeltaNet hybrids). On Qwen3.8-Flash-Next
85
+ (Qwen4-Exp) only the QSA ring fix applies; SGLang does not expose its aux hidden states (needed by
86
+ DFlash2) and the tree needs the PLE n-gram context.
87
+ - MTP 12 on Flash-Next needs `--max-running-requests 32` (the GDN state pool grows with the draft
88
+ length). Wider MTP is slower on chat; choose the step count per workload.
89
+
90
+ ## Launch defaults
91
+
92
+ On SGLang 0.5.23 the plugin fills in the settings below while SGLang resolves the server arguments,
93
+ so the command above runs the measured configuration. The launcher prints every value with its
94
+ origin (`auto` or `env`). Explicit values take priority. A mismatch with the
95
+ checkpoint stops the launch and reports the reason. `AX_AUTO_DEFAULTS=0` turns
96
+ off these defaults. For an existing SGLang 0.5.22 environment, use `--no-deps`
97
+ and supply the settings in the table below explicitly.
98
+
99
+ | Applies to | Default | Derived from |
100
+ |---|---|---|
101
+ | `FC1_DFLASH_TREE` | `AX_GDN_LAYERS`, `AX_GDN_HEADS` | the target's `layer_types` and `linear_num_value_heads` (48 / 48 for Qwen3.8-27B, 24 / 32 for Qwen3.5-9B) |
102
+ | `FC1_DFLASH_TREE` | `FC1_DRAFT_BLOCK` | `--speculative-num-draft-tokens`, else the drafter's `dflash_config.block_size` |
103
+ | `FC1_DFLASH_TREE` | `AX_LATTICE=1` | a DFlash2 drafter; a DFlash (v1) drafter needs `FC1_NGRAM_PATH` (checked at launch) |
104
+ | `FC1_DFLASH_TREE` | `FC1_TREE64=1 FC1_BRANCH_PILOT=1 FC1_OURS=1 FC1_FUSED=1 FC1_COMPILE_BUILD=1 AX_FAST=1 FC1_TREE_N=32` | the measured tree configuration |
105
+ | `FC1_DFLASH_TREE` | `--max-running-requests 1 --cuda-graph-max-bs-decode 1` | only when `--max-running-requests` is not given; set it (and `AX_CHAIN_*`) for multi-user chain rounds |
106
+ | Qwen4-Exp target with any speculative algorithm | `AX_QSA_RING=16` | the stock 4-slot ring is wrong for verify windows that cross a group and refuses windows above 4 |
107
+ | NVFP4 MoE target on SM110 (Jetson Thor) / SM120 | `--moe-runner-backend flashinfer_cutlass`, and `--speculative-moe-runner-backend` with speculative decoding | only when left at `auto`: SGLang 0.5.23 picks TRT-LLM (SM100 only) |
108
+
109
+ The tree is refused on Qwen4-Exp targets. If the target's or drafter's `config.json` cannot be read (offline, a wrong revision), a tree launch stops instead of guessing: set `AX_GDN_LAYERS` and `AX_GDN_HEADS`, or `AX_LATTICE` (`1` for DFlash2, `0` for DFlash v1), explicitly. It also stops when neither `--speculative-num-draft-tokens`, the drafter config nor `FC1_DRAFT_BLOCK` gives the draft block length. The published DFlash2 drafters list `block_size` 8; the measured lanes draft 16 tokens per round, so keep `--speculative-num-draft-tokens 16` (the launcher prints a note about the difference). For a stock speculative route (MTP) with an unreadable target config, the launcher notes that the NVFP4 MoE backend and `AX_QSA_RING` defaults were not derived.
110
+
111
+ | Variable | Meaning |
112
+ |---|---|
113
+ | `FC1_TREE_N` | nodes verified per round, root included (32 measured best on B200 and 64 on RTX PRO 6000 for single-request 27B NVFP4). 16, 32 and 64 use the plugin's host-length FlashInfer plan; other sizes use SGLang's own plan |
114
+ | `FC1_DRAFT_BLOCK` | tokens drafted per round (16 on the 9B and the 27B; at most 32 with `FC1_TREE64=1`) |
115
+ | `AX_LATTICE=1` | build the tree from the DFlash2 selector lattice (needs a DFlash2 drafter) |
116
+ | `AX_FAST=1` | per-round overhead fixes (no host readback of the prefix length) |
117
+ | `AX_GDN_LAYERS`, `AX_GDN_HEADS` | Gated-DeltaNet shape of the target: 48 / 48 for Qwen3.8-27B, 24 / 32 for Qwen3.5-9B |
118
+ | `FC1_FUSED=1` | fused tree verifier; `0` uses SGLang's own tree verify (slower, a reference) |
119
+ | `FC1_NGRAM_PATH` | n-gram table of the DForkTree release, used to score trees with a DFlash (v1) drafter; lattice trees (`AX_LATTICE=1`) do not use it. The measured runs set it, so the example does too |
120
+ | `AX_CHECK=1` | validation only: checks the mask and length bound every round (synchronous, slow) |
121
+ | `AX_QSA_RING=16` | Qwen4-Exp (Qwen3.8-Flash-Next) QSA sparse attention: widen the per-request pending index-key ring from 4 to 16 slots. Fixes compressed index keys built from overwritten ring members whenever a verify window crosses a 4-token group (stock SGLang 0.5.23, MTP 1-3 included) and allows verify windows up to 13 tokens (stock refuses more than 4). Works with stock MTP (`--speculative-algorithm EAGLE`); the tree is not supported on Qwen4-Exp |
122
+ | `AX_QSA_CHECK=1` | validation only: counts QSA groups compressed from ring members that do not hold their group's positions (eager, `--disable-cuda-graph`) |
123
+
124
+ B200 multi-user server for the 27B (tree at one request, chain rounds of width 16 / 8 with their own
125
+ CUDA graphs on `trtllm_mha`): see `benchmarks/sglang/run_stage1a.sh` for the full flag set
126
+ (`AX_CHAIN_ATTN=trtllm_mha AX_CHAIN_GRAPH_WIDTHS="16 8" AX_CHAIN_DRAFT_WIDTHS=8`, 16 slots bf16 or 32
127
+ NVFP4, prefill on `trtllm_mha`, tree verify on `triton`). Set `HYBRID=0` to use Triton
128
+ for the target, drafter and private chain runners.
129
+
130
+ Qwen3.8-Flash-Next with stock MTP and the ring fix (`AX_QSA_RING=16` is the launch default for
131
+ Qwen4-Exp; it is spelled out here because SGLang 0.5.22 needs it):
132
+
133
+ ```bash
134
+ AX_QSA_RING=16 ax-engine-sglang serve RadixArk/Qwen3.8-Flash-Next-NVFP4 \
135
+ --speculative-algorithm EAGLE --speculative-num-steps 7 --speculative-eagle-topk 1 \
136
+ --speculative-num-draft-tokens 8
137
+ ```
138
+
139
+ The measurement lanes `axtree<spec>` (venv SGLang) and `axotree<spec>` (0.5.22 overlay) in
140
+ `benchmarks/sglang/run_tree_plugin.sh` run the standalone plugin's DFlash tree configuration.
141
+ The `axtree` lanes use `AXSITE` and the venv. Lattice lanes use DFlash2 scores
142
+ and can run without an n-gram table.
143
+
144
+ ## RTX PRO 6000
145
+
146
+ For single-request Qwen3.8-27B NVFP4 serving, the fastest setting in the
147
+ 128-token sweep used a 64-node tree, a draft block of 16 and verification
148
+ parity disabled. It reached **156.87 output tok/s** at **0.818 s median
149
+ request latency**. At eight serving slots, set `AX_CHAIN_WIDTH=8`,
150
+ `AX_CHAIN_GRAPH_WIDTHS=8`, `AX_CHAIN_DRAFT_WIDTHS=8` and `AX_SSM_POSITIONS=8`
151
+ to reproduce the measured cache allocation. Tree 64 matched packed AR exactly
152
+ on one of ten complete outputs per pass.
153
+
154
+ At concurrency eight, stock `DFLASH` with `--speculative-num-draft-tokens 8`
155
+ averaged **489.86 aggregate output tok/s** over two 40-request passes. Plugin
156
+ tree 32 averaged **484.78 tok/s** with width-eight chain rounds for grouped
157
+ requests. Packed AR reached **388.29 tok/s**.
158
+ [Launch commands and all ten measured configurations](https://github.com/defai-digital/ax-engine-sglang/blob/main/results/rtx_27b_nvfp4_speed/REPORT.md)
159
+
160
+ ## Jetson Thor
161
+
162
+ Jetson Thor (SM 11.0, aarch64, 122 GB unified memory) runs the same commands as above on
163
+ `lmsysorg/sglang:v0.5.23-cu130`; the launch defaults detect SM110. Measured single-request output
164
+ throughput (greedy, 12 prompts, 512 tokens; 27B bf16: 8 prompts, 384 tokens), code / math / chat:
165
+
166
+ | Target | AR | Stock chain 16 | ax-engine-sglang tree |
167
+ |---|---|---|---|
168
+ | Qwen3.5-9B bf16 | 14.8 / 14.9 / 14.9 | 118.7 / 78.0 / 31.3 | 125.5 / 98.2 / 46.2 |
169
+ | Qwen3.8-27B NVFP4 | 13.4 / 13.5 / 13.5 | 93.0 / 73.5 / 30.6 | 106.1 / 92.1 / 43.1 |
170
+ | Qwen3.8-27B bf16 | 4.6 / 4.6 / 4.6 | 43.1 / 29.6 / 12.5 | 47.5 / 37.6 / 18.3 |
171
+
172
+ All three rows use FlashInfer attention. Full tables (Triton, vLLM, MTP, teacher checks) and the
173
+ two-host Flash-Next run are in the [Thor report](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-19-jetson-thor.md).
174
+
175
+ Settings that differ from a discrete GPU:
176
+
177
+ - `--mem-fraction-static` is a fraction of the memory free at start-up, and CUDA's free figure on
178
+ Jetson excludes page cache. Drop the page cache before starting the server
179
+ (`sync; echo 3 > /proc/sys/vm/drop_caches` as root) and pass
180
+ `--mem-fraction-static 0.70 --chunked-prefill-size 2048` for the 9B and the 27B NVFP4, `0.80`
181
+ for the 27B bf16. With other services holding about half of the memory, `0.70` still serves the
182
+ 9B and the 27B NVFP4 tree (about 87k KV tokens on the 27B NVFP4).
183
+ - Stock MTP on the 27B bf16 also needs `--max-running-requests 4`: the Gated-DeltaNet state pool
184
+ for the default request count leaves no KV cache.
185
+ - Qwen3.8-Flash-Next NVFP4 (about 148 GB) does not fit one Thor. Two hosts serve it with SGLang
186
+ pipeline parallelism (`--pp-size 2 --nnodes 2 --dist-init-addr <rank-0 host>:29500
187
+ --node-rank {0,1}`, `SGLANG_PP_LAYER_PARTITION=4,44`, `--mem-fraction-static 0.90`,
188
+ `--max-running-requests 4`, and `SGLANG_ENABLE_PP_SPEC=1` for MTP), each host loading a stage
189
+ directory that lists only its own shards. Without InfiniBand, set `NCCL_IB_DISABLE=1` and
190
+ `NCCL_SOCKET_IFNAME` / `GLOO_SOCKET_IFNAME` to the Ethernet interface. The report gives the
191
+ coordinator script. Flash-Next bf16 does not fit two Thors.
192
+ - NVFP4 targets: a fresh prefill and AR decoding disagree on about 3% of tokens on SM110, for
193
+ stock AR as well, so greedy identity and the teacher check cannot qualify NVFP4 routes on Thor.
194
+ Qualify exact-output requirements on bf16.
195
+
196
+ Not qualified on Thor: sampled decoding (`AX_TREE_SAMPLING`, `AX_EAGLE_JOINT_SAMPLING`,
197
+ `AX_DFLASH_JOINT_SAMPLING`; their kernel-level checks pass on SM110, the distribution qualification
198
+ is the B200 result), more than one running request (`AX_CHAIN_*`), and `AX_QSA_STABLE_TOPK` on a
199
+ served model. All `tests/gpu_*.py` checks pass on SM110.
200
+
201
+ ## Maintenance and validation
202
+
203
+ Startup parses and validates the tree/chain configuration before installing
204
+ upstream hooks. QSA/RNG fixes can load without constructing a DFlash worker;
205
+ tree hooks load when their flags or the custom algorithm request them. Supported
206
+ SGLang versions are 0.5.22 and 0.5.23. `AX_ALLOW_UNTESTED_SGLANG=1` permits an
207
+ explicit porting experiment; exact source-anchor checks still apply.
208
+
209
+ Round policy is pure Python in `policy.py`. `runtime.py` keeps round decisions,
210
+ planning lengths and fused GDN buffers on each worker. Startup patches use
211
+ `compat.py` to restore replaced attributes on failure. SSM allocation and budget
212
+ hooks are compiled together before either replacement is published.
213
+ Tree rounds read fresh logits or a lattice from the drafter's sampler folded
214
+ into its CUDA graph. Eager drafts and draft graph misses use chain verification
215
+ for the round, including when the server was launched with the tree algorithm.
216
+ When chain verification keeps a prefix of a wider draft, it keeps the sampled
217
+ candidate IDs and proposal probabilities for those same positions.
218
+
219
+ The package owns `ax_fast.py` and `ax_lattice.py`; `benchmarks/sglang/dft_*.py` preserve the
220
+ older research imports. Legacy DForkTree overlays copy the package-owned files.
221
+ Shared commit fixtures and benchmark evidence schemas live in `../contracts/`;
222
+ see [maintenance boundaries](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/decisions/2026-11-17-maintenance-boundaries.md).
223
+
224
+ Run the CPU checks from the repository root. Install `setuptools>=77`, `wheel`,
225
+ `scipy` and `jsonschema` in the test environment, as in the CPU workflow.
226
+
227
+ ```bash
228
+ python -m unittest discover -s ax-engine-sglang/tests -v
229
+ python scripts/check_engine_contracts.py --validate-schema
230
+ python scripts/check_engine_contracts.py --peer /path/to/ax-engine
231
+ python benchmarks/sglang/test_dft_lattice.py --plugin ax-engine-sglang/ax_engine_sglang
232
+ python benchmarks/sglang/test_paired_ci.py
233
+ ```
234
+
235
+ CUDA checks include `benchmarks/sglang/test_dft_fast.py`, `benchmarks/sglang/test_tree_gdn.py`, and
236
+ `ax-engine-sglang/tests/gpu_runtime_check.py` (its header lists the flags).
237
+ `gpu_ple_offload_check.py` checks pinned-host PLE reads and CUDA replay, including
238
+ large offsets. `gpu_qsa_diagnostic_check.py` checks multimodal QSA diagnostics
239
+ against real ring-overwrite and RoPE-store negative controls.
240
+ `gpu_nvfp4_moe_check.py` checks SM110 (Jetson Thor) / SM120 CUTLASS weight preparation, nonzero MoE
241
+ execution and changed-input graph replay before loading Flash Next weights.
242
+ `scripts/check_model_regression.py --help` describes the bounded comparison
243
+ against an earlier checkout with local target/drafter checkpoints. It checks
244
+ greedy identity, mixed request types and post-request state reuse. Optional
245
+ `--stress-requests`, `--sampling-n`, `--sampling-seed` and `--long-context` controls
246
+ exercise cancellation, sampled distributions and longer contexts. The stress
247
+ check requires matching idle pool usage and an observed abort when cancellation
248
+ is enabled. Use
249
+ `--candidate-only --route ar|mtp3|mtp7|mtp12` for Flash Next, with a local model
250
+ and `--model-override` for pinned FP8 PLE on a 96 GB card. `--qsa-ring 16
251
+ --qsa-check --eager` enables the synchronous ring diagnostic. The runner refuses
252
+ Flash Next tree verification until PLE/QSA tree support exists. The RTX
253
+ development checks cover correctness and lifecycle behavior. See the
254
+ [RTX validation plan](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/decisions/2026-11-17-rtx-development-validation.md)
255
+ and [installed-wheel QA results](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-18-development-qa.md).
256
+ The independent RTX BF16 distribution control passes; the NVFP4 AR/chain
257
+ comparison fails and remains outside cross-route lossless qualification.
258
+
259
+ For Flash Next NVFP4 on SM110 (Jetson Thor) and SM120 the runner must be
260
+ `flashinfer_cutlass` for the target and the MTP draft. SGLang 0.5.23's automatic
261
+ NVFP4 MoE selection can prepare a different weight layout from the runner it
262
+ later chooses (`g1_scale_c` missing during graph warmup). The plugin's launch
263
+ defaults select CUTLASS when both are left at `auto`; benchmark harnesses still
264
+ pass the backends explicitly so they appear in the saved launch command.
265
+
266
+ Sampling defaults to the server RNG. Paired comparisons use `--server-seed` for
267
+ the baseline and the next seed for the candidate, and enforce
268
+ `sampling_dist_check.py compare A B --require-independent-seeds`. A single lane
269
+ uses the requested server seed unchanged and records
270
+ `sampling_comparison: not_run_single_lane`. Collection sidecars record the
271
+ effective seed mode, tokenized prompt hashes, and a hash of the completed sample file.
272
+ Request-seed collection requires `--candidate-only` and
273
+ `--enable-deterministic-inference`; correlated request-seed cohorts cannot be
274
+ used for the independent two-sample test. SGLang otherwise ignores that request
275
+ field. The distribution gate requires at least 10 samples per prompt in each
276
+ cohort and reports an inconclusive result when low expected counts force all
277
+ observed differences into one cell.
278
+
279
+ For failure diagnosis, `--repeat-reference` checks reference stability before
280
+ stress, and stress records retain the before/after token arrays.
281
+ `--candidate-only --keep-server-on-failure` keeps an owned failed server resident
282
+ and writes its process-group stop command to `retained-server.json`. Each model
283
+ run also saves a copy of the harness source for replay.
284
+
285
+ `AX_QSA_STABLE_TOPK=1` (runner: `--qsa-stable-topk`) selects a fixed-shape,
286
+ stable tensor-sort fallback for QSA. It supports CUDA graph replay on SM120,
287
+ where the native deterministic FilteredTopK path needs more shared memory than
288
+ the device provides. Equal scores select the smaller relative block index.
289
+ `gpu_qsa_topk_check.py` covers ragged rows, ties, replay and hook rollback (it also passes on
290
+ SM110; a served Flash-Next model with this option was not run on Jetson Thor).
291
+ This is an opt-in correctness control; its throughput is not qualified.
292
+
293
+ `AX_EAGLE_JOINT_SAMPLING=1` matches AR's FlashInfer top-k/top-p filter during
294
+ target-only EAGLE verification on SGLang 0.5.23. Both filters use the original
295
+ probabilities. The option applies when both cutoffs are active and min-p is
296
+ disabled. NVFP4 model logits can still differ between AR and block verification.
297
+ `gpu_eagle_sampling_check.py` checks the filter against FlashInfer's AR sampler.
298
+
299
+ `AX_DFLASH_JOINT_SAMPLING=1` (runner flag `--dflash-joint-sampling`) applies
300
+ FlashInfer AR's joint top-k/top-p filter to target probabilities in
301
+ `FC1_DFLASH_TREE` chain rounds on SGLang 0.5.23. It applies when both cutoffs
302
+ are active and min-p is disabled. Rejection sampling retains the drafter's
303
+ proposal probabilities, and sampling-mask capture uses the same target filter.
304
+ `gpu_dflash_sampling_check.py` checks the target support and frequencies against
305
+ the FlashInfer AR sampler on CUDA.
306
+
307
+ For the B200 Qwen3.8-27B NVFP4 sampled profile, use `--attention-backend
308
+ flashinfer --fp4-gemm-backend flashinfer_cutlass` with checkpoint-selected FP8
309
+ KV. Enable `AX_GDN_UNPACKED_DECODE=1` on the AR reference and
310
+ `AX_DFLASH_JOINT_SAMPLING=1` on the DFlash2 service with chain width 8. The
311
+ profile passed all 28 distribution checks at the specified cutoff. AR and
312
+ DFlash2 produced identical greedy token sequences for two of seven prompts.
313
+ [B200 retest and commands](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-18-b200-27b-nvfp4.md) ·
314
+ [Greedy token identity and logit example](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-18-b200-27b-nvfp4.md#greedy-follow-up)
315
+
316
+ The RTX PRO 6000 retest passed real NVFP4 serving and kernel checks. Recurrent
317
+ GDN tree and chain each matched four of seven greedy outputs against RTX AR.
318
+ [RTX PRO 6000 model and kernel results](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-19-rtx-27b-nvfp4.md)
319
+
320
+ For the dense Qwen3.8-27B NVFP4 checkpoint on RTX PRO 6000, the regression
321
+ runner accepts `--nvfp4-verify-parity` for AR, DFlash2 tree and chain.
322
+ It selects FlashInfer paged attention, CUTLASS NVFP4, unpacked GDN
323
+ and row-wise target projections. The serving Python must be able to import
324
+ `cutlass.cute` from NVIDIA CUTLASS DSL. Use the option on both sides of a greedy
325
+ comparison. It changes the AR numerical reference and trades throughput for
326
+ reproducibility. [Verification controls and results](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-19-rtx-nvfp4-parity.md)
327
+
328
+ On the Flash Next AR reference server, `AX_GDN_UNPACKED_DECODE=1` selects
329
+ unpacked Triton Gated DeltaNet decode before CUDA graph capture. To reproduce
330
+ the AR profile through the plugin, set `SGLANG_PLUGINS=ax-engine` and
331
+ `AX_FI_OFFSET_FIX=0`. Both MTP7 configurations passed the 28 distribution checks
332
+ against the unpacked AR reference. The packed AR comparisons still fail.
333
+ [B200 sampling and throughput results](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-18-b200-eagle-sampling.md)
334
+
335
+ To avoid reloading unrelated target shards for Flash Next MTP, derive a compact
336
+ snapshot outside the repository with `scripts/prepare_flash_mtp.py --help`,
337
+ then pass it as `--mtp-draft`. The tool selects the loader's MTP/embedding names,
338
+ preserves model configuration and verifies every tensor's SHA-256 after writing.
339
+ It records the declared source revision in `derivation.json` and does not
340
+ requantize weights.
341
+
342
+ The [main deployment and logit report](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-18-main-deployment-and-nvfp4.md)
343
+ records clean-wheel GPU smokes and the unresolved NVFP4 AR/block-verification
344
+ differences on RTX PRO 6000, including native DFlash controls. The
345
+ [27B NVFP4 B200 retest](https://github.com/defai-digital/ax-engine-sglang/blob/main/docs/reports/2026-11-18-b200-27b-nvfp4.md) records
346
+ the follow-up attention and sampling controls. `scripts/nvfp4_forward_probe.py`
347
+ provides opt-in SGLang forward-hook factories and a matched-prefix analyzer.
348
+ Use eager execution and a single greedy request in flight; it rejects tree positions,
349
+ rejected speculative histories and incomplete/mismatched prompt sets. Its
350
+ synchronous replay probes preserve model outputs and are unsuitable for timing.