Skip to main content

Ommi LLM

Run 70B+ LLMs on consumer GPUs with layer-wise inference

Ommi LLM is a memory-efficient inference engine that enables running large language models with 70B+ parameters on consumer GPUs with limited VRAM (4-8GB) through innovative layer-wise processing.

PyPI version License: MIT

🌟 Features

  • 🚀 Layer-wise Inference: Process one transformer layer at a time, using only ~4GB VRAM for 70B models
  • 🧠 Meta Device Pattern: Virtual model skeleton with zero memory footprint
  • 💾 SafeTensor Sharding: Pre-shard models for efficient layer-by-layer disk loading
  • ⚡ Async Prefetching: Overlap I/O with computation using ThreadPoolExecutor
  • 🔧 Quantization Support: 4-bit and 8-bit compression for 3x speedup
  • 🎯 Multi-Architecture: Supports Llama, Mistral, Qwen, Mixtral, Baichuan, ChatGLM, InternLM
  • 🔗 MCP Server: Model management via Model Context Protocol
  • 🎨 Skill System: Pluggable optimizations for different use cases

📊 Performance

Model VRAM Required Speed (tok/s)
Llama 3.1 405B 8 GB 2.1
Llama 2/3 70B 4 GB 4.3
Mixtral 8x7B 6 GB 3.8
Qwen-72B 4 GB 4.1
Platypus2-70B 4 GB 4.5

🚀 Quick Start

Installation

pip install ommi-llm

Basic Usage

from ommi_llm import AutoModel

# Load a 70B model on a 4GB GPU
model = AutoModel.from_pretrained("meta-llama/Llama-2-70b-chat")

# Generate
output = model.generate(
    "What is the capital of France?",
    max_new_tokens=100,
    temperature=0.7
)

print(output)

CLI Usage

# Show memory stats
ommi memory

# Generate text
ommi generate "meta-llama/Llama-2-70b-chat" "What is quantum computing?"

# Shard a model for faster loading
ommi shard "meta-llama/Llama-2-70b-chat" ./sharded-model

# List supported architectures
ommi list-architectures

🏗️ Architecture

Core Concepts

Layer-wise Inference: Instead of loading the entire model into GPU memory, ommi llm processes one transformer layer at a time:

  1. Load layer N weights from disk
  2. Compute forward pass
  3. Immediately free layer N memory
  4. Repeat for layer N+1

Memory Strategy:

  • Single layer: ~1.6 GB
  • Hidden states: ~0.4 GB
  • KV cache: ~30 MB
  • Total peak: ~4 GB for 70B models

Project Structure

ommi-llm/
├── src/ommi_llm/
│   ├── core/           # Inference engine
│   │   ├── engine.py   # Layer-wise forward pass
│   │   └── auto_model.py  # Architecture detection
│   ├── adapters/       # Model-specific implementations
│   │   ├── llama.py
│   │   ├── mistral.py
│   │   └── ...
│   ├── persistence/    # Model sharding & loading
│   │   ├── loader.py
│   │   └── sharder.py
│   ├── server/         # MCP server
│   │   └── mcp_server.py
│   ├── skills/         # Pluggable optimizations
│   │   └── registry.py
│   └── utils/          # Utilities
│       ├── memory.py
│       └── constants.py
├── examples/           # Usage examples
├── docs/              # Documentation
└── tests/             # Test suite

🔧 Advanced Usage

Quantization

# 4-bit quantization for 3x speedup
model = AutoModel.from_pretrained(
    "meta-llama/Llama-2-70b-chat",
    compression="4bit"
)

Custom Configuration

from ommi_llm import AutoModel
from ommi_llm.skills.registry import get_skill_registry

# Load model with skills
model = AutoModel.from_pretrained(
    "mistralai/Mistral-7B",
    device="cuda",
    dtype="bfloat16",
    prefetching=True
)

# Apply skills
registry = get_skill_registry()
registry.apply_skill("flash_attention", model)
registry.apply_skill("kv_cache", model, {"max_cache_size": 2048})

MCP Server

# Start MCP server
python -m ommi_llm.server.mcp_server

Tools available:

  • load_model: Load models from HuggingFace
  • generate: Run inference
  • shard_model: Pre-shard models for efficiency
  • get_model_info: Query model metadata
  • unload_model: Free memory

Model Sharding

from ommi_llm.persistence.sharder import ModelSharder

# Pre-shard model for faster inference
sharder = ModelSharder(
    "meta-llama/Llama-2-70b-chat",
    output_path="./sharded-model",
    compression="4bit"
)

sharder.shard_model(delete_original=False)

🎯 Supported Models

  • Llama: 7B, 13B, 30B, 65B, 70B, 405B
  • Llama 2: 7B, 13B, 70B
  • Llama 3/3.1: 8B, 70B, 405B
  • Mistral: 7B
  • Mixtral: 8x7B, 8x22B
  • Qwen/Qwen2: 7B, 14B, 72B
  • Baichuan: 7B, 13B
  • ChatGLM: 6B
  • InternLM: 7B, 20B

💡 How It Works

The Problem

Running a 70B parameter model in FP16 normally requires:

  • Model weights: 140 GB VRAM
  • Activations: Additional memory
  • Total: 150+ GB VRAM (impossible on consumer GPUs)

The Solution

Layer-wise inference treats transformers as a divide-and-conquer problem:

# Instead of loading all 80 layers:
model = load_entire_model()  # 140GB - IMPOSSIBLE

# Process one layer at a time:
for layer in layers:
    weights = load_layer_weights(layer)     # 1.6GB
    output = compute_layer(weights, input)  # Fast!
    unload_layer(layer)                     # Free memory
    input = output

Trade-offs

Aspect Impact
Memory ✅ 4GB VRAM for 70B models
Speed ⚠️ 35-100+ seconds per token
Disk ⚠️ 2x model size for sharding
Accuracy ✅ Full precision maintained

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

📄 License

MIT License - see LICENSE for details.

🙏 Acknowledgments

📬 Contact

Metadata

Release files for ommi-llm 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ommi-llm 0.2.3
File Size Uploaded
ommi_llm-0.2.3.tar.gz 37.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ommi-llm 0.2.3
File Interpreter ABI Platform
ommi_llm-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 85.1 kB

Release files / ommi_llm-0.2.3.tar.gz

Download URL ommi_llm-0.2.3.tar.gz
Size 37.0 kB
Tags Source
SHA-256 checksum
How to use checksums
18b60bb9c6a03c9225fd1b0c7fa01c0096e61c02b6c5aa0d92b5ff43a7cad518
BLAKE2b-256 checksum
How to use checksums
e92d8a97a39ebf6262d4ab4d4619afea8a68890c9057e2f09bceaff57ec4efda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / ommi_llm-0.2.3-py3-none-any.whl

Download URL ommi_llm-0.2.3-py3-none-any.whl
Size 48.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4130bd6aa9cbbd1b08a530395f8aeeafbb89135fda964ffe0fed4d91e55c8676
BLAKE2b-256 checksum
How to use checksums
8e9aad0cc4298a575381ec9ec52f636ef3c6aeb686cedf9c92e9ab1f8cf819b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page