optimum-neuron / granite
AGENTS.md270 starsChanged 10 months agoApache-2.0View on GitHub
This directory contains the Neuron-optimized Granite inference implementation. It follows HF Transformers structure with only Neuron-specific graph changes from NxDI. Reference: NxDI Granite implementation Granite shares Llama's architecture and inherits similar removals: Why removed: Requires unstable NKI private APIs. Optimum Neuron uses compiler auto-optimization. Why removed: Production serving features delegated to vLLM integration. Why removed: Optimum uses HF Transformers config base extended via neuron_config.json. Optimum Neuron prioritizes stability and HF compatibility over experimental optimizations.
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/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/qwen3_moe/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
Granite Inference Model Guide
This directory contains the Neuron-optimized Granite inference implementation. It follows HF Transformers structure with only Neuron-specific graph changes from NxDI.
HF reference
- Transformers Granite modeling: https://github.com/huggingface/transformers/tree/main/src/transformers/models/granite
What differs vs HF
- Parallel layers: TP-aware
ColumnParallelLinear/RowParallelLinearandParallelEmbedding. - Attention base: Uses
NeuronAttentionBaseutilities instead of HF attention. - Static shapes & KV cache: Enforced by
neuron_config.jsonandKVCacheManager.
What was removed from NxDI
Reference: NxDI Granite implementation
Granite shares Llama's architecture and inherits similar removals:
Removed NKI Kernel Implementations
- MLP TKG kernel - Small batch/sequence optimization with NKI primitives
- Quantized MLP kernels - INT8 quantization with fused RMSNorm-Quantize
- NKI-based MLP - Hand-optimized kernels using neuronxcc.nki APIs
Why removed: Requires unstable NKI private APIs. Optimum Neuron uses compiler auto-optimization.
Removed Serving/Speculative Features
- EAGLE/EAGLE3 draft models - Speculative decoding support
- Medusa heads - Multi-head speculative sampling
- Flash Decoding - Multi-query decode parallelism
- LoRA serving - Dynamic adapter switching
- Context parallelism (CP) - MLP splitting for long contexts
Why removed: Production serving features delegated to vLLM integration.
Removed Configuration/Infrastructure
- NxDI config classes (
InferenceConfig,NeuronConfig) - Replaced byNxDNeuronConfig - Module registration - Plugin architecture for implementation swapping
- Preshard hooks - Weight sharding orchestration
- Custom RMSNorm variants - CPU/NXD mode switching
Why removed: Optimum uses HF Transformers config base extended via neuron_config.json.
What Optimum Neuron Keeps
- Core parallel layers (
ColumnParallelLinear,RowParallelLinear,ParallelEmbedding) NeuronAttentionBasewith GQA and flash attention- Rotary embeddings with RoPE scaling
- State dict conversion (QKV fusion, rank tensors)
- Model structure (decoder layers, embeddings, norms)
Optimum Neuron prioritizes stability and HF compatibility over experimental optimizations.
Key files
- optimum/neuron/models/inference/granite/modeling_granite.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.

