Skip to content

Add experimental Qwen3.8 packed hybrid export for ORT GenAI Engine - #738

Draft
titaiwangms with Copilot wants to merge 7 commits into
mainfrom
copilot/add-qwen3-8-packed-hybrid-pagedattention-export
Draft

titaiwangms with Copilot wants to merge 7 commits into
mainfrom
copilot/add-qwen3-8-packed-hybrid-pagedattention-export

Conversation

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Add an opt-in continuous-batching ABI for Qwen3.8 (qwen3_5_text), combining paged full attention with fixed GatedDeltaNet state. Existing dense Qwen and LATENT MLA paths remain unchanged.

  • Packed decoder

    • Dedicated PagedHybridCausalLMTask with [N] tokens and [3, N] positions; no attention mask or slot mapping.
    • SEPARATE K/V PagedAttention preserves Q/K normalization, partial interleaved MRoPE, and output gating.
    • Optional prefix pruning selects each request’s final hidden-state row before the LM head.
  • Recurrent execution

    • Native varlen convolution and GatedDeltaNet consume packed sequence boundaries.
    • Preserve FP32 gate parameters and V-major recurrent state [B, H_v, D_v, D_k].
  • Runtime packaging

    • Graph-verified paged_kv, fixed_conv, and fixed_recurrent groups, explicit state mappings, and dynamic-batching configuration.
    • Workflow metadata describes externally scheduled invocations rather than a dense generation loop.
    • CUDA FP16/BF16 only; reject incompatible task, cache, quantization, and RoPE configurations.
mobius build --model Qwen/Qwen3.8-27B --output qwen-paged/ \
  --ep cuda --dtype f16 --features paged-attention --runtime ort-genai

Qualification: Includes structural, numerical/state-carry, and pinned Engine probes. Native CUDA/Engine execution and full 27B hardware qualification remain outstanding; support is explicitly experimental.

@CLAassistant

CLAassistant commented Sep 16, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ titaiwangms
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Emit native SEPARATE PagedAttention and varlen DeltaNet state, with distinct Engine and workflow state groups. Preserve dense inference and record runtime pins. Add structural, CPU projection parity, and opt-in CUDA state-carry/Engine tests; full CUDA qualification remains outstanding.

Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: titaiwangms <18010845+titaiwangms@users.noreply.github.com>
Comment thread src/mobius/models/qwen35.py Fixed
Declare native output shapes before downstream construction, reject incompatible direct tasks and RoPE configurations, and verify the 64-layer state manifest. Exercise both CLI runtime packagers and strengthen page-reuse coverage. Focused checks: 20 passed, 3 CUDA-dependent skips.

Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: titaiwangms <18010845+titaiwangms@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Qwen3.8 packed hybrid PagedAttention export for ORT GenAI Engine Add experimental Qwen3.8 packed hybrid export for ORT GenAI Engine Sep 16, 2026
Copilot AI requested a review from titaiwangms September 16, 2026 23:15
@titaiwangms
titaiwangms requested a balanced review from Copilot September 16, 2026 23:16
Comment thread src/mobius/models/paged_qwen35_export_test.py Fixed
Comment thread src/mobius/models/qwen35.py Fixed
@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing 99d3155bfeceaa43

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0%
bert (feature-extraction) num_nodes 68 68 +0.0%
falcon model_size_bytes 364 KB 364 KB +0.0%
falcon num_nodes 66 66 +0.0%
gemma2 model_size_bytes 428 KB 428 KB +0.0%
gemma2 num_nodes 105 105 +0.0%
gpt2 model_size_bytes 324 KB 324 KB +0.0%
gpt2 num_nodes 54 54 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 60 60 +0.0%
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0%
llama (static-cache) num_nodes 56 56 +0.0%
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0%
mamba (ssm-text-generation) num_nodes 94 94 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 58 58 +0.0%
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0%
phi3 (static-cache) num_nodes 54 54 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 60 60 +0.0%
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0%
qwen2 (static-cache) num_nodes 56 56 +0.0%
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0%
qwen3_5_moe (hybrid-text-generation) num_nodes 265 265 +0.0%
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0%
qwen3_5_text (hybrid-text-generation) num_nodes 127 127 +0.0%
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0%
qwen3_5_vl (hybrid-qwen-vl) num_nodes 450 450 +0.0%
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0%
t5 (seq2seq) num_nodes 176 176 +0.0%
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0%
whisper (speech-to-text) num_nodes 128 128 +0.0%

No performance regressions.

@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 99d3155bfeceaa43

Model Sub-model Changes Status
bert (feature-extraction) model 0
falcon model 0
gemma2 model 0
gemma4 (gemma4) decoder 0
gemma4 (gemma4) embedding 0
gemma4 (gemma4) vision_encoder 0
gemma4_text model 0
gpt2 model 0
llama model 0
llama (static-cache) model 0
mamba (ssm-text-generation) model 0
phi3 model 0
phi3 (static-cache) model 0
qwen model 0
qwen (static-cache) model 0
qwen2 model 0
qwen2 (static-cache) model 0
qwen2_moe model 0
qwen2_moe (static-cache) model 0
qwen3 model 0
qwen3 (static-cache) model 0
qwen3_5_moe (hybrid-text-generation) model 0
qwen3_5_text (hybrid-text-generation) model 0
qwen3_5_vl (hybrid-qwen-vl) decoder 0
qwen3_5_vl (hybrid-qwen-vl) embedding 0
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0
qwen3_moe model 0
qwen3_moe (static-cache) model 0
qwen3_next (hybrid-text-generation) model 0
t5 (seq2seq) decoder 0
t5 (seq2seq) encoder 0
whisper (speech-to-text) decoder 0
whisper (speech-to-text) encoder 0

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The registered paged task cannot currently enable prefix pruning by task name, and an existing unit-test assertion is broken.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds an experimental packed hybrid Qwen3.8 export path for ORT GenAI continuous batching.

Changes:

  • Adds paged attention and native packed GatedDeltaNet execution.
  • Generates hybrid state-group and dynamic-batching metadata.
  • Adds structural, parity, metadata, and Engine tests.
File summaries
File Description
README.md Documents experimental serving workflow.
src/mobius/__main__.py Routes the paged-attention feature.
src/mobius/_builder.py Validates and configures packed tasks.
src/mobius/components/__init__.py Exports packed context types.
src/mobius/components/_attention.py Adds SEPARATE paged Qwen attention.
src/mobius/components/_gated_deltanet.py Adds native packed recurrence.
src/mobius/components/_paged_attention.py Defines native operator adapters.
src/mobius/components/_rotary_embedding.py Supports packed MRoPE positions.
src/mobius/integrations/_paged_hybrid.py Verifies packed graph ABI.
src/mobius/integrations/onnx_genai/_schema/inference_metadata.schema.json Adds paged-scatter metadata schema.
src/mobius/integrations/onnx_genai/paged_hybrid_metadata_test.py Tests ABI and metadata generation.
src/mobius/integrations/onnx_genai/workflow_metadata.py Publishes externally scheduled workflows.
src/mobius/integrations/ort_genai/auto_export.py Introspects hybrid state groups.
src/mobius/integrations/ort_genai/genai_config.py Emits Engine configuration.
src/mobius/integrations/ort_genai/genai_config_test.py Tests generated Engine fields.
src/mobius/integrations/transformers/_builder.py Selects the packed Qwen task.
src/mobius/models/paged_qwen35_export_test.py Tests packed graph structure.
src/mobius/models/qwen35.py Wires packed execution through Qwen.
src/mobius/tasks/__init__.py Registers the new task.
src/mobius/tasks/_causal_lm.py Implements the packed decoder ABI.
tests/integration/paged_hybrid_test.py Tests CUDA parity and Engine scheduling.
Review details
  • Files reviewed: 21/21 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/mobius/_builder.py
Comment thread src/mobius/components/_rotary_embedding.py Outdated
@titaiwangms

Copy link
Copy Markdown
Contributor

@copilot Please fix advanced security, CIs, code-quality and reviews.

Copilot AI and others added 3 commits September 16, 2026 23:32
Enable prefix pruning when the paged hybrid task is selected by its registered name and cover that dispatch path. Correct the packed MRoPE contract documentation and apply the CI lint fixes.

Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: titaiwangms <18010845+titaiwangms@users.noreply.github.com>
Match Ruff's formatting for the packed prefix-pruning gather after removing the unused paged-attention import.

Signed-off-by: GitHub <noreply@github.com>

Co-authored-by: titaiwangms <18010845+titaiwangms@users.noreply.github.com>

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please fix advanced security, CIs, code-quality and reviews.

Fixed in 370655b and cdff31a. Registered paged-task pruning now works with regression coverage, packed MRoPE docs are accurate, and all Ruff/security findings are resolved. Final-head lint, L1, L3, ORT GenAI fast CPU, benchmark, CodeQL, and security analyses passed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The documented Qwen3.8 command resolves the composite qwen3_5 type and bypasses the new paged-hybrid dispatch.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 22/22 changed files
  • Comments generated: 1
  • Review effort level: Balanced

paged_task_placeholder = isinstance(task, CausalLMTask) and getattr(
task, "_paged_cache", False
)
if model_type == "qwen3_5_text":

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The documented Qwen3.8 checkpoint resolves through the composite model type and bypasses the new packed-hybrid task.

Review details

Suppressed comments (1)

src/mobius/integrations/transformers/_builder.py:642

  • The documented Qwen/Qwen3.8-27B command does not select this branch. That checkpoint has top-level model_type="qwen3_5" with a nested qwen3_5_text config; _select_primary_config() unwraps the text config but retains the top-level type, so module/task resolution has already selected the VL path before this qwen3_5_text check. Route this composite checkpoint to its text backbone before _resolve_module_class() when paged attention is requested, and cover the documented command in a builder/CLI regression test.
        if model_type == "qwen3_5_text":
  • Files reviewed: 22/22 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Verify native packed-state dataflow, operand layouts, and Phase 1 attributes before emitting runtime metadata. Route paged context explicitly, expand malformed-graph coverage, and fix the CI dependency and stale VibeVoice streaming denylist regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: titaiwang <titaiwang@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Qwen3.8 packed hybrid PagedAttention export for ORT GenAI Engine

5 participants