sageLLM: Modular LLM inference engine for domestic computing power (Huawei Ascend, NVIDIA)
Project description
sageLLM
🚀 Modular LLM Inference Engine for Domestic Computing Power
Ollama-like experience for Chinese hardware ecosystems (Huawei Ascend, NVIDIA)
✨ Features
- 🎯 One-Click Install -
pip install isagellmgets you started immediately - 🔌 Mock-First - Test without GPU, perfect for CI/CD
- 🇨🇳 Domestic Hardware - First-class support for Huawei Ascend NPU
- 📊 Observable - Built-in metrics (TTFT, TBT, throughput, KV usage)
- 🧩 Plugin System - Extend with custom backends and engines
📦 Quick Install
# Install sageLLM (includes mock backend, no GPU required)
pip install isagellm
# With Control Plane (request routing & scheduling)
pip install 'isagellm[control-plane]'
# With API Gateway (OpenAI-compatible REST API)
pip install 'isagellm[gateway]'
# Full server (Control Plane + Gateway)
pip install 'isagellm[server]'
# With CUDA support
pip install 'isagellm[cuda]'
# All features
pip install 'isagellm[all]'
🚀 Quick Start
CLI (like ollama)
# Show system info
sage-llm info
# Default mode (CPU engine, no GPU required)
sage-llm serve
sage-llm run -p "What is LLM inference?"
# Mock mode (CI / fast smoke tests)
sage-llm serve --mock
sage-llm run -p "What is LLM inference?" --mock
# Production mode (requires control-plane)
# pip install 'isagellm[server]'
sage-llm serve --control-plane
sage-llm gateway --port 8080
Python API
from sagellm import BackendConfig, EngineConfig, Request, create_backend, create_engine
# Create CPU backend + engine (no GPU needed)
backend = create_backend(BackendConfig(kind="cpu", device="cpu"))
engine = create_engine(
EngineConfig(kind="cpu", model="sshleifer/tiny-gpt2", device="cpu"),
backend,
)
# Run inference
request = Request(
request_id="demo-001",
prompt="Hello, world!",
max_tokens=128,
)
response = engine.generate(request)
print(f"Response: {response.text}")
print(f"TTFT: {response.metrics.ttft_ms:.2f} ms")
print(f"Throughput: {response.metrics.throughput_tps:.2f} tokens/s")
Configuration
# ~/.sage-llm/config.yaml
backend:
kind: cpu # Options: cpu, mock, cuda, ascend
device: cpu
engine:
kind: cpu
model: sshleifer/tiny-gpt2
control_plane:
endpoint: "localhost:8080"
📊 Metrics & Validation
sageLLM provides comprehensive performance metrics:
{
"ttft_ms": 45.2,
"tbt_ms": 12.5,
"throughput_tps": 80.0,
"peak_mem_mb": 24576,
"kv_used_tokens": 4096,
"prefix_hit_rate": 0.85
}
Run benchmarks:
sage-llm demo --workload year1 --output metrics.json
🏗️ Architecture
isagellm (umbrella package)
├── isagellm-protocol # Protocol v0.1 types
│ └── Request, Response, Metrics, Error, StreamEvent
├── isagellm-core # Runtime & Demo Runner
│ └── Config, Engine, Factory, DemoRunner
├── isagellm-backend # Hardware abstraction
│ └── BackendProvider, MockBackend, (CUDABackend, AscendBackend)
├── isagellm-control-plane # Request routing & scheduling (optional)
│ └── ControlPlaneManager, Router, Policies, Lifecycle
└── isagellm-gateway # OpenAI-compatible REST API (optional)
└── FastAPI server, /v1/chat/completions, Session management
🔧 Development
Quick Setup (Development Mode)
# Clone all repositories
./scripts/clone-all-repos.sh
# Install all packages in editable mode
./quickstart.sh
# Open all repos in VS Code Multi-root Workspace
code sagellm.code-workspace
📖 See WORKSPACE_GUIDE.md for Multi-root Workspace usage.
Testing
# Clone and setup
git clone https://github.com/IntelliStream/sagellm.git
cd sagellm
pip install -e ".[dev]"
# Run tests
pytest -v
# Format & lint
ruff format .
ruff check . --fix
# Type check
mypy src/sagellm/
# Verify dependency hierarchy
python scripts/verify_dependencies.py
📖 Development Resources
- DEPLOYMENT_GUIDE.md - 完整部署与配置指南
- TROUBLESHOOTING.md - 故障排查快速参考
- ENVIRONMENT_VARIABLES.md - 环境变量完整参考
- DEVELOPER_GUIDE.md - 开发者指南
- WORKSPACE_GUIDE.md - Multi-root Workspace 使用
- INFERENCE_FLOW.md - 推理流程详解
- PR_CHECKLIST.md - Pull Request 检查清单
📚 Documentation Index
用户文档
开发者文档
- 开发指南 - 贡献代码
- 架构设计 - 系统架构
- Workspace 使用 - Multi-root 工作区
- PR 检查清单 - 提交前检查
API 文档
- OpenAI 兼容 API - 参见 sagellm-gateway
- Python API - 参见 API_REFERENCE.md(待补充)
子包文档
-
sagellm-protocol - 协议定义
-
sagellm-backend - 后端抽象
-
sagellm-core - 引擎核心
-
sagellm-control-plane - 控制面
-
sagellm-gateway - API 网关
-
sagellm-benchmark - 基准测试
-
DEVELOPER_GUIDE.md - 架构规范与开发指南
-
PR_CHECKLIST.md - Pull Request 审查清单
-
scripts/verify_dependencies.py - 依赖层次验证
📚 Package Details
| Package | PyPI Name | Import Name | Description |
|---|---|---|---|
| sagellm | isagellm |
sagellm |
Umbrella package (install this) |
| sagellm-protocol | isagellm-protocol |
sagellm_protocol |
Protocol v0.1 types |
| sagellm-core | isagellm-core |
sagellm_core |
Runtime & config |
| sagellm-backend | isagellm-backend |
sagellm_backend |
Hardware abstraction |
📄 License
Proprietary - IntelliStream. Internal use only.
Built with ❤️ by IntelliStream Team for domestic AI infrastructure
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file isagellm-0.2.0.0-cp311-none-any.whl.
File metadata
- Download URL: isagellm-0.2.0.0-cp311-none-any.whl
- Upload date:
- Size: 53.0 kB
- Tags: CPython 3.11
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98e5f020f6248cd5cb1ce04204cb0605992e3cd96d8d7d375cc9d9d8ad442c57
|
|
| MD5 |
3c15ba447d13b3c25de8d3db2c27bf71
|
|
| BLAKE2b-256 |
a11f305332339749bfdab472d0683313b331ac913ec2b9782c5e819eee432583
|