agentleFS
Hugging FaceKnown publisherhuggingface/optimum-neuron/optimum/neuron/models/inference/mixtral/AGENTS.md

optimum-neuron / mixtral

AGENTS.md270 starsChanged 10 months agoApache-2.0View on GitHub

This directory contains the Neuron-optimized Mixtral (MoE) inference implementation. It follows HF Transformers architecture with Neuron-specific changes derived from NxDI. Reference: NxDI Mixtral implementation Mixtral is a Mixture-of-Experts (MoE) model with additional MoE-specific removals: Why removed: Requires unstable NKI APIs. Compiler handles expert optimization automatically. Why removed: Complex serving optimizations for production MoE deployments. Focus on foundational MoE export/inference. Why removed: Optimum uses standardized MoE configuration via neuron_config.json. Optimum Neuron provides stable foundational MoE support while delegating advanced serving to…

The file

Files
AGENTS.md

Mixtral Inference Model Guide (MoE)

This directory contains the Neuron-optimized Mixtral (MoE) inference implementation. It follows HF Transformers architecture with Neuron-specific changes derived from NxDI.

HF reference

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 instead of per-expert nn.Linear stacks.
  • KV cache/static shapes: Uses KVCacheManager and fixed sequence_length/batch_size.

What was removed from NxDI

Reference: NxDI Mixtral implementation

Mixtral is a Mixture-of-Experts (MoE) model with additional MoE-specific removals:

Removed NKI Kernel Implementations

  • MLP TKG kernel - Small batch optimization for expert MLPs
  • Quantized MLP kernels - INT8 quantization for experts
  • NKI-based expert MLP - Hand-optimized expert computation
  • Fused expert routing kernels - Combined routing + expert execution

Why removed: Requires unstable NKI APIs. Compiler handles expert optimization automatically.

Removed MoE-Specific Serving Features

  • Dynamic expert capacity - Runtime expert token allocation
  • Expert load balancing hooks - Custom load balancing strategies
  • Expert caching - Cached expert activations for repeated tokens
  • Hierarchical expert parallelism - Multi-level EP/TP decomposition
  • EAGLE/Medusa with MoE - Speculative decoding for MoE models

Why removed: Complex serving optimizations for production MoE deployments. Focus on foundational MoE export/inference.

Removed Configuration/Infrastructure

  • NxDI MoE configs - Custom expert parallelism configuration
  • Expert module registration - Plugin system for expert implementations
  • Preshard hooks for experts - Expert weight distribution logic
  • Expert quantization helpers - Per-expert quantization control

Why removed: Optimum uses standardized MoE configuration via neuron_config.json.

What Optimum Neuron Keeps

  • Expert parallel layers with TP/EP sharding
  • Static expert routing with compiled shapes
  • NeuronAttentionBase with GQA and flash attention
  • Expert MLP parallelization
  • State dict conversion for expert weights
  • Router logits computation

Optimum Neuron provides stable foundational MoE support while delegating advanced serving to vLLM.

Key files

  • optimum/neuron/models/inference/mixtral/modeling_mixtral.py
  • optimum/neuron/models/inference/backend/modules/attention/attention_base.py

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.