Skip to content

Qwen3moe #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions QEfficient/transformers/models/pytorch_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@
Qwen2Model,
Qwen2RMSNorm,
)
from transformers.models.qwen3_moe.modeling_qwen3_moe import (
Qwen3MoeAttention,
Qwen3MoeDecoderLayer,
Qwen3MoeForCausalLM,
Qwen3MoeModel,
Qwen3MoeRMSNorm,
Qwen3MoeRotaryEmbedding,
Qwen3MoeSparseMoeBlock,
)
from transformers.models.starcoder2.modeling_starcoder2 import (
Starcoder2Attention,
Starcoder2DecoderLayer,
Expand Down Expand Up @@ -303,6 +312,14 @@
QEffQwen2ForCausalLM,
QEffQwen2Model,
)
from QEfficient.transformers.models.qwen3_moe.modeling_qwen3_moe import (
QEffQwen3MoeAttention,
QEffQwen3MoeDecoderLayer,
QEffQwen3MoeForCausalLM,
QEffQwen3MoeModel,
QEffQwen3MoeRotaryEmbedding,
QEffQwen3MoeSparseMoeBlock,
)
from QEfficient.transformers.models.starcoder2.modeling_starcoder2 import (
QEffStarcoder2Attention,
QEFFStarcoder2DecoderLayer,
Expand Down Expand Up @@ -338,6 +355,7 @@ class CustomOpsTransform(ModuleMappingTransform):
MllamaTextRMSNorm: CustomRMSNormAIC,
GraniteRMSNorm: CustomRMSNormAIC,
GraniteMoeRMSNorm: CustomRMSNormAIC,
Qwen3MoeRMSNorm: CustomRMSNormAIC,
Gemma3RMSNorm: QEffGemma3CustomRMSNormAIC,
}

Expand Down Expand Up @@ -388,6 +406,13 @@ class KVCacheTransform(ModuleMappingTransform):
GemmaDecoderLayer: QEffGemmaDecoderLayer,
GemmaModel: QEffGemmaModel,
GemmaForCausalLM: QEffGemmaForCausalLM,
# Qwen3Moe
Copy link
Contributor

Choose a reason for hiding this comment

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

Also updated ReadMe on what all official models will be supported as part of enabling this arch. thanks

Qwen3MoeForCausalLM: QEffQwen3MoeForCausalLM,
Qwen3MoeModel: QEffQwen3MoeModel,
Qwen3MoeDecoderLayer: QEffQwen3MoeDecoderLayer,
Qwen3MoeAttention: QEffQwen3MoeAttention,
Qwen3MoeRotaryEmbedding: QEffQwen3MoeRotaryEmbedding,
Qwen3MoeSparseMoeBlock: QEffQwen3MoeSparseMoeBlock,
# Gemma2
Gemma2Attention: QEffGemma2Attention,
Gemma2DecoderLayer: QEffGemma2DecoderLayer,
Expand Down
6 changes: 6 additions & 0 deletions QEfficient/transformers/models/qwen3_moe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -----------------------------------------------------------------------------
#
# Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
#
# -----------------------------------------------------------------------------
Loading
Loading