gump2049 commited on
Commit
970e644
·
verified ·
1 Parent(s): 48f53cc

Add standalone APUS-Reflex2.1 vLLM service and attribution

Browse files
.dockerignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *
2
+ !third_party/
3
+ !third_party/vllm/
4
+ !third_party/vllm/**
5
+ !serve.py
6
+ !deploy.sh
7
+ !verify.py
8
+ !Dockerfile
9
+ !LICENSE
10
+ !third_party/ATTRIBUTION.md
11
+ !third_party/licenses/
12
+ !third_party/licenses/**
.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
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ FROM vllm/vllm-openai:v0.33.0
2
+ WORKDIR /opt/apus
3
+ COPY LICENSE /opt/apus/LICENSE
4
+ COPY third_party/ /opt/apus/third_party/
5
+ RUN python3 /opt/apus/third_party/vllm/install_backport.py --apply --container-build
6
+ COPY serve.py deploy.sh verify.py /opt/apus/
7
+ ENV MODEL_DIR=/model HOST=0.0.0.0 PORT=8000 TENSOR_PARALLEL_SIZE=2
8
+ EXPOSE 8000
9
+ ENTRYPOINT ["bash", "/opt/apus/deploy.sh"]
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
README.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: vllm
4
+ pipeline_tag: zero-shot-classification
5
+ tags:
6
+ - decision-model
7
+ - structured-output
8
+ - vllm
9
+ ---
10
+
11
+ # APUS-Reflex2.1
12
+
13
+ APUS-Reflex2.1 scores typed decisions about a shared state in a single request. The text decision endpoint supports choice, binary and ordinal questions. This snapshot contains the model, tokenizer, FP32 decision head, a vLLM serving path, and a smoke verifier. The served model ID is `APUS-Reflex2.1`.
14
+
15
+ ## Run on two GPUs
16
+
17
+ Download the entire private snapshot using an authorized Hugging Face account and the revision you intend to serve. Run these commands from its root. The Docker build context contains the launcher and compatibility code. Model weights are supplied through a read-only mount.
18
+
19
+ ```bash
20
+ docker build -t apus-reflex21 .
21
+ docker run --rm --gpus '"device=0,1"' --ipc=host \
22
+ -p 127.0.0.1:8000:8000 -v "$PWD:/model:ro" apus-reflex21
23
+ ```
24
+
25
+ Once the server is ready, run `python3 verify.py --url http://127.0.0.1:8000`. It checks discovery, health, model identity and the probability distributions of three question types. External deployments can place an authenticated reverse proxy in front of the service.
26
+
27
+ ## Existing CUDA environment
28
+
29
+ The tested stack uses Python 3.12 on Linux, vLLM 0.33.0, Torch 2.14.0 with CUDA 13.0, Transformers 5.20.2 and Triton 3.8.0. In a dedicated virtual environment with the corresponding CUDA wheels and Git available, install `requirements.txt`, then run the following commands.
30
+
31
+ ```bash
32
+ python third_party/vllm/install_backport.py --apply
33
+ PYTHON_BIN="$(command -v python)" bash deploy.sh --host 127.0.0.1 --port 8000
34
+ ```
35
+
36
+ The default tensor parallel size is two. The launcher uses a separate temporary directory for each serving process and validates the exact vLLM source hashes before launching. Individual weight files can be checked against SHA256SUMS.
37
+
38
+ ## Protocol
39
+
40
+ Send a JSON object with model, state and questions to POST /v1/systemone. Each question has a type and instructions. A choice question includes a mapping from option IDs to descriptions. A score question takes ordered level descriptions. Each response gives the selected answer or scalar and the distribution across options or levels.
41
+
42
+ ```json
43
+ {"model":"APUS-Reflex2.1","state":"The same invoice was charged twice.","questions":{"queue":{"type":"choice","instructions":"Choose a support queue.","criteria":{"billing":"Billing","shipping":"Delivery"}}}}
44
+ ```
45
+
46
+ The model assets and third-party notices are documented in [the attribution file](third_party/ATTRIBUTION.md).
SHA256SUMS ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ bce4ed49239fd5638f7fe392cad7ac56a0845c04525ce799bd8632236387b436 .dockerignore
2
+ 56f06bc1d05007c2c80878e46fd40531576bf086566c62de5cbfaeda2f675148 Dockerfile
3
+ c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 LICENSE
4
+ 6b01d498728b3a69fe3e09c5b3b4ccb620043114a65161d4164d148ca68a44bf README.md
5
+ c3cf9e34abf4f9e36c2d72165aa9c132d3e2a725b6c2586aaa3a8af9d7a81041 chat_template.jinja
6
+ de032e751a82b4907ea8b230266e5e74609c5af0dde8b2722a5652a46142ea9b config.json
7
+ ffa94f39113838f7de083cd7cb85614f81845c5325c6aa45865f82fa91d54429 decision_config.json
8
+ dd882fefe01f9c3227ff2afe7d25e99d0bc3d95e107a2ae040c4cd57052b6b2f deploy.sh
9
+ a9d356d7bdf1ef4949e3e748e95b8e10ad9d4e2e838eddc38a0a7b6b94d1db8d merges.txt
10
+ 42a756c7640d2cb1d7aa114ec4015aa4a2aef6795c59316a39b13aa31d431000 model-00001-of-00011.safetensors
11
+ 80ed6444b8947fd0c94b26116d4def1e6cb9360b720ef666591da6a6176c346c model-00002-of-00011.safetensors
12
+ aa2dcc42c1ef32b6676d0e7e27fcb2386a35081e861195aec4e75c698412b2b7 model-00003-of-00011.safetensors
13
+ a00f672cf268b26cf0685e4c9ac630d5b6ae5254ee20c8a162781a4b85f2e687 model-00004-of-00011.safetensors
14
+ 756f28c98896a388f2fec706f55d9eb2d1c8c874a0a50a6e1e18b3db739ebd35 model-00005-of-00011.safetensors
15
+ e72542b949d02ac62103d613b087dc223dd603868cd0168f59c0528dd97d623c model-00006-of-00011.safetensors
16
+ f4f39956809a2c1139c5399af409b823cfcec9e89da2e6336df536d66ac836b5 model-00007-of-00011.safetensors
17
+ e202c386246c1630790916f06d8044e1da50cbe4e482bd7f633fcce1fe0ed16d model-00008-of-00011.safetensors
18
+ 09ea53ad79d54a828f2bbc48433787b62e7c198de3fd0a0e653e968b551136cd model-00009-of-00011.safetensors
19
+ 130721971031131f2b74d5bf52c13343a070d83388831e582deb60296b2fdd9c model-00010-of-00011.safetensors
20
+ 9fa39109db0047b10d2bc0e78a1980d99687edc5b81e6a54d7cfab5ec0245db1 model-00011-of-00011.safetensors
21
+ dc39d771cb240f775399e1845b11d081d8e007f14eecae3b780bc6272b128a46 model.safetensors.index.json
22
+ 27225450ac9c6529872ee1924fcb0962ff5634834f817040f444118116f4e516 preprocessor_config.json
23
+ a60b7a43b4d5698c426338695daf1ce02d6e8c536ce56a980664330246ee88d7 readout.safetensors
24
+ ca9ed8d6c1e3ab5da193e31b3c0319aa85ca4e445db26b318807eec9f6de4fd5 requirements.txt
25
+ 389a3b9c1f791cb71c28a9aa04ea9f21cf79fea2eb987900a909b2668f73cca7 serve.py
26
+ 89d3a538ed99f8970e4aa92960c494d5f5808a9c7d3f411748134abf52349908 third_party/ATTRIBUTION.md
27
+ d7522881de6b8417b997953c9b82d54e1be61952571a163c2fcf77f1e199406d third_party/licenses/NOTICE-upstream.txt
28
+ 9333c90f04b2c10a3f9a0ef41837261231b671970e13b4a886e37fe3b51ad2a1 third_party/licenses/second-source-Apache-2.0.txt
29
+ 1528a30b5614c4fd6ab1161a1f02d724f141a57dfc4bc280a60d29e179221aa6 third_party/vllm/install_backport.py
30
+ fe3668e8c945ebf4f8a53312f26e9a57d3bcf22caed91b14518d6c9cbfef6b17 third_party/vllm/vllm_patch_assets/d3-prefix-v033.patch
31
+ 16ddc6369e7b925d9d10f974b4b4f93e7f2a39fee0da7888b70468215b8ee0d9 third_party/vllm/vllm_patch_assets/manifest.json
32
+ 0997f410c57a1f4e53b09e4be8f4a172d90edd9564368fb0847030937229b9f3 tokenizer.json
33
+ b11349aafa7cdc6a320767cf7ceb29ed82f7eda5d65e8e0819e76f0ce947bf27 tokenizer_config.json
34
+ 9105aa0e98205c8f97bdfde33e0775757dba42960938107c8b07593fc3825daa verify.py
35
+ 7768af27c1fafa9cc9011c1dc20067e03f8915e03b63504550e11d5066986d13 video_preprocessor_config.json
36
+ ce99b4cb2983d118806ce0a8b777a35b093e2000a503ebde25853284c9dfa003 vocab.json
chat_template.jinja ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- set reasoning_instructions = '' %}
46
+ {%- if enable_thinking is undefined or enable_thinking is true %}
47
+ {%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}
48
+ {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}
49
+ {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}
50
+ {%- endif %}
51
+ {%- if resolved_reasoning_effort == 'xhigh' %}
52
+ {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}
53
+ {%- elif resolved_reasoning_effort == 'low' %}
54
+ {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}
55
+ {%- endif %}
56
+ {%- endif %}
57
+ {%- if tools and tools is iterable and tools is not mapping %}
58
+ {{- '<|im_start|>system\n' }}
59
+ {%- if reasoning_instructions %}
60
+ {{- reasoning_instructions + '\n\n' }}
61
+ {%- endif %}
62
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
63
+ {%- for tool in tools %}
64
+ {{- "\n" }}
65
+ {{- tool | tojson }}
66
+ {%- endfor %}
67
+ {{- "\n</tools>" }}
68
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
69
+ {%- if messages[0].role == 'system' %}
70
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
71
+ {%- if content %}
72
+ {{- '\n\n' + content }}
73
+ {%- endif %}
74
+ {%- endif %}
75
+ {{- '<|im_end|>\n' }}
76
+ {%- else %}
77
+ {%- if messages[0].role == 'system' %}
78
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
79
+ {%- if content %}
80
+ {{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + content + '<|im_end|>\n' }}
81
+ {%- elif reasoning_instructions %}
82
+ {{- '<|im_start|>system\n' + reasoning_instructions + '<|im_end|>\n' }}
83
+ {%- endif %}
84
+ {%- elif reasoning_instructions %}
85
+ {{- '<|im_start|>system\n' + reasoning_instructions + '<|im_end|>\n' }}
86
+ {%- endif %}
87
+ {%- endif %}
88
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
89
+ {%- for message in messages[::-1] %}
90
+ {%- set index = (messages|length - 1) - loop.index0 %}
91
+ {%- if ns.multi_step_tool and message.role == "user" %}
92
+ {%- set content = render_content(message.content, false)|trim %}
93
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
94
+ {%- set ns.multi_step_tool = false %}
95
+ {%- set ns.last_query_index = index %}
96
+ {%- endif %}
97
+ {%- endif %}
98
+ {%- endfor %}
99
+ {%- if ns.multi_step_tool %}
100
+ {{- raise_exception('No user query found in messages.') }}
101
+ {%- endif %}
102
+ {%- for message in messages %}
103
+ {%- set content = render_content(message.content, true)|trim %}
104
+ {%- if message.role == "system" %}
105
+ {%- if not loop.first %}
106
+ {{- raise_exception('System message must be at the beginning.') }}
107
+ {%- endif %}
108
+ {%- elif message.role == "user" %}
109
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
110
+ {%- elif message.role == "assistant" %}
111
+ {%- set reasoning_content = '' %}
112
+ {%- if message.reasoning_content is string %}
113
+ {%- set reasoning_content = message.reasoning_content %}
114
+ {%- endif %}
115
+ {%- set reasoning_content = reasoning_content|trim %}
116
+ {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}
117
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
118
+ {%- else %}
119
+ {{- '<|im_start|>' + message.role + '\n' + content }}
120
+ {%- endif %}
121
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
122
+ {%- for tool_call in message.tool_calls %}
123
+ {%- if tool_call.function is defined %}
124
+ {%- set tool_call = tool_call.function %}
125
+ {%- endif %}
126
+ {%- if loop.first %}
127
+ {%- if content|trim %}
128
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
129
+ {%- else %}
130
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
131
+ {%- endif %}
132
+ {%- else %}
133
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
134
+ {%- endif %}
135
+ {%- if tool_call.arguments is defined and tool_call.arguments != '' %}
136
+ {%- for args_name, args_value in tool_call.arguments|items %}
137
+ {{- '<parameter=' + args_name + '>\n' }}
138
+ {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}
139
+ {{- args_value }}
140
+ {{- '\n</parameter>\n' }}
141
+ {%- endfor %}
142
+ {%- endif %}
143
+ {{- '</function>\n</tool_call>' }}
144
+ {%- endfor %}
145
+ {%- endif %}
146
+ {{- '<|im_end|>\n' }}
147
+ {%- elif message.role == "tool" %}
148
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
149
+ {{- '<|im_start|>user' }}
150
+ {%- endif %}
151
+ {{- '\n<tool_response>\n' }}
152
+ {{- content }}
153
+ {{- '\n</tool_response>' }}
154
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
155
+ {{- '<|im_end|>\n' }}
156
+ {%- elif loop.last %}
157
+ {{- '<|im_end|>\n' }}
158
+ {%- endif %}
159
+ {%- else %}
160
+ {{- raise_exception('Unexpected message role.') }}
161
+ {%- endif %}
162
+ {%- endfor %}
163
+ {%- if add_generation_prompt %}
164
+ {{- '<|im_start|>assistant\n' }}
165
+ {%- if enable_thinking is defined and enable_thinking is false %}
166
+ {{- '<think>\n\n</think>\n\n' }}
167
+ {%- else %}
168
+ {{- '<think>\n' }}
169
+ {%- endif %}
170
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5Model"
4
+ ],
5
+ "dtype": "bfloat16",
6
+ "image_token_id": 248056,
7
+ "language_model_only": false,
8
+ "model_type": "qwen3_5",
9
+ "text_config": {
10
+ "attention_bias": false,
11
+ "attention_dropout": 0.0,
12
+ "attn_output_gate": true,
13
+ "bos_token_id": 248044,
14
+ "dtype": "bfloat16",
15
+ "eos_token_id": 248044,
16
+ "full_attention_interval": 4,
17
+ "head_dim": 256,
18
+ "hidden_act": "silu",
19
+ "hidden_size": 5120,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 17408,
22
+ "layer_types": [
23
+ "linear_attention",
24
+ "linear_attention",
25
+ "linear_attention",
26
+ "full_attention",
27
+ "linear_attention",
28
+ "linear_attention",
29
+ "linear_attention",
30
+ "full_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "linear_attention",
34
+ "full_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "linear_attention",
38
+ "full_attention",
39
+ "linear_attention",
40
+ "linear_attention",
41
+ "linear_attention",
42
+ "full_attention",
43
+ "linear_attention",
44
+ "linear_attention",
45
+ "linear_attention",
46
+ "full_attention",
47
+ "linear_attention",
48
+ "linear_attention",
49
+ "linear_attention",
50
+ "full_attention",
51
+ "linear_attention",
52
+ "linear_attention",
53
+ "linear_attention",
54
+ "full_attention",
55
+ "linear_attention",
56
+ "linear_attention",
57
+ "linear_attention",
58
+ "full_attention",
59
+ "linear_attention",
60
+ "linear_attention",
61
+ "linear_attention",
62
+ "full_attention",
63
+ "linear_attention",
64
+ "linear_attention",
65
+ "linear_attention",
66
+ "full_attention",
67
+ "linear_attention",
68
+ "linear_attention",
69
+ "linear_attention",
70
+ "full_attention",
71
+ "linear_attention",
72
+ "linear_attention",
73
+ "linear_attention",
74
+ "full_attention",
75
+ "linear_attention",
76
+ "linear_attention",
77
+ "linear_attention",
78
+ "full_attention",
79
+ "linear_attention",
80
+ "linear_attention",
81
+ "linear_attention",
82
+ "full_attention",
83
+ "linear_attention",
84
+ "linear_attention",
85
+ "linear_attention",
86
+ "full_attention"
87
+ ],
88
+ "linear_conv_kernel_dim": 4,
89
+ "linear_key_head_dim": 128,
90
+ "linear_num_key_heads": 16,
91
+ "linear_num_value_heads": 48,
92
+ "linear_value_head_dim": 128,
93
+ "mamba_ssm_dtype": "float32",
94
+ "max_position_embeddings": 262144,
95
+ "model_type": "qwen3_5_text",
96
+ "mtp_num_hidden_layers": 1,
97
+ "mtp_use_dedicated_embeddings": false,
98
+ "num_attention_heads": 24,
99
+ "num_hidden_layers": 64,
100
+ "num_key_value_heads": 4,
101
+ "output_gate_type": "swish",
102
+ "pad_token_id": null,
103
+ "partial_rotary_factor": 0.25,
104
+ "rms_norm_eps": 1e-06,
105
+ "rope_parameters": {
106
+ "mrope_interleaved": true,
107
+ "mrope_section": [
108
+ 11,
109
+ 11,
110
+ 10
111
+ ],
112
+ "partial_rotary_factor": 0.25,
113
+ "rope_theta": 10000000,
114
+ "rope_type": "default"
115
+ },
116
+ "tie_word_embeddings": false,
117
+ "use_cache": true,
118
+ "vocab_size": 248320
119
+ },
120
+ "tie_word_embeddings": false,
121
+ "transformers_version": "5.17.0",
122
+ "video_token_id": 248057,
123
+ "vision_config": {
124
+ "deepstack_visual_indexes": [],
125
+ "depth": 27,
126
+ "hidden_act": "gelu_pytorch_tanh",
127
+ "hidden_size": 1152,
128
+ "in_channels": 3,
129
+ "initializer_range": 0.02,
130
+ "intermediate_size": 4304,
131
+ "model_type": "qwen3_5_vision",
132
+ "num_heads": 16,
133
+ "num_position_embeddings": 2304,
134
+ "out_hidden_size": 5120,
135
+ "patch_size": 16,
136
+ "rope_parameters": {
137
+ "rope_theta": 10000.0,
138
+ "rope_type": "axial"
139
+ },
140
+ "spatial_merge_size": 2,
141
+ "temporal_patch_size": 2
142
+ },
143
+ "vision_end_token_id": 248054,
144
+ "vision_start_token_id": 248053
145
+ }
decision_config.json ADDED
@@ -0,0 +1,817 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format_version": 1,
3
+ "format_id": "apus-code-readout-v1",
4
+ "prompt": "apus",
5
+ "codes": [
6
+ "A",
7
+ "B",
8
+ "C",
9
+ "D",
10
+ "E",
11
+ "F",
12
+ "G",
13
+ "H",
14
+ "I",
15
+ "J",
16
+ "K",
17
+ "L",
18
+ "M",
19
+ "N",
20
+ "O",
21
+ "P",
22
+ "Q",
23
+ "R",
24
+ "S",
25
+ "T",
26
+ "U",
27
+ "V",
28
+ "W",
29
+ "X",
30
+ "Y",
31
+ "Z",
32
+ "AA",
33
+ "AB",
34
+ "AC",
35
+ "AD",
36
+ "AE",
37
+ "AF",
38
+ "AG",
39
+ "AH",
40
+ "AI",
41
+ "AJ",
42
+ "AK",
43
+ "AL",
44
+ "AM",
45
+ "AN",
46
+ "AO",
47
+ "AP",
48
+ "AQ",
49
+ "AR",
50
+ "AS",
51
+ "AT",
52
+ "AU",
53
+ "AV",
54
+ "AW",
55
+ "AX",
56
+ "AY",
57
+ "AZ",
58
+ "BA",
59
+ "BB",
60
+ "BC",
61
+ "BD",
62
+ "BE",
63
+ "BF",
64
+ "BG",
65
+ "BH",
66
+ "BI",
67
+ "BJ",
68
+ "BK",
69
+ "BL",
70
+ "BM",
71
+ "BN",
72
+ "BO",
73
+ "BP",
74
+ "BR",
75
+ "BS",
76
+ "BT",
77
+ "BU",
78
+ "BV",
79
+ "BW",
80
+ "BX",
81
+ "BY",
82
+ "CA",
83
+ "CB",
84
+ "CC",
85
+ "CD",
86
+ "CE",
87
+ "CF",
88
+ "CG",
89
+ "CH",
90
+ "CI",
91
+ "CK",
92
+ "CL",
93
+ "CM",
94
+ "CN",
95
+ "CO",
96
+ "CP",
97
+ "CR",
98
+ "CS",
99
+ "CT",
100
+ "CU",
101
+ "CV",
102
+ "CW",
103
+ "CX",
104
+ "CY",
105
+ "DA",
106
+ "DB",
107
+ "DC",
108
+ "DD",
109
+ "DE",
110
+ "DF",
111
+ "DG",
112
+ "DH",
113
+ "DI",
114
+ "DJ",
115
+ "DK",
116
+ "DL",
117
+ "DM",
118
+ "DN",
119
+ "DO",
120
+ "DP",
121
+ "DR",
122
+ "DS",
123
+ "DT",
124
+ "DU",
125
+ "DV",
126
+ "DW",
127
+ "DX",
128
+ "DY",
129
+ "EA",
130
+ "EB",
131
+ "EC",
132
+ "ED",
133
+ "EE",
134
+ "EF",
135
+ "EG",
136
+ "EH",
137
+ "EI",
138
+ "EK",
139
+ "EL",
140
+ "EM",
141
+ "EN",
142
+ "EO",
143
+ "EP",
144
+ "EQ",
145
+ "ER",
146
+ "ES",
147
+ "ET",
148
+ "EU",
149
+ "EV",
150
+ "EW",
151
+ "EX",
152
+ "EZ",
153
+ "FA",
154
+ "FB",
155
+ "FC",
156
+ "FD",
157
+ "FE",
158
+ "FF",
159
+ "FG",
160
+ "FH",
161
+ "FI",
162
+ "FK",
163
+ "FL",
164
+ "FM",
165
+ "FN",
166
+ "FO",
167
+ "FP",
168
+ "FR",
169
+ "FS",
170
+ "FT",
171
+ "FU",
172
+ "FW",
173
+ "FX",
174
+ "FY",
175
+ "GA",
176
+ "GB",
177
+ "GC",
178
+ "GD",
179
+ "GE",
180
+ "GF",
181
+ "GG",
182
+ "GH",
183
+ "GI",
184
+ "GL",
185
+ "GM",
186
+ "GN",
187
+ "GO",
188
+ "GP",
189
+ "GR",
190
+ "GS",
191
+ "GT",
192
+ "GU",
193
+ "GV",
194
+ "GW",
195
+ "GX",
196
+ "GY",
197
+ "HA",
198
+ "HB",
199
+ "HC",
200
+ "HD",
201
+ "HE",
202
+ "HF",
203
+ "HG",
204
+ "HH",
205
+ "HI",
206
+ "HK",
207
+ "HL",
208
+ "HM",
209
+ "HN",
210
+ "HO",
211
+ "HP",
212
+ "HQ",
213
+ "HR",
214
+ "HS",
215
+ "HT",
216
+ "HU",
217
+ "HV",
218
+ "HW",
219
+ "HX",
220
+ "HY",
221
+ "HZ",
222
+ "IA",
223
+ "IB",
224
+ "IC",
225
+ "ID",
226
+ "IE",
227
+ "IF",
228
+ "IG",
229
+ "IH",
230
+ "II",
231
+ "IJ",
232
+ "IK",
233
+ "IL",
234
+ "IM",
235
+ "IN",
236
+ "IO",
237
+ "IP",
238
+ "IQ",
239
+ "IR",
240
+ "IS",
241
+ "IT",
242
+ "IU",
243
+ "IV",
244
+ "IW",
245
+ "IX",
246
+ "IZ",
247
+ "JA",
248
+ "JB",
249
+ "JC",
250
+ "JD",
251
+ "JE",
252
+ "JI",
253
+ "JJ",
254
+ "JK",
255
+ "JM",
256
+ "JO",
257
+ "JP",
258
+ "JR",
259
+ "JS",
260
+ "JT"
261
+ ],
262
+ "token_ids": [
263
+ 32,
264
+ 33,
265
+ 34,
266
+ 35,
267
+ 36,
268
+ 37,
269
+ 38,
270
+ 39,
271
+ 40,
272
+ 41,
273
+ 42,
274
+ 43,
275
+ 44,
276
+ 45,
277
+ 46,
278
+ 47,
279
+ 48,
280
+ 49,
281
+ 50,
282
+ 51,
283
+ 52,
284
+ 53,
285
+ 54,
286
+ 55,
287
+ 56,
288
+ 57,
289
+ 5840,
290
+ 1803,
291
+ 1646,
292
+ 1745,
293
+ 13276,
294
+ 8018,
295
+ 1825,
296
+ 28946,
297
+ 15015,
298
+ 29595,
299
+ 11568,
300
+ 939,
301
+ 1354,
302
+ 1058,
303
+ 18183,
304
+ 2456,
305
+ 88898,
306
+ 905,
307
+ 1846,
308
+ 802,
309
+ 33869,
310
+ 7839,
311
+ 14006,
312
+ 2860,
313
+ 2926,
314
+ 22828,
315
+ 6844,
316
+ 9798,
317
+ 4738,
318
+ 9265,
319
+ 11261,
320
+ 19278,
321
+ 36513,
322
+ 93801,
323
+ 8335,
324
+ 14544,
325
+ 85266,
326
+ 9110,
327
+ 28000,
328
+ 15137,
329
+ 4525,
330
+ 25261,
331
+ 12717,
332
+ 7116,
333
+ 17078,
334
+ 14497,
335
+ 57339,
336
+ 74909,
337
+ 52072,
338
+ 19305,
339
+ 4887,
340
+ 12607,
341
+ 3580,
342
+ 6281,
343
+ 2036,
344
+ 9362,
345
+ 8533,
346
+ 2080,
347
+ 10911,
348
+ 2925,
349
+ 3040,
350
+ 9690,
351
+ 27731,
352
+ 8023,
353
+ 6901,
354
+ 8702,
355
+ 6211,
356
+ 1123,
357
+ 16307,
358
+ 18990,
359
+ 64045,
360
+ 63037,
361
+ 33380,
362
+ 6151,
363
+ 3392,
364
+ 5449,
365
+ 3967,
366
+ 1113,
367
+ 5095,
368
+ 51923,
369
+ 49600,
370
+ 17099,
371
+ 51483,
372
+ 17756,
373
+ 16037,
374
+ 8135,
375
+ 30237,
376
+ 5683,
377
+ 9992,
378
+ 7444,
379
+ 5751,
380
+ 10284,
381
+ 20887,
382
+ 59884,
383
+ 52396,
384
+ 16103,
385
+ 67547,
386
+ 18535,
387
+ 8006,
388
+ 7263,
389
+ 1425,
390
+ 6878,
391
+ 14453,
392
+ 9097,
393
+ 44072,
394
+ 76089,
395
+ 68720,
396
+ 2662,
397
+ 2629,
398
+ 923,
399
+ 6548,
400
+ 8924,
401
+ 52194,
402
+ 622,
403
+ 1515,
404
+ 1300,
405
+ 37523,
406
+ 44473,
407
+ 36530,
408
+ 3152,
409
+ 93924,
410
+ 3505,
411
+ 15731,
412
+ 6542,
413
+ 14176,
414
+ 11091,
415
+ 1686,
416
+ 11660,
417
+ 80440,
418
+ 18836,
419
+ 26132,
420
+ 5934,
421
+ 24794,
422
+ 40229,
423
+ 3660,
424
+ 11361,
425
+ 10191,
426
+ 8225,
427
+ 3860,
428
+ 78413,
429
+ 17680,
430
+ 15900,
431
+ 78138,
432
+ 15653,
433
+ 5213,
434
+ 22150,
435
+ 39500,
436
+ 10460,
437
+ 35131,
438
+ 21563,
439
+ 43194,
440
+ 27127,
441
+ 3697,
442
+ 20011,
443
+ 24368,
444
+ 15058,
445
+ 23658,
446
+ 8362,
447
+ 16035,
448
+ 24583,
449
+ 52857,
450
+ 38403,
451
+ 60456,
452
+ 81519,
453
+ 40097,
454
+ 16522,
455
+ 29722,
456
+ 21756,
457
+ 18567,
458
+ 1736,
459
+ 48043,
460
+ 87013,
461
+ 22456,
462
+ 23165,
463
+ 55523,
464
+ 13097,
465
+ 50397,
466
+ 41741,
467
+ 23073,
468
+ 6401,
469
+ 86538,
470
+ 16585,
471
+ 11622,
472
+ 2464,
473
+ 84982,
474
+ 75516,
475
+ 36984,
476
+ 58795,
477
+ 47217,
478
+ 59675,
479
+ 5681,
480
+ 3151,
481
+ 1271,
482
+ 887,
483
+ 5203,
484
+ 2685,
485
+ 1849,
486
+ 72470,
487
+ 5370,
488
+ 74063,
489
+ 27629,
490
+ 1655,
491
+ 1728,
492
+ 669,
493
+ 3682,
494
+ 3191,
495
+ 59865,
496
+ 2712,
497
+ 1580,
498
+ 922,
499
+ 77243,
500
+ 2990,
501
+ 78493,
502
+ 5228,
503
+ 2750,
504
+ 42711,
505
+ 44568,
506
+ 56402,
507
+ 48236,
508
+ 38993,
509
+ 43559,
510
+ 61250,
511
+ 32942,
512
+ 86302,
513
+ 25310,
514
+ 26313,
515
+ 81770,
516
+ 12185,
517
+ 78382
518
+ ],
519
+ "temperature": 1.0,
520
+ "temperature_by_questions": {
521
+ "max_questions": [
522
+ 1,
523
+ 4,
524
+ 16
525
+ ],
526
+ "temperature": [
527
+ 1.046,
528
+ 1.0,
529
+ 1.0,
530
+ 1.0
531
+ ]
532
+ },
533
+ "attention_mode": "prefix_bidir",
534
+ "pooling": "last",
535
+ "max_length": null,
536
+ "readout_dtype": "float32",
537
+ "validated_length": 131072,
538
+ "systemone": {
539
+ "question_types": [
540
+ "box",
541
+ "track"
542
+ ],
543
+ "image_placements": [
544
+ "state",
545
+ "instructions",
546
+ "criteria"
547
+ ],
548
+ "track_rates": [
549
+ 1,
550
+ 2
551
+ ],
552
+ "box_calibration": [
553
+ [
554
+ 0.0,
555
+ 0.0
556
+ ],
557
+ [
558
+ 0.001953,
559
+ 0.0
560
+ ],
561
+ [
562
+ 0.003906,
563
+ 0.0
564
+ ],
565
+ [
566
+ 0.005859,
567
+ 0.048387
568
+ ],
569
+ [
570
+ 0.013672,
571
+ 0.05
572
+ ],
573
+ [
574
+ 0.019531,
575
+ 0.1
576
+ ],
577
+ [
578
+ 0.027344,
579
+ 0.140351
580
+ ],
581
+ [
582
+ 0.052734,
583
+ 0.163265
584
+ ],
585
+ [
586
+ 0.078125,
587
+ 0.236842
588
+ ],
589
+ [
590
+ 0.109375,
591
+ 0.255814
592
+ ],
593
+ [
594
+ 0.140625,
595
+ 0.3
596
+ ],
597
+ [
598
+ 0.152344,
599
+ 0.4
600
+ ],
601
+ [
602
+ 0.169922,
603
+ 0.457831
604
+ ],
605
+ [
606
+ 0.269531,
607
+ 0.457831
608
+ ],
609
+ [
610
+ 0.271484,
611
+ 0.461538
612
+ ],
613
+ [
614
+ 0.279297,
615
+ 0.590909
616
+ ],
617
+ [
618
+ 0.300781,
619
+ 0.666667
620
+ ],
621
+ [
622
+ 0.302734,
623
+ 0.666667
624
+ ],
625
+ [
626
+ 0.3125,
627
+ 0.666667
628
+ ],
629
+ [
630
+ 0.314453,
631
+ 0.666667
632
+ ],
633
+ [
634
+ 0.316406,
635
+ 0.715909
636
+ ],
637
+ [
638
+ 0.386719,
639
+ 0.727273
640
+ ],
641
+ [
642
+ 0.423828,
643
+ 0.75
644
+ ],
645
+ [
646
+ 0.427734,
647
+ 0.765957
648
+ ],
649
+ [
650
+ 0.460938,
651
+ 0.8
652
+ ],
653
+ [
654
+ 0.484375,
655
+ 0.8
656
+ ],
657
+ [
658
+ 0.486328,
659
+ 0.803571
660
+ ],
661
+ [
662
+ 0.556641,
663
+ 0.869565
664
+ ],
665
+ [
666
+ 0.566406,
667
+ 0.923077
668
+ ],
669
+ [
670
+ 0.572266,
671
+ 0.946915
672
+ ],
673
+ [
674
+ 0.783203,
675
+ 0.960784
676
+ ],
677
+ [
678
+ 0.8125,
679
+ 0.963636
680
+ ],
681
+ [
682
+ 0.832031,
683
+ 0.97037
684
+ ],
685
+ [
686
+ 0.871094,
687
+ 0.989474
688
+ ],
689
+ [
690
+ 0.880859,
691
+ 0.989664
692
+ ],
693
+ [
694
+ 0.90625,
695
+ 0.990291
696
+ ],
697
+ [
698
+ 0.923828,
699
+ 0.990654
700
+ ],
701
+ [
702
+ 0.927734,
703
+ 0.991525
704
+ ],
705
+ [
706
+ 0.931641,
707
+ 0.994083
708
+ ],
709
+ [
710
+ 0.9375,
711
+ 0.998043
712
+ ],
713
+ [
714
+ 0.951172,
715
+ 1.0
716
+ ],
717
+ [
718
+ 0.953125,
719
+ 1.0
720
+ ],
721
+ [
722
+ 0.955078,
723
+ 1.0
724
+ ],
725
+ [
726
+ 0.957031,
727
+ 1.0
728
+ ],
729
+ [
730
+ 0.958984,
731
+ 1.0
732
+ ],
733
+ [
734
+ 0.960938,
735
+ 1.0
736
+ ],
737
+ [
738
+ 0.962891,
739
+ 1.0
740
+ ],
741
+ [
742
+ 0.964844,
743
+ 1.0
744
+ ],
745
+ [
746
+ 0.966797,
747
+ 1.0
748
+ ],
749
+ [
750
+ 0.96875,
751
+ 1.0
752
+ ],
753
+ [
754
+ 0.970703,
755
+ 1.0
756
+ ],
757
+ [
758
+ 0.972656,
759
+ 1.0
760
+ ],
761
+ [
762
+ 0.974609,
763
+ 1.0
764
+ ],
765
+ [
766
+ 0.976562,
767
+ 1.0
768
+ ],
769
+ [
770
+ 0.978516,
771
+ 1.0
772
+ ],
773
+ [
774
+ 0.980469,
775
+ 1.0
776
+ ],
777
+ [
778
+ 0.982422,
779
+ 1.0
780
+ ],
781
+ [
782
+ 0.984375,
783
+ 1.0
784
+ ],
785
+ [
786
+ 0.986328,
787
+ 1.0
788
+ ],
789
+ [
790
+ 0.988281,
791
+ 1.0
792
+ ],
793
+ [
794
+ 0.990234,
795
+ 1.0
796
+ ],
797
+ [
798
+ 0.992188,
799
+ 1.0
800
+ ],
801
+ [
802
+ 0.994141,
803
+ 1.0
804
+ ],
805
+ [
806
+ 0.996094,
807
+ 1.0
808
+ ],
809
+ [
810
+ 0.998047,
811
+ 1.0
812
+ ]
813
+ ],
814
+ "box_video_max_seconds": 60
815
+ },
816
+ "prompt_layout": "header-v1"
817
+ }
deploy.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ pkg=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
4
+ exec "${PYTHON_BIN:-python3}" "$pkg/serve.py" "$@"
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 16777216,
4
+ "shortest_edge": 65536
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "image_processor_type": "Qwen2VLImageProcessorFast"
21
+ }
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ vllm==0.33.0
2
+ torch==2.14.0
3
+ transformers==5.20.2
4
+ triton==3.8.0
serve.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Serve APUS-Reflex2.1 using an isolated runtime view of a read-only checkpoint."""
2
+
3
+ import argparse
4
+ import json
5
+ import os
6
+ from pathlib import Path
7
+ import signal
8
+ import subprocess
9
+ import sys
10
+ import sysconfig
11
+ import tempfile
12
+
13
+ MODEL_ID = "APUS-Reflex2.1"
14
+ PACKAGE = Path(__file__).resolve().parent
15
+ INPUT_FILES = (
16
+ "config.json",
17
+ "model.safetensors.index.json",
18
+ "readout.safetensors",
19
+ "tokenizer.json",
20
+ "tokenizer_config.json",
21
+ "vocab.json",
22
+ "merges.txt",
23
+ "chat_template.jinja",
24
+ "preprocessor_config.json",
25
+ "video_preprocessor_config.json",
26
+ )
27
+
28
+
29
+ def build_view(model, view):
30
+ index = json.loads((model / "model.safetensors.index.json").read_text())
31
+ shards = sorted(set(index["weight_map"].values()))
32
+ if len(shards) != 11 or any(Path(name).name != name for name in shards):
33
+ raise ValueError("Unexpected model shard layout")
34
+ for name in (*INPUT_FILES, *shards):
35
+ source = model / name
36
+ if not source.is_file():
37
+ raise FileNotFoundError(source)
38
+ (view / name).symlink_to(source.resolve())
39
+ config = json.loads((model / "decision_config.json").read_text())
40
+ if (config["format_id"], config["prompt"], config["attention_mode"]) != (
41
+ "apus-code-readout-v1",
42
+ "apus",
43
+ "prefix_bidir",
44
+ ):
45
+ raise ValueError("Unexpected decision configuration")
46
+ # These are internal renderer identifiers required by the pinned vLLM version.
47
+ config.update(format_id="d3-code-readout-v1", prompt="d3")
48
+ (view / "decision_config.json").write_text(json.dumps(config, indent=2) + "\n")
49
+
50
+
51
+ def main():
52
+ parser = argparse.ArgumentParser(description=__doc__)
53
+ parser.add_argument(
54
+ "--model-dir", type=Path, default=Path(os.environ.get("MODEL_DIR", PACKAGE))
55
+ )
56
+ parser.add_argument("--host", default=os.environ.get("HOST", "127.0.0.1"))
57
+ parser.add_argument("--port", type=int, default=os.environ.get("PORT", 8000))
58
+ parser.add_argument(
59
+ "--tensor-parallel-size",
60
+ type=int,
61
+ default=os.environ.get("TENSOR_PARALLEL_SIZE", 2),
62
+ )
63
+ args = parser.parse_args()
64
+ model = args.model_dir.expanduser().resolve(strict=True)
65
+ if not 1 <= args.port <= 65535 or args.tensor_parallel_size < 1:
66
+ parser.error("Invalid port or tensor parallel size")
67
+ subprocess.run(
68
+ [sys.executable, PACKAGE / "third_party/vllm/install_backport.py"], check=True
69
+ )
70
+ with tempfile.TemporaryDirectory(prefix="APUS-Reflex2.1-") as tmp:
71
+ build_view(model, Path(tmp))
72
+ executable = Path(sysconfig.get_path("scripts")) / "vllm"
73
+ cmd = [
74
+ executable,
75
+ "serve",
76
+ tmp,
77
+ "--host",
78
+ args.host,
79
+ "--port",
80
+ str(args.port),
81
+ "--served-model-name",
82
+ MODEL_ID,
83
+ "--runner",
84
+ "pooling",
85
+ "--tensor-parallel-size",
86
+ str(args.tensor_parallel_size),
87
+ "--attention-backend",
88
+ "TRITON_ATTN",
89
+ "--disable-custom-all-reduce",
90
+ "--enforce-eager",
91
+ "--max-model-len",
92
+ "131072",
93
+ "--max-num-batched-tokens",
94
+ "131072",
95
+ "--max-num-seqs",
96
+ "8",
97
+ "--gpu-memory-utilization",
98
+ "0.85",
99
+ ]
100
+ env = os.environ.copy()
101
+ env.setdefault("VLLM_ALLREDUCE_USE_FLASHINFER", "0")
102
+ process = subprocess.Popen(cmd, env=env)
103
+ for signum in (signal.SIGTERM, signal.SIGINT):
104
+ signal.signal(signum, lambda sig, frame: process.send_signal(sig))
105
+ return process.wait()
106
+
107
+
108
+ if __name__ == "__main__":
109
+ sys.exit(main())
third_party/ATTRIBUTION.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Third-party notices and modifications
2
+
3
+ APUS-Reflex2.1 packages a previously merged checkpoint. The recorded inputs are vllm-sr/d3-ultra at ccdcfa611649a59e095e0b5e1732a15cedafadd6 and tattrongvu/Jeffan-27B-1211 at f0ce7043ca32ebfe6613615e573a5010bda7228a. The merge fraction recorded by the source package is 0.6. The 11 backbone shards and the readout match the files in gump2049/APUS-Reflex2 at revision 6a94f1215c408be3a74f252ce8b6c264b3453c86 by SHA-256. The merged checkpoint has also been distributed under the name APUS-Reflex2.
4
+
5
+ Original license documents are included under LICENSE and third_party/licenses. The original d3-ultra attribution is reproduced in third_party/licenses/NOTICE-upstream.txt. The second source license identifies Copyright 2026 tattrongvu.
6
+
7
+ The vLLM backport contains changes based on upstream vLLM PRs 65996 and 66722, licensed under Apache-2.0. The corresponding base and head revisions are recorded in third_party/vllm/vllm_patch_assets/manifest.json. Third-party module names in this directory and native renderer identifiers in the temporary execution view are used for software compatibility.
8
+
9
+ Distribution changes include removing unused Python auto-loading declarations in the exported configuration, adapting the launcher and verifier to the published model identity, isolating the execution overlay and including a verified vLLM prefix-attention backport installer. Original checkpoint weights and the readout are unchanged.
third_party/licenses/NOTICE-upstream.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ d3-ultra (Decision 3.0)
2
+ Copyright 2026 vLLM Semantic Router Team
third_party/licenses/second-source-Apache-2.0.txt ADDED
@@ -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 2026 tattrongvu
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.
third_party/vllm/install_backport.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Apply the audited D3 PrefixLM backport to an isolated vLLM 0.33.0 venv.
2
+
3
+ Run with that venv's Python. Default is verification only; --apply writes backups.
4
+ No downloads, native compilation, source checkpoint changes, or GPU imports.
5
+ """
6
+
7
+ import argparse
8
+ import hashlib
9
+ import importlib.metadata
10
+ import json
11
+ import shutil
12
+ import subprocess
13
+ import sys
14
+ import tempfile
15
+ import time
16
+ from pathlib import Path
17
+
18
+
19
+ def digest(data):
20
+ """Return the SHA256 of exact file bytes."""
21
+ return hashlib.sha256(data).hexdigest()
22
+
23
+
24
+ def main():
25
+ """Verify and optionally apply the pinned patch with a full backup."""
26
+ parser = argparse.ArgumentParser(description=__doc__)
27
+ parser.add_argument("--apply", action="store_true")
28
+ parser.add_argument(
29
+ "--container-build",
30
+ action="store_true",
31
+ help="allow patching the dedicated image interpreter",
32
+ )
33
+ args = parser.parse_args()
34
+ if args.apply and sys.prefix == sys.base_prefix and not args.container_build:
35
+ raise SystemExit("Use an isolated virtualenv Python")
36
+ dist = importlib.metadata.distribution("vllm")
37
+ if dist.version != "0.33.0":
38
+ raise SystemExit(f"Requires exact vllm 0.33.0, got {dist.version}")
39
+ root = Path(dist.locate_file("")).resolve()
40
+ if not root.is_relative_to(Path(sys.prefix).resolve()):
41
+ raise SystemExit("Refusing a package outside this virtualenv")
42
+ bundle = Path(__file__).with_name("vllm_patch_assets")
43
+ manifest = json.loads((bundle / "manifest.json").read_text())
44
+ patch = (bundle / "d3-prefix-v033.patch").read_bytes()
45
+ if digest(patch) != manifest["patch_sha256"]:
46
+ raise SystemExit("Patch asset hash mismatch")
47
+ originals = {}
48
+ already = []
49
+ for name, hashes in manifest["files"].items():
50
+ rel = Path(name)
51
+ if rel.is_absolute() or ".." in rel.parts or not name.startswith("vllm/"):
52
+ raise SystemExit("Unsafe manifest path")
53
+ path = root / rel
54
+ if path.is_symlink() or not path.resolve().is_relative_to(root):
55
+ raise SystemExit(f"Unsafe package path: {name}")
56
+ data = path.read_bytes()
57
+ actual = digest(data)
58
+ already.append(actual == hashes["patched"])
59
+ if actual not in (hashes["original"], hashes["patched"]):
60
+ raise SystemExit(f"Unrecognized original file hash: {name}: {actual}")
61
+ originals[name] = data
62
+ if all(already):
63
+ print("Already patched; all five output hashes match")
64
+ return
65
+ if any(already):
66
+ raise SystemExit(
67
+ "Mixed patched/unpatched package; restore recorded backup first"
68
+ )
69
+ with tempfile.TemporaryDirectory(prefix="apus-vllm-patch-") as temp:
70
+ stage = Path(temp)
71
+ for name, data in originals.items():
72
+ target = stage / name
73
+ target.parent.mkdir(parents=True, exist_ok=True)
74
+ target.write_bytes(data)
75
+ subprocess.run(
76
+ ["git", "apply", "--check", "-"], input=patch, cwd=stage, check=True
77
+ )
78
+ subprocess.run(["git", "apply", "-"], input=patch, cwd=stage, check=True)
79
+ outputs = {}
80
+ for name, hashes in manifest["files"].items():
81
+ data = (stage / name).read_bytes()
82
+ if digest(data) != hashes["patched"]:
83
+ raise SystemExit(f"Patched hash mismatch: {name}")
84
+ compile(data, name, "exec")
85
+ outputs[name] = data
86
+ if not args.apply:
87
+ raise SystemExit(
88
+ "Backport verified but not installed; run install_backport.py --apply"
89
+ )
90
+ backup = root / f"apus-prefix-backup-{time.time_ns()}"
91
+ backup.mkdir()
92
+ for name, data in originals.items():
93
+ target = backup / name
94
+ target.parent.mkdir(parents=True, exist_ok=True)
95
+ target.write_bytes(data)
96
+ (backup / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n")
97
+ try:
98
+ for name, data in outputs.items():
99
+ path = root / name
100
+ if path.read_bytes() != originals[name]:
101
+ raise RuntimeError(f"Concurrent package modification: {name}")
102
+ candidate = path.with_name(path.name + ".apus-patch-tmp")
103
+ candidate.write_bytes(data)
104
+ shutil.copymode(path, candidate)
105
+ candidate.replace(path)
106
+ except BaseException:
107
+ for name, data in originals.items():
108
+ (root / name).write_bytes(data)
109
+ raise
110
+ print(
111
+ json.dumps(
112
+ {
113
+ "status": "patched",
114
+ "backup": str(backup),
115
+ "patch_sha256": manifest["patch_sha256"],
116
+ }
117
+ )
118
+ )
119
+
120
+
121
+ if __name__ == "__main__":
122
+ main()
third_party/vllm/vllm_patch_assets/d3-prefix-v033.patch ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --- a/vllm/v1/worker/gpu/model_states/default.py
2
+ +++ b/vllm/v1/worker/gpu/model_states/default.py
3
+ @@ -62,7 +62,27 @@
4
+ self.model_config, model, self.rope_state, encoder_cache
5
+ )
6
+
7
+ + # Per-request bidirectional MM ranges. Not kept in the encoder cache:
8
+ + # only the first PP rank has one, but every rank builds attn metadata.
9
+ + self.mm_prefix_ranges: dict[str, list[tuple[int, int]]] | None = None
10
+ + if (
11
+ + self.model_config.supports_multimodal_inputs
12
+ + and self.model_config.is_mm_prefix_lm
13
+ + ):
14
+ + self.mm_prefix_ranges = {}
15
+ +
16
+ def add_request(self, req_index: int, new_req_data: NewRequestData) -> None:
17
+ + if self.mm_prefix_ranges is not None:
18
+ + hf_text_config = self.model_config.hf_text_config
19
+ + self.mm_prefix_ranges[new_req_data.req_id] = compute_mm_prefix_ranges(
20
+ + [new_req_data.mm_features],
21
+ + sliding_window=self.model_config.get_sliding_window(),
22
+ + clamp_sliding_window=getattr(
23
+ + self.model, "mm_prefix_clamp_sliding_window", False
24
+ + )
25
+ + or getattr(hf_text_config, "mm_prefix_clamp_sliding_window", False),
26
+ + span_pad=getattr(self.model, "mm_prefix_span_leading_pad_modulus", 0),
27
+ + )[0]
28
+ if self.rope_state is not None:
29
+ assert new_req_data.prefill_token_ids is not None
30
+ # `prompt_embeds` is a passthrough modality with no grid info, but
31
+ @@ -80,6 +100,8 @@
32
+ self.prompt_embeds_state.add_request(req_index, new_req_data)
33
+
34
+ def remove_request(self, req_id: str) -> None:
35
+ + if self.mm_prefix_ranges is not None:
36
+ + self.mm_prefix_ranges.pop(req_id, None)
37
+ if self.prompt_embeds_state is not None:
38
+ self.prompt_embeds_state.remove_request(req_id)
39
+
40
+ @@ -198,22 +220,11 @@
41
+ else:
42
+ max_seq_len = seq_lens_cpu_upper_bound[:num_reqs].max().item()
43
+ req_doc_ranges: dict[int, list[tuple[int, int]]] | None = None
44
+ - if (
45
+ - self.supports_mm_inputs
46
+ - and self.encoder_cache is not None
47
+ - and self.model_config.is_mm_prefix_lm
48
+ - ):
49
+ - mm_features = self.encoder_cache.mm_features
50
+ - hf_text_config = self.model_config.hf_text_config
51
+ - req_doc_ranges = compute_mm_prefix_ranges(
52
+ - [mm_features.get(req_id, ()) for req_id in input_batch.req_ids],
53
+ - sliding_window=self.model_config.get_sliding_window(),
54
+ - clamp_sliding_window=getattr(
55
+ - self.model, "mm_prefix_clamp_sliding_window", False
56
+ - )
57
+ - or getattr(hf_text_config, "mm_prefix_clamp_sliding_window", False),
58
+ - span_pad=getattr(self.model, "mm_prefix_span_leading_pad_modulus", 0),
59
+ - )
60
+ + if self.mm_prefix_ranges is not None:
61
+ + req_doc_ranges = {
62
+ + i: self.mm_prefix_ranges.get(req_id, [])
63
+ + for i, req_id in enumerate(input_batch.req_ids)
64
+ + }
65
+ dcp_local_seq_lens_cpu_upper_bound = None
66
+ if input_batch.pcp is not None:
67
+ dcp_local_seq_lens_cpu_upper_bound = (
68
+ --- a/vllm/entrypoints/openai/decisions/strategies.py
69
+ +++ b/vllm/entrypoints/openai/decisions/strategies.py
70
+ @@ -1215,6 +1215,9 @@
71
+ #: The runtime reads videos at 2 frames per second, 4 to 32 frames each.
72
+ VIDEO_FPS = 2
73
+ VIDEO_MAX_FRAMES = 32
74
+ + #: `PoolingParams.extra_kwargs` key of a prefix_bidir prompt's state block
75
+ + #: size (`vllm.model_executor.models.d3.STATE_TOKENS`).
76
+ + STATE_TOKENS = "d3_state_tokens"
77
+
78
+ def __init__(self, context: ReadContext):
79
+ super().__init__(context)
80
+ @@ -1224,6 +1227,8 @@
81
+ raise ValueError(f"unknown decision prompt {decision['prompt']!r}")
82
+ self.codes: list[str] = decision["codes"]
83
+ self.temperature = float(decision.get("temperature", 1.0))
84
+ + self.temperature_by_questions = decision.get("temperature_by_questions")
85
+ + self.state_blocks = decision.get("attention_mode") == "prefix_bidir"
86
+ self.max_model_len = model_config.max_model_len
87
+ self.tokenizer = context.online_renderer.renderer.get_tokenizer()
88
+
89
+ @@ -1302,6 +1307,21 @@
90
+ def _tokens(self, text: str) -> list[int]:
91
+ return self.tokenizer.encode(text, add_special_tokens=False)
92
+
93
+ + def _encode(self, text: str, state: str) -> tuple[list[int], int]:
94
+ + """`text`'s tokens and, for prefix_bidir checkpoints, how many lead
95
+ + tokens are its state block: those that end by the end of the state text,
96
+ + so a token straddling it belongs to the question block."""
97
+ + if not self.state_blocks:
98
+ + return self._tokens(text), 0
99
+ + end = text.index(f"State:\n{state}\n\nQuestion:\n") + len(f"State:\n{state}")
100
+ + encoded = self.tokenizer( # type: ignore[call-arg]
101
+ + text, add_special_tokens=False, return_offsets_mapping=True
102
+ + )
103
+ + offsets = encoded["offset_mapping"]
104
+ + return encoded["input_ids"], next(
105
+ + (i for i, (_, stop) in enumerate(offsets) if stop > end), len(offsets)
106
+ + )
107
+ +
108
+ async def _render_media(
109
+ self, prefix: str, media: Mapping[str, Sequence[str]], cache_salt: str | None
110
+ ) -> MultiModalInput:
111
+ @@ -1378,6 +1398,7 @@
112
+
113
+ engine_inputs: list[EngineInput] = []
114
+ prompt_ids: list[list[int]] = []
115
+ + state_tokens: list[int] = []
116
+ if placeholders:
117
+ # The media come first, so every prompt starts with the same
118
+ # prefix, which ends at the last media placeholder.
119
+ @@ -1388,15 +1409,19 @@
120
+ "the questions' prompts do not share their media"
121
+ )
122
+ media_input = await self._render_media(prefix, media or {}, cache_salt)
123
+ + media_ids = media_input["prompt_token_ids"]
124
+ for p in prompts:
125
+ - ids = media_input["prompt_token_ids"] + self._tokens(p[split:])
126
+ + tail, tail_state = self._encode(p[split:], state)
127
+ + ids = media_ids + tail
128
+ engine_inputs.append({**media_input, "prompt_token_ids": ids})
129
+ prompt_ids.append(ids)
130
+ + state_tokens.append(len(media_ids) + tail_state)
131
+ else:
132
+ - prompt_ids = [self._tokens(p) for p in prompts]
133
+ - engine_inputs = [
134
+ - tokens_input(ids, cache_salt=cache_salt) for ids in prompt_ids
135
+ - ]
136
+ + for p in prompts:
137
+ + ids, count = self._encode(p, state)
138
+ + engine_inputs.append(tokens_input(ids, cache_salt=cache_salt))
139
+ + prompt_ids.append(ids)
140
+ + state_tokens.append(count)
141
+ for q, ids in zip(questions, prompt_ids):
142
+ if len(ids) > self.max_model_len:
143
+ raise StructuredDecisionError(
144
+ @@ -1405,10 +1430,14 @@
145
+ )
146
+
147
+ async def read_one(n: int, engine_input: EngineInput) -> list[float]:
148
+ + extra = {self.STATE_TOKENS: state_tokens[n]} if self.state_blocks else None
149
+ + params = PoolingParams(
150
+ + task="classify", use_activation=False, extra_kwargs=extra
151
+ + )
152
+ result = None
153
+ async for result in self.context.engine_client.encode(
154
+ engine_input,
155
+ - PoolingParams(task="classify", use_activation=False),
156
+ + params,
157
+ f"{request_id}-{n}",
158
+ lora_request=lora_request,
159
+ trace_headers=trace_headers,
160
+ @@ -1427,10 +1456,19 @@
161
+ *(read_one(n, inputs) for n, inputs in enumerate(engine_inputs))
162
+ )
163
+
164
+ + # Request-local: concurrent calls must not mutate the shared strategy.
165
+ + temperature = self.temperature
166
+ + if self.temperature_by_questions is not None:
167
+ + table = self.temperature_by_questions
168
+ + temperature = next(
169
+ + (t for b, t in zip(table["max_questions"], table["temperature"])
170
+ + if len(questions) <= b),
171
+ + table["temperature"][-1],
172
+ + )
173
+ reads = []
174
+ for q, ids, code_logits in zip(questions, prompt_ids, logits):
175
+ texts, order = self._options(q)
176
+ - scaled = [v / self.temperature for v in code_logits[: len(texts)]]
177
+ + scaled = [v / temperature for v in code_logits[: len(texts)]]
178
+ probs = label_softmax(scaled)
179
+ reads.append(
180
+ QuestionRead(
181
+ --- a/vllm/model_executor/models/config.py
182
+ +++ b/vllm/model_executor/models/config.py
183
+ @@ -1135,7 +1135,7 @@
184
+ f"unsupported decision_config.json pooling {decision['pooling']!r}"
185
+ )
186
+ attention_mode = decision.get("attention_mode", "causal")
187
+ - if attention_mode not in ("causal", "noncausal_full_attention"):
188
+ + if attention_mode not in ("causal", "noncausal_full_attention", "prefix_bidir"):
189
+ raise ValueError(
190
+ f"unsupported decision_config.json attention_mode {attention_mode!r}"
191
+ )
192
+ @@ -1146,15 +1146,34 @@
193
+ "decision_config.json must list one token id per answer code"
194
+ )
195
+
196
+ - # The full attention layers read the whole prompt in both directions;
197
+ - # the Gated DeltaNet layers stay causal.
198
+ - is_causal = attention_mode == "causal"
199
+ - for config in {
200
+ - id(config): config for config in (hf_config, model_config.hf_text_config)
201
+ - }.values():
202
+ - config.is_causal = is_causal
203
+ + if attention_mode == "prefix_bidir":
204
+ + # The full attention layers stay decoder layers that read each
205
+ + # request's state and question blocks as PrefixLM ranges
206
+ + # (`D3PrefixBidirModelState`). The prompt as a whole is still read
207
+ + # bidirectionally, so chunked prefill and prefix caching stay off.
208
+ + if model_config.hf_text_config is hf_config:
209
+ + raise ValueError("prefix_bidir needs a separate text config")
210
+ + hf_config.is_causal = False
211
+ + else:
212
+ + # The full attention layers read the whole prompt in both
213
+ + # directions; the Gated DeltaNet layers stay causal.
214
+ + is_causal = attention_mode == "causal"
215
+ + for config in {
216
+ + id(config): config
217
+ + for config in (hf_config, model_config.hf_text_config)
218
+ + }.values():
219
+ + config.is_causal = is_causal
220
+ # One readout row per answer code.
221
+ hf_config.id2label = dict(enumerate(codes))
222
+ + # The length the checkpoint was validated at is the default limit;
223
+ + # --max-model-len still reaches the model's positions.
224
+ + validated = decision.get("validated_length")
225
+ + if validated and model_config.original_max_model_len is None:
226
+ + model_config.max_model_len = min(model_config.max_model_len, validated)
227
+ + logger.info(
228
+ + "Using max model len %d, the checkpoint's validated length",
229
+ + model_config.max_model_len,
230
+ + )
231
+
232
+ # Probabilities only exist over a question's own options, so the head
233
+ # returns raw code logits unless activation is requested.
234
+ --- a/vllm/model_executor/models/d3.py
235
+ +++ b/vllm/model_executor/models/d3.py
236
+ @@ -7,6 +7,14 @@
237
+ last prompt token and is served as the `score` head of a classification model.
238
+ `D3ForSequenceClassificationConfig` applies the checkpoint's attention mode and
239
+ label space.
240
+ +
241
+ +Under the `prefix_bidir` attention mode a prompt is a state block (the system
242
+ +turn, the media, `State:` and the state) followed by a question block. The full
243
+ +attention layers read each block in both directions and the question block also
244
+ +reads the state block, so the state never sees a question; the linear-attention
245
+ +layers stay causal. Each request carries its state block's token count in
246
+ +`PoolingParams.extra_kwargs[STATE_TOKENS]`, and `D3PrefixBidirModelState` makes
247
+ +the two blocks the PrefixLM ranges of its attention.
248
+ """
249
+
250
+ from typing import TYPE_CHECKING
251
+ @@ -14,8 +22,12 @@
252
+ from transformers.models.qwen3_vl import Qwen3VLProcessor
253
+
254
+ from vllm.config import VllmConfig
255
+ +from vllm.logger import init_logger
256
+ from vllm.model_executor.model_loader.default_loader import DefaultModelLoader
257
+ from vllm.multimodal import MULTIMODAL_REGISTRY
258
+ +from vllm.platforms import current_platform
259
+ +from vllm.v1.core.sched.output import NewRequestData
260
+ +from vllm.v1.worker.gpu.model_states.default import DefaultModelState
261
+
262
+ from .adapters import as_seq_cls_model
263
+ from .interfaces_base import default_pooling_type
264
+ @@ -23,7 +35,12 @@
265
+ from .qwen3_vl import Qwen3VLDummyInputsBuilder, Qwen3VLMultiModalProcessor
266
+ from .utils import WeightsMapper
267
+
268
+ +logger = init_logger(__name__)
269
+ +
270
+ READOUT_WEIGHTS = "readout.safetensors"
271
+ +# The `PoolingParams.extra_kwargs` key of a `prefix_bidir` request's state block
272
+ +# token count, set by the System One strategy.
273
+ +STATE_TOKENS = "d3_state_tokens"
274
+
275
+ # The media budgets of the checkpoint's runtime (`d3_runtime.py`), which differ
276
+ # from its processor config: images at 65,536 to 1,638,400 pixels, video frames
277
+ @@ -48,6 +65,27 @@
278
+ video.max_video_tokens = VIDEO_FRAME_MAX_PIXELS // factor**2
279
+ video.do_sample_frames = False
280
+ return processor
281
+ +
282
+ +
283
+ +class D3PrefixBidirModelState(DefaultModelState):
284
+ + """The model state of a `prefix_bidir` checkpoint: a request's state block
285
+ + and question block are the PrefixLM ranges of its attention, so the
286
+ + attention is causal across them and bidirectional within each."""
287
+ +
288
+ + def add_request(self, req_index: int, new_req_data: NewRequestData) -> None:
289
+ + super().add_request(req_index, new_req_data)
290
+ + assert self.mm_prefix_ranges is not None
291
+ + params = new_req_data.pooling_params
292
+ + state = (params.extra_kwargs or {}).get(STATE_TOKENS) if params else None
293
+ + length = len(new_req_data.prompt_token_ids or ())
294
+ + if isinstance(state, int) and 0 < state < length:
295
+ + blocks = [(0, state - 1), (state, length - 1)]
296
+ + else:
297
+ + # Without a state block size (warm-up runs, or a request that did
298
+ + # not go through /v1/systemone) the whole prompt is one block.
299
+ + logger.debug_once("A prefix_bidir request has no state block size")
300
+ + blocks = [(0, length - 1)]
301
+ + self.mm_prefix_ranges[new_req_data.req_id] = blocks
302
+
303
+
304
+ if TYPE_CHECKING:
305
+ @@ -81,6 +119,19 @@
306
+ allow_patterns_overrides=[READOUT_WEIGHTS],
307
+ )
308
+ ]
309
+ + if model_config.hf_config.decision_config.get("attention_mode") == (
310
+ + "prefix_bidir"
311
+ + ):
312
+ + # The blocks reach the attention only through backends that read
313
+ + # PrefixLM ranges, which multimodal checkpoints select while their
314
+ + # multimodal inputs are enabled.
315
+ + if not (current_platform.is_cuda_alike() and model_config.is_mm_prefix_lm):
316
+ + raise ValueError(
317
+ + "Decision 3.0 prefix_bidir checkpoints need a CUDA or ROCm "
318
+ + "GPU and multimodal inputs enabled"
319
+ + )
320
+ + # The other attention modes keep the runner's default state.
321
+ + self.get_model_state_cls = lambda: D3PrefixBidirModelState
322
+
323
+ def is_unused_checkpoint_weight(self, name: str) -> bool:
324
+ # The readout's only tensor, loaded through `secondary_weights`. A
325
+ --- a/vllm/transformers_utils/model_arch_config_convertor.py
326
+ +++ b/vllm/transformers_utils/model_arch_config_convertor.py
327
+ @@ -648,6 +648,12 @@
328
+ hf_config.decision_config = get_hf_file_to_dict(
329
+ "decision_config.json", model_path, revision
330
+ )
331
+ + # prefix_bidir attention reads each request's state and question
332
+ + # blocks as PrefixLM ranges, so it needs backends that take them.
333
+ + if (hf_config.decision_config or {}).get(
334
+ + "attention_mode"
335
+ + ) == "prefix_bidir":
336
+ + hf_config.is_mm_prefix_lm = True
337
+ super().__init__(hf_config, hf_text_config, revision)
338
+
339
+
third_party/vllm/vllm_patch_assets/manifest.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "0.33.0",
3
+ "upstream": {
4
+ "65996": {
5
+ "head": "dc929c2df47108d61b47f627fb809721860e8b1b",
6
+ "base": "a6cf455ad952504e97fdbede65360c21ac0dddc7",
7
+ "url": "https://github.com/vllm-project/vllm/pull/65996"
8
+ },
9
+ "66722": {
10
+ "head": "aeaebe3b731fa35f3148a044be8950ca2368b8f8",
11
+ "base": "99af1568ccbacad0064eeaa2a175991e9ef7472c",
12
+ "url": "https://github.com/vllm-project/vllm/pull/66722"
13
+ }
14
+ },
15
+ "files": {
16
+ "vllm/v1/worker/gpu/model_states/default.py": {
17
+ "original": "453eb32c5efef9f4064c333c3e5e714aef3adc16645db1f4a311f8a397860f02",
18
+ "patched": "01410de343f0016263e4d7ac19ad1739887aa632700621c147ba56dd407c98f3"
19
+ },
20
+ "vllm/entrypoints/openai/decisions/strategies.py": {
21
+ "original": "d7e25f1d879cd0dc2d8e38629805a66018a9c63e364572d6cbfee6a9fedd97bb",
22
+ "patched": "24f5fc3f8437235b7aa4bd994a392e635ac6c861284c9f4cdc1219aebef2aa2a"
23
+ },
24
+ "vllm/model_executor/models/config.py": {
25
+ "original": "850156ca9540bdd899ab0a3d4e8bcc5a790acd07b6c2b1848fd906a67eb7424a",
26
+ "patched": "2f92c4f77d2f6ae79e5abafd74f8f4a048e58a31dfcf64a3c894b7d31a5edbf7"
27
+ },
28
+ "vllm/model_executor/models/d3.py": {
29
+ "original": "c632494024c2ce5b4b46ceae209f08ad38bbcc23d358105a6bc730e740f31cc4",
30
+ "patched": "4fea2dab06c76915620c629459a16e01f76f6841d56193f5da008589e400c4dc"
31
+ },
32
+ "vllm/transformers_utils/model_arch_config_convertor.py": {
33
+ "original": "1f3b241ae27c753e3254bf084f532783f75ca232a8a89e128232fdc624e39ba9",
34
+ "patched": "df7a8aa110eb11029055064c12db8a6734f5d1af30571e67957a5c798ec558ae"
35
+ }
36
+ },
37
+ "patch_sha256": "fe3668e8c945ebf4f8a53312f26e9a57d3bcf22caed91b14518d6c9cbfef6b17"
38
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0997f410c57a1f4e53b09e4be8f4a172d90edd9564368fb0847030937229b9f3
3
+ size 12809320
tokenizer_config.json ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "248044": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "248045": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "248046": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "248047": {
29
+ "content": "<|object_ref_start|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "248048": {
37
+ "content": "<|object_ref_end|>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "248049": {
45
+ "content": "<|box_start|>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "248050": {
53
+ "content": "<|box_end|>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "248051": {
61
+ "content": "<|quad_start|>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "248052": {
69
+ "content": "<|quad_end|>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "248053": {
77
+ "content": "<|vision_start|>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "248054": {
85
+ "content": "<|vision_end|>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "248055": {
93
+ "content": "<|vision_pad|>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "248056": {
101
+ "content": "<|image_pad|>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "248057": {
109
+ "content": "<|video_pad|>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "248058": {
117
+ "content": "<tool_call>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": false
123
+ },
124
+ "248059": {
125
+ "content": "</tool_call>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": false
131
+ },
132
+ "248060": {
133
+ "content": "<|fim_prefix|>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": false
139
+ },
140
+ "248061": {
141
+ "content": "<|fim_middle|>",
142
+ "lstrip": false,
143
+ "normalized": false,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": false
147
+ },
148
+ "248062": {
149
+ "content": "<|fim_suffix|>",
150
+ "lstrip": false,
151
+ "normalized": false,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": false
155
+ },
156
+ "248063": {
157
+ "content": "<|fim_pad|>",
158
+ "lstrip": false,
159
+ "normalized": false,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": false
163
+ },
164
+ "248064": {
165
+ "content": "<|repo_name|>",
166
+ "lstrip": false,
167
+ "normalized": false,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": false
171
+ },
172
+ "248065": {
173
+ "content": "<|file_sep|>",
174
+ "lstrip": false,
175
+ "normalized": false,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": false
179
+ },
180
+ "248066": {
181
+ "content": "<tool_response>",
182
+ "lstrip": false,
183
+ "normalized": false,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": false
187
+ },
188
+ "248067": {
189
+ "content": "</tool_response>",
190
+ "lstrip": false,
191
+ "normalized": false,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": false
195
+ },
196
+ "248068": {
197
+ "content": "<think>",
198
+ "lstrip": false,
199
+ "normalized": false,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": false
203
+ },
204
+ "248069": {
205
+ "content": "</think>",
206
+ "lstrip": false,
207
+ "normalized": false,
208
+ "rstrip": false,
209
+ "single_word": false,
210
+ "special": false
211
+ },
212
+ "248070": {
213
+ "content": "<|audio_start|>",
214
+ "lstrip": false,
215
+ "normalized": false,
216
+ "rstrip": false,
217
+ "single_word": false,
218
+ "special": true
219
+ },
220
+ "248071": {
221
+ "content": "<|audio_end|>",
222
+ "lstrip": false,
223
+ "normalized": false,
224
+ "rstrip": false,
225
+ "single_word": false,
226
+ "special": true
227
+ },
228
+ "248072": {
229
+ "content": "<tts_pad>",
230
+ "lstrip": false,
231
+ "normalized": false,
232
+ "rstrip": false,
233
+ "single_word": false,
234
+ "special": true
235
+ },
236
+ "248073": {
237
+ "content": "<tts_text_bos>",
238
+ "lstrip": false,
239
+ "normalized": false,
240
+ "rstrip": false,
241
+ "single_word": false,
242
+ "special": true
243
+ },
244
+ "248074": {
245
+ "content": "<tts_text_eod>",
246
+ "lstrip": false,
247
+ "normalized": false,
248
+ "rstrip": false,
249
+ "single_word": false,
250
+ "special": true
251
+ },
252
+ "248075": {
253
+ "content": "<tts_text_bos_single>",
254
+ "lstrip": false,
255
+ "normalized": false,
256
+ "rstrip": false,
257
+ "single_word": false,
258
+ "special": true
259
+ },
260
+ "248076": {
261
+ "content": "<|audio_pad|>",
262
+ "lstrip": false,
263
+ "normalized": false,
264
+ "rstrip": false,
265
+ "single_word": false,
266
+ "special": true
267
+ }
268
+ },
269
+ "additional_special_tokens": [
270
+ "<|im_start|>",
271
+ "<|im_end|>",
272
+ "<|object_ref_start|>",
273
+ "<|object_ref_end|>",
274
+ "<|box_start|>",
275
+ "<|box_end|>",
276
+ "<|quad_start|>",
277
+ "<|quad_end|>",
278
+ "<|vision_start|>",
279
+ "<|vision_end|>",
280
+ "<|vision_pad|>",
281
+ "<|image_pad|>",
282
+ "<|video_pad|>"
283
+ ],
284
+ "bos_token": null,
285
+ "chat_template": "{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif 'video' in item or item.type == 'video' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- set reasoning_instructions = '' %}\n{%- if enable_thinking is undefined or enable_thinking is true %}\n {%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}\n {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}\n {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}\n {%- endif %}\n {%- if resolved_reasoning_effort == 'xhigh' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}\n {%- elif resolved_reasoning_effort == 'low' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}\n {%- endif %}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {%- if reasoning_instructions %}\n {{- reasoning_instructions + '\\n\\n' }}\n {%- endif %}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '\\n\\n' + content }}\n {%- endif %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + content + '<|im_end|>\\n' }}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" %}\n {%- set content = render_content(message.content, false)|trim %}\n {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {{- raise_exception('No user query found in messages.') }}\n{%- endif %}\n{%- for message in messages %}\n {%- set content = render_content(message.content, true)|trim %}\n {%- if message.role == \"system\" %}\n {%- if not loop.first %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- endif %}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content|trim %}\n {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is defined and tool_call.arguments != '' %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is false %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- else %}\n {{- '<think>\\n' }}\n {%- endif %}\n{%- endif %}",
286
+ "clean_up_tokenization_spaces": false,
287
+ "eos_token": "<|im_end|>",
288
+ "errors": "replace",
289
+ "model_max_length": 262144,
290
+ "pad_token": "<|endoftext|>",
291
+ "split_special_tokens": false,
292
+ "tokenizer_class": "Qwen2Tokenizer",
293
+ "unk_token": null,
294
+ "add_bos_token": false,
295
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
296
+ "extra_special_tokens": {
297
+ "audio_bos_token": "<|audio_start|>",
298
+ "audio_eos_token": "<|audio_end|>",
299
+ "audio_token": "<|audio_pad|>",
300
+ "image_token": "<|image_pad|>",
301
+ "video_token": "<|video_pad|>",
302
+ "vision_bos_token": "<|vision_start|>",
303
+ "vision_eos_token": "<|vision_end|>"
304
+ }
305
+ }
verify.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Verify model identity and three typed probability readouts over System One."""
2
+
3
+ import argparse
4
+ import json
5
+ import math
6
+ import os
7
+ import urllib.request
8
+
9
+ MODEL = "APUS-Reflex2.1"
10
+
11
+
12
+ def call(url, payload=None):
13
+ headers = {"User-Agent": "APUS-Eval/1.0", "Content-Type": "application/json"}
14
+ if os.environ.get("APUS_TOKEN"):
15
+ headers["Authorization"] = "Bearer " + os.environ["APUS_TOKEN"]
16
+ body = json.dumps(payload).encode() if payload is not None else None
17
+ with urllib.request.urlopen(
18
+ urllib.request.Request(url, data=body, headers=headers), timeout=90
19
+ ) as response:
20
+ data = response.read()
21
+ return json.loads(data) if data else {}
22
+
23
+
24
+ def main():
25
+ p = argparse.ArgumentParser(description=__doc__)
26
+ p.add_argument("--url", default="http://127.0.0.1:8000")
27
+ url = p.parse_args().url.rstrip("/")
28
+ call(url + "/health")
29
+ if [x["id"] for x in call(url + "/v1/models")["data"]] != [MODEL]:
30
+ raise ValueError("Unexpected served-model identity")
31
+ req = {
32
+ "model": MODEL,
33
+ "state": "The customer reports a duplicate invoice charge.",
34
+ "questions": {
35
+ "queue": {
36
+ "type": "choice",
37
+ "instructions": "Choose a support queue.",
38
+ "criteria": {"billing": "Billing", "shipping": "Delivery"},
39
+ },
40
+ "duplicate": {"type": "noul", "instructions": "Is the charge duplicated?"},
41
+ "relevance": {
42
+ "type": "score",
43
+ "instructions": "How relevant is this to billing?",
44
+ "criteria": ["unrelated", "partly relevant", "directly relevant"],
45
+ },
46
+ },
47
+ }
48
+ response = call(url + "/v1/systemone", req)
49
+ if response["model"] != MODEL or set(response["answers"]) != set(req["questions"]):
50
+ raise ValueError("Unexpected inference response identity or question keys")
51
+ for key, answer in response["answers"].items():
52
+ prob = answer["probabilities"]
53
+ if (
54
+ answer["type"] != req["questions"][key]["type"]
55
+ or not prob
56
+ or not all(
57
+ math.isfinite(value) and 0 <= value <= 1 for value in prob.values()
58
+ )
59
+ or not math.isclose(sum(prob.values()), 1, abs_tol=1e-5)
60
+ ):
61
+ raise ValueError(f"Invalid probabilities for {key}")
62
+ if key == "queue" and (
63
+ set(prob) != {"billing", "shipping"}
64
+ or prob[answer["choice"]] != max(prob.values())
65
+ ):
66
+ raise ValueError("Invalid choice readout")
67
+ if key == "duplicate":
68
+ yes = "yes" if set(prob) == {"yes", "no"} else "true"
69
+ if set(prob) not in ({"yes", "no"}, {"true", "false"}) or not math.isclose(
70
+ answer["noul"], prob[yes], abs_tol=1e-5
71
+ ):
72
+ raise ValueError("Invalid binary readout")
73
+ if key == "relevance" and (
74
+ set(prob) != {"0", "1", "2"}
75
+ or not math.isclose(
76
+ answer["score"],
77
+ sum(int(level) * val for level, val in prob.items()),
78
+ abs_tol=1e-5,
79
+ )
80
+ ):
81
+ raise ValueError("Invalid ordinal readout")
82
+ print(json.dumps(response, ensure_ascii=False))
83
+
84
+
85
+ if __name__ == "__main__":
86
+ main()
video_preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 25165824,
4
+ "shortest_edge": 4096
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "video_processor_type": "Qwen3VLVideoProcessor"
21
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff