optimum-neuron / qwen3_moe
AGENTS.md270 starsChanged 10 months agoApache-2.0View on GitHub
This directory contains the Neuron-optimized Qwen3 MoE inference implementation. It follows HF Transformers architecture with Neuron-specific changes from NxDI. Reference: NxDI Qwen3 MoE implementation Qwen3 MoE is a Mixture-of-Experts model with MoE-specific removals: Why removed: Requires unstable NKI APIs. Compiler handles MoE optimization. Why removed: Complex MoE serving optimizations for production. Focus on foundational support. Why removed: Optimum uses standardized config via neuron_config.json. Optimum Neuron provides stable foundational MoE support with vLLM for advanced serving.
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- optimum/neuron/cache/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/backend/modules/attention/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/gemma3/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/granite/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/llama4/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/llama/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/mixtral/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/phi3/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/qwen2/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/qwen3/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/smollm3/AGENTS.mdAGENTS.md
- optimum/neuron/models/inference/smolvlm/AGENTS.mdAGENTS.md
- optimum/neuron/vllm/AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- optimum/neuron/cache/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/gemma3/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/granite/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/llama4/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/llama/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/mixtral/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/phi3/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/qwen2/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/qwen3/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/qwen3_moe/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/smollm3/CLAUDE.mdCLAUDE.md
- optimum/neuron/models/inference/smolvlm/CLAUDE.mdCLAUDE.md
- optimum/neuron/vllm/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
The file
Files
Qwen3 MoE Inference Model Guide
This directory contains the Neuron-optimized Qwen3 MoE inference implementation. It follows HF Transformers architecture with Neuron-specific changes from NxDI.
HF reference
- Transformers Qwen3 MoE modeling: https://github.com/huggingface/transformers/tree/main/src/transformers/models/qwen3_moe
What differs vs HF
- Expert parallelism: Routing and expert weights are sharded for TP/EP.
- Static expert shapes: Router logits and capacity are compiled into fixed shapes.
- Parallel MLP/FFN: Expert MLPs use parallel layers or fused kernels.
- KV cache/static shapes: Uses
KVCacheManagerand fixed shapes.
What was removed from NxDI
Reference: NxDI Qwen3 MoE implementation
Qwen3 MoE is a Mixture-of-Experts model with MoE-specific removals:
Removed NKI Kernel Implementations
- MLP TKG kernel for experts - Small batch optimization for expert MLPs
- Quantized expert kernels - INT8 quantization for expert computation
- NKI-based expert MLP - Hand-optimized expert implementations
- Fused routing + execution - Combined router and expert kernels
Why removed: Requires unstable NKI APIs. Compiler handles MoE optimization.
Removed MoE-Specific Serving Features
- Dynamic expert capacity - Runtime token allocation to experts
- Expert load balancing - Custom balancing strategies
- Expert caching - Cached activations for repeated patterns
- Hierarchical EP/TP - Multi-level expert parallelism
- EAGLE/Medusa for MoE - Speculative decoding with experts
Why removed: Complex MoE serving optimizations for production. Focus on foundational support.
Removed Configuration/Infrastructure
- NxDI MoE configs - Custom expert parallelism settings
- Expert module registration - Plugin system for experts
- Expert preshard hooks - Weight distribution for experts
- Per-expert quantization - Fine-grained quantization control
Why removed: Optimum uses standardized config via neuron_config.json.
What Optimum Neuron Keeps
- Expert parallel layers with TP/EP sharding
- Static expert routing with fixed shapes
NeuronAttentionBasewith GQA and flash attention- Expert MLP parallelization
- State dict conversion for expert weights
- Shared expert computation
Optimum Neuron provides stable foundational MoE support with vLLM for advanced serving.
Key files
- optimum/neuron/models/inference/qwen3_moe/modeling_qwen3_moe.py
- optimum/neuron/models/inference/backend/modules/attention/attention_base.py
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

