Skip to content

examples/models/qwen3_5_moe: CUDA Engine/Session adapter + OpenAI serving#20043

Open
mergennachin wants to merge 6 commits into
gh/mergennachin/6/headfrom
gh/mergennachin/7/head
Open

examples/models/qwen3_5_moe: CUDA Engine/Session adapter + OpenAI serving#20043
mergennachin wants to merge 6 commits into
gh/mergennachin/6/headfrom
gh/mergennachin/7/head

Conversation

@mergennachin

@mergennachin mergennachin commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Implement Qwen35MoEEngine / Qwen35MoESession (the model-agnostic
LLMEngine / LLMSession contract) over the exported prefill/decode methods.
serving_capacity() reports a single physical session; the model is
hybrid_recurrent with seek() NotSupported (no prefix reuse). main.cpp is a thin
CLI over the engine/session.

OpenAI serving runs process-isolated and model execution stays in C++: serve.py
is the control plane (FastAPI, chat templating, Qwen XML tool parsing,
validation; no CUDA, no pybind) and spawns qwen3_5_moe_worker
(qwen35_moe_worker.cpp), a C++ worker that constructs the engine and one session
and speaks the same JSONL protocol as the generic text worker. Executing the
AOTI CUDA model inside a live asyncio server process segfaults in the int4
matmul; isolating it in a plain worker process makes serving reliable while
loading weights once. Single-slot: concurrent requests queue. Tool calls use the
Qwen XML <function=...> format (QwenFunctionCallDetector).

Review order: qwen35_moe_engine.{h,cpp} (adapter) and main.cpp; then
qwen35_moe_worker.cpp and serve.py (serving); then tests and docs.

Part of #20001

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20043

Note: Links to docs will display an error until the docs builds have been completed.

❌ 5 New Failures, 1 Pending

As of commit 462416d with merge base eeb0646 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
mergennachin added a commit that referenced this pull request Jun 4, 2026
…ving

Implement Qwen35MoEEngine / Qwen35MoESession (the model-agnostic
LLMEngine / LLMSession contract) over the exported prefill/decode methods.
serving_capacity() reports a single physical session; the model is
hybrid_recurrent with seek() NotSupported (no prefix reuse). main.cpp is a thin
CLI over the engine/session.

OpenAI serving runs process-isolated and model execution stays in C++: serve.py
is the control plane (FastAPI, chat templating, Qwen XML tool parsing,
validation; no CUDA, no pybind) and spawns qwen3_5_moe_worker
(qwen35_moe_worker.cpp), a C++ worker that constructs the engine and one session
and speaks the same JSONL protocol as the generic text worker. Executing the
AOTI CUDA model inside a live asyncio server process segfaults in the int4
matmul; isolating it in a plain worker process makes serving reliable while
loading weights once. Single-slot: concurrent requests queue. Tool calls use the
Qwen XML <function=...> format (QwenFunctionCallDetector).

Review order: qwen35_moe_engine.{h,cpp} (adapter) and main.cpp; then
qwen35_moe_worker.cpp and serve.py (serving); then tests and docs.

ghstack-source-id: ca70937
ghstack-comment-id: 4625142707
Pull-Request: #20043
mergennachin added a commit that referenced this pull request Jun 4, 2026
…ving

Implement Qwen35MoEEngine / Qwen35MoESession (the model-agnostic
LLMEngine / LLMSession contract) over the exported prefill/decode methods.
serving_capacity() reports a single physical session; the model is
hybrid_recurrent with seek() NotSupported (no prefix reuse). main.cpp is a thin
CLI over the engine/session.

OpenAI serving runs process-isolated and model execution stays in C++: serve.py
is the control plane (FastAPI, chat templating, Qwen XML tool parsing,
validation; no CUDA, no pybind) and spawns qwen3_5_moe_worker
(qwen35_moe_worker.cpp), a C++ worker that constructs the engine and one session
and speaks the same JSONL protocol as the generic text worker. Executing the
AOTI CUDA model inside a live asyncio server process segfaults in the int4
matmul; isolating it in a plain worker process makes serving reliable while
loading weights once. Single-slot: concurrent requests queue. Tool calls use the
Qwen XML <function=...> format (QwenFunctionCallDetector).

Review order: qwen35_moe_engine.{h,cpp} (adapter) and main.cpp; then
qwen35_moe_worker.cpp and serve.py (serving); then tests and docs.

ghstack-source-id: ca70937
ghstack-comment-id: 4625142707
Pull-Request: #20043
[ghstack-poisoned]
mergennachin added a commit that referenced this pull request Jun 4, 2026
…ving

Implement Qwen35MoEEngine / Qwen35MoESession (the model-agnostic
LLMEngine / LLMSession contract) over the exported prefill/decode methods.
serving_capacity() reports a single physical session; the model is
hybrid_recurrent with seek() NotSupported (no prefix reuse). main.cpp is a thin
CLI over the engine/session.

OpenAI serving runs process-isolated and model execution stays in C++: serve.py
is the control plane (FastAPI, chat templating, Qwen XML tool parsing,
validation; no CUDA, no pybind) and spawns qwen3_5_moe_worker
(qwen35_moe_worker.cpp), a C++ worker that constructs the engine and one session
and speaks the same JSONL protocol as the generic text worker. Executing the
AOTI CUDA model inside a live asyncio server process segfaults in the int4
matmul; isolating it in a plain worker process makes serving reliable while
loading weights once. Single-slot: concurrent requests queue. Tool calls use the
Qwen XML <function=...> format (QwenFunctionCallDetector).

Review order: qwen35_moe_engine.{h,cpp} (adapter) and main.cpp; then
qwen35_moe_worker.cpp and serve.py (serving); then tests and docs.

ghstack-source-id: 6ae0026
ghstack-comment-id: 4625142707
Pull-Request: #20043
[ghstack-poisoned]
mergennachin added a commit that referenced this pull request Jun 4, 2026
…ving

Implement Qwen35MoEEngine / Qwen35MoESession (the model-agnostic
LLMEngine / LLMSession contract) over the exported prefill/decode methods.
serving_capacity() reports a single physical session; the model is
hybrid_recurrent with seek() NotSupported (no prefix reuse). main.cpp is a thin
CLI over the engine/session.

OpenAI serving runs process-isolated and model execution stays in C++: serve.py
is the control plane (FastAPI, chat templating, Qwen XML tool parsing,
validation; no CUDA, no pybind) and spawns qwen3_5_moe_worker
(qwen35_moe_worker.cpp), a C++ worker that constructs the engine and one session
and speaks the same JSONL protocol as the generic text worker. Executing the
AOTI CUDA model inside a live asyncio server process segfaults in the int4
matmul; isolating it in a plain worker process makes serving reliable while
loading weights once. Single-slot: concurrent requests queue. Tool calls use the
Qwen XML <function=...> format (QwenFunctionCallDetector).

Review order: qwen35_moe_engine.{h,cpp} (adapter) and main.cpp; then
qwen35_moe_worker.cpp and serve.py (serving); then tests and docs.

ghstack-source-id: 4440667
ghstack-comment-id: 4625142707
Pull-Request: #20043
[ghstack-poisoned]
mergennachin added a commit that referenced this pull request Jun 5, 2026
…ving

Implement Qwen35MoEEngine / Qwen35MoESession (the model-agnostic
LLMEngine / LLMSession contract) over the exported prefill/decode methods.
serving_capacity() reports a single physical session; the model is
hybrid_recurrent with seek() NotSupported (no prefix reuse). main.cpp is a thin
CLI over the engine/session.

OpenAI serving runs process-isolated and model execution stays in C++: serve.py
is the control plane (FastAPI, chat templating, Qwen XML tool parsing,
validation; no CUDA, no pybind) and spawns qwen3_5_moe_worker
(qwen35_moe_worker.cpp), a C++ worker that constructs the engine and one session
and speaks the same JSONL protocol as the generic text worker. Executing the
AOTI CUDA model inside a live asyncio server process segfaults in the int4
matmul; isolating it in a plain worker process makes serving reliable while
loading weights once. Single-slot: concurrent requests queue. Tool calls use the
Qwen XML <function=...> format (QwenFunctionCallDetector).

Review order: qwen35_moe_engine.{h,cpp} (adapter) and main.cpp; then
qwen35_moe_worker.cpp and serve.py (serving); then tests and docs.

ghstack-source-id: 4577b1d
ghstack-comment-id: 4625142707
Pull-Request: #20043
@mergennachin mergennachin marked this pull request as ready for review June 5, 2026 19:02
[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant