An adaptable, Rust and Python-based quantization runtime.
Rust
0
29 commits
updated Sep 10, 2025
Fandango is a production-grade, high-performance framework for optimizing large language model (LLM) inference through advanced quantization techniques, dynamic precision scaling, and intelligent KV-cache management. Built with Rust for maximum performance and memory safety, it provides a comprehensive platform for deploying efficient LLM applications in production environments with enterprise-grade monitoring and deployment capabilities.
Fandango implements a multi-layered architecture with the following core components:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Fandango Architecture โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Web Interface (Yew + WebAssembly) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ API Layer (Actix-Web HTTP/WebSocket Server) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ง Core Engine โ
โ โโโ Quantization Server (Production-Ready) โ
โ โโโ Fused Attention Kernels (CUDA/Metal/CPU) โ
โ โโโ KV-Cache Manager (Dynamic Precision) โ
โ โโโ Visual Workspace (Interactive Pipeline) โ
โ โโโ Cognitive Modeling (MCMC Search) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐พ Storage Layer โ
โ โโโ Learned Storage Structures โ
โ โโโ LSM-Tree with Compaction Agent โ
โ โโโ Nebula Integration (Graph Storage) โ
โ โโโ Cosine Similarity Engine โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Deployment & Orchestration โ
โ โโโ OCaml Deployment Orchestrator โ
โ โโโ Kubernetes Manifests โ
โ โโโ Docker Multi-Stage Builds โ
โ โโโ CI/CD Pipeline (GitHub Actions) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Monitoring & Observability โ
โ โโโ Golden Metrics (Latency/Errors/Throughput) โ
โ โโโ Prometheus + Grafana Integration โ
โ โโโ Health Checks & Probes โ
โ โโโ Performance Benchmarking โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Fandango can be seamlessly integrated as a quantization layer in your ML pipeline. Whether you're working with PyTorch, TensorFlow, or JAX models, Fandango provides:
๐ Learn how to use Fandango as a quantization layer โ
Location: quantization_server/src/main.rs, src/rust/quantization/
Location: src/rust/fused_attention_kernels/
Location: src/rust/kvcache_manager/
Location: src/rust/visual_workspace/
Location: src/rust/cognitive_modeling/
Location: src/rust/storage_engine/
Location: src/rust/integration/, src/rust/nebula_integration/
Location: src/python/
Clone and Build:
git clone https://github.com/zetareticula/fandango.git
cd fandango
# Build quantization server (production component)
cd quantization_server
cargo build --release
Run Production Server:
# Start quantization server on port 8080
cargo run --release
# Test health endpoint
curl http://localhost:8080/health
# Response: {"status":"ok"}
# Test quantization API
curl -X POST http://localhost:8080/api/quantize \
-H "Content-Type: application/json" \
-d '{"model_path": "/tmp/model", "model_name": "llama", "bits": 4, "dims": [512, 512]}'
Docker Deployment:
# Build optimized container
docker build -t fandango:latest .
# Run with health checks
docker run -p 8080:8080 --name fandango-server fandango:latest
Kubernetes Deployment:
# Deploy to Kubernetes
kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/deployment.yaml
# Monitor deployment
kubectl get pods -l app=fandango
kubectl logs -f deployment/fandango-quantization-server
OCaml Deployment Orchestration:
# Build deployment orchestrator
cd deployment
dune build
# Deploy to staging
fandango-deploy deploy --env staging --strategy kubernetes --target staging-cluster
# Run deployment pipeline
fandango-deploy pipeline --config pipeline.json
# Install development dependencies
rustup component add rustfmt clippy
cargo install cargo-watch cargo-audit
# Run development server with hot reload
cargo watch -x "run --bin quantization_server"
# Run comprehensive tests
cargo test --all --verbose
cd quantization_server && cargo test --release
# Run benchmarks
cd quantization_server && cargo bench
# Format and lint
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
Fandango includes a comprehensive Container Circuit Proposition Framework for testing LLM quantization:
# Build the quantization suite
cd examples/llm_quantization_suite
cargo build --release
# Create a quantization circuit for LLaMA-2 7B
./target/release/llm_quantizer create \
--model llama2-7b \
--precision int4 \
--group-size 128 \
--output circuit.json
# Execute the quantization circuit
./target/release/llm_quantizer execute \
--config circuit.json \
--output ./results
# Run comprehensive test suite
./target/release/llm_quantizer test-suite \
--all-models \
--precisions int4 int8 fp16
Key Features:
Supported Models:
meta-llama/Llama-2-7b-hf)mistralai/Mistral-7B-v0.1)codellama/CodeLlama-7b-hf)Performance Results:
The production quantization server provides the following REST API:
GET /health
# Response: {"status":"ok"}
POST /api/quantize
Content-Type: application/json
{
"model_path": "/path/to/model",
"model_name": "llama-7b",
"bits": 4,
"dims": [4096, 4096]
}
# Response:
{
"status": "success",
"model_name": "llama-7b",
"original_size": 16777216,
"quantized_size": 4194304,
"compression_ratio": 4.0
}
POST /api/infer/{model_name}
Content-Type: application/json
{
"input": [1.0, 2.0, 3.0, ...]
}
# Response:
{
"status": "success",
"result": [0.1, 0.8, 0.1, ...],
"error": null
}
use fandango::quantization_server::QuantizedModel;
use candle_core::{Device, Tensor};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create sample model weights
let device = Device::Cpu;
let weights = Tensor::randn(0f32, 1.0, &[1024, 1024], &device)?;
// Quantize to 4-bit
let quantized = QuantizedModel::quantize(&weights, 4)?;
// Perform quantized inference
let input = Tensor::randn(0f32, 1.0, &[1, 1024], &device)?;
let output = quantized.quantized_matmul(&input)?;
println!("Quantized inference completed");
Ok(())
}
| Model | Precision | Memory (GB) | Tokens/s | Compression | Accuracy Loss |
|---|---|---|---|---|---|
| LLaMA-7B | FP16 | 13.5 | 45.2 | 1.0x | 0% |
| LLaMA-7B | 8-bit | 7.8 | 38.7 | 1.7x | <1% |
| LLaMA-7B | 4-bit | 4.2 | 32.1 | 3.2x | <2% |
| LLaMA-13B | FP16 | 26.0 | 28.1 | 1.0x | 0% |
| LLaMA-13B | 4-bit | 8.1 | 24.3 | 3.2x | <2% |
Benchmarks run on NVIDIA A100 80GB GPU
Fandango exposes comprehensive metrics for production monitoring:
quantization_requests_total: Total quantization requestsquantization_duration_seconds: Quantization operation durationquantization_failures_total: Failed quantization attemptsmodel_memory_usage_bytes: Memory usage per loaded modelcache_hit_ratio: KV-cache hit rate percentagefandango/
โโโ ๐ src/rust/ # Core Rust implementation
โ โโโ fused_attention_kernels/ # CUDA/Metal/CPU attention kernels
โ โโโ kvcache_manager/ # Dynamic KV-cache with precision scaling
โ โโโ visual_workspace/ # Interactive pipeline builder
โ โโโ cognitive_modeling/ # MCMC search and Bayesian inference
โ โโโ storage_engine/ # Learned structures and LSM-trees
โ โโโ quantization/ # Bit-level precision control
โ โโโ integration/ # External system connectors
โ โโโ nebula_integration/ # Graph database integration
โโโ ๐ quantization_server/ # Production-ready HTTP server
โ โโโ src/main.rs # Actix-web server implementation
โ โโโ tests/ # Integration and property tests
โ โโโ benches/ # Performance benchmarks
โโโ ๐ examples/ # Comprehensive example applications
โ โโโ llm_quantization_suite/ # ๐ Container Circuit Proposition Framework
โ โโโ src/ # LLM quantization with HuggingFace integration
โ โ โโโ circuit.rs # Container circuit executor
โ โ โโโ huggingface.rs # Safetensors & JSON model loading
โ โ โโโ orchestration.rs # Serverless concurrent MLP processing
โ โ โโโ quantization.rs # Advanced quantization algorithms
โ โ โโโ validation.rs # Comprehensive validation engine
โ โ โโโ bin/main.rs # CLI application
โ โโโ tests/ # Integration tests with real models
โ โโโ benches/ # Performance benchmarks
โ โโโ README.md # Complete usage guide
โโโ ๐ deployment/ # OCaml deployment orchestration
โ โโโ lib/fandango_deploy.ml # Type-safe deployment strategies
โ โโโ bin/main.ml # CLI deployment tool
โ โโโ dune-project # OCaml build configuration
โโโ ๐ k8s/ # Kubernetes manifests
โ โโโ deployment.yaml # Pod deployment with probes
โ โโโ configmap.yaml # Configuration and secrets
โ โโโ monitoring/ # Prometheus + Grafana setup
โโโ ๐ src/python/ # Python bindings and tools
โ โโโ ir_generator.py # Model IR generation
โ โโโ scheduler.py # Task scheduling
โ โโโ mermaid_flow.py # Pipeline visualization
โโโ ๐ .github/workflows/ # CI/CD automation
โ โโโ ci-cd.yml # Multi-stage deployment pipeline
โโโ ๐ docs/ # Comprehensive documentation
โ โโโ QUANTIZATION_LAYER.md # Integration guide
โโโ ๐ Dockerfile # Multi-stage container build
โโโ ๐ docker-compose.yml # Local development stack
โโโ ๐ deploy.sh # Quick deployment script
Quantization Precision Control:
Memory Layout Optimization:
Attention Kernel Fusion:
Container Security:
Kubernetes Integration:
Monitoring Stack:
We welcome contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
For questions or support, please open an issue or reach out to our team at [email protected]
src/ - Rust source code
bin/ - Binary targets including the quantization serverlib.rs - Library rootweb/ - Web server implementationcore/ - Core functionalityquantization_server/ - Standalone quantization server
src/ - Server implementationCargo.toml - Server dependenciesweb-ui/ - Web frontend (Yew + WebAssembly)
src/ - Frontend source codestatic/ - Static assetsThe quantization server provides the following endpoints:
GET /health - Health check endpointPOST /api/quantize - Quantize a modelPOST /api/infer/{model_name} - Run inference with a quantized modelSee QUANTIZATION_SERVER.md for detailed API documentation.
cd web-ui
wasm-pack build --target web --out-name wasm --out-dir ./static
Contributions are welcome! Please read our Contributing Guidelines for details on how to submit pull requests.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
29 commits
Rust
90.6%
OCaml
3.9%
Python
3.1%
HTML
1.5%
An adaptable, Rust and Python-based quantization runtime.
Rust
0
29 commits
updated Sep 10, 2025
Fandango is a production-grade, high-performance framework for optimizing large language model (LLM) inference through advanced quantization techniques, dynamic precision scaling, and intelligent KV-cache management. Built with Rust for maximum performance and memory safety, it provides a comprehensive platform for deploying efficient LLM applications in production environments with enterprise-grade monitoring and deployment capabilities.
Fandango implements a multi-layered architecture with the following core components:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Fandango Architecture โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Web Interface (Yew + WebAssembly) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ API Layer (Actix-Web HTTP/WebSocket Server) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ง Core Engine โ
โ โโโ Quantization Server (Production-Ready) โ
โ โโโ Fused Attention Kernels (CUDA/Metal/CPU) โ
โ โโโ KV-Cache Manager (Dynamic Precision) โ
โ โโโ Visual Workspace (Interactive Pipeline) โ
โ โโโ Cognitive Modeling (MCMC Search) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐พ Storage Layer โ
โ โโโ Learned Storage Structures โ
โ โโโ LSM-Tree with Compaction Agent โ
โ โโโ Nebula Integration (Graph Storage) โ
โ โโโ Cosine Similarity Engine โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Deployment & Orchestration โ
โ โโโ OCaml Deployment Orchestrator โ
โ โโโ Kubernetes Manifests โ
โ โโโ Docker Multi-Stage Builds โ
โ โโโ CI/CD Pipeline (GitHub Actions) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Monitoring & Observability โ
โ โโโ Golden Metrics (Latency/Errors/Throughput) โ
โ โโโ Prometheus + Grafana Integration โ
โ โโโ Health Checks & Probes โ
โ โโโ Performance Benchmarking โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Fandango can be seamlessly integrated as a quantization layer in your ML pipeline. Whether you're working with PyTorch, TensorFlow, or JAX models, Fandango provides:
๐ Learn how to use Fandango as a quantization layer โ
Location: quantization_server/src/main.rs, src/rust/quantization/
Location: src/rust/fused_attention_kernels/
Location: src/rust/kvcache_manager/
Location: src/rust/visual_workspace/
Location: src/rust/cognitive_modeling/
Location: src/rust/storage_engine/
Location: src/rust/integration/, src/rust/nebula_integration/
Location: src/python/
Clone and Build:
git clone https://github.com/zetareticula/fandango.git
cd fandango
# Build quantization server (production component)
cd quantization_server
cargo build --release
Run Production Server:
# Start quantization server on port 8080
cargo run --release
# Test health endpoint
curl http://localhost:8080/health
# Response: {"status":"ok"}
# Test quantization API
curl -X POST http://localhost:8080/api/quantize \
-H "Content-Type: application/json" \
-d '{"model_path": "/tmp/model", "model_name": "llama", "bits": 4, "dims": [512, 512]}'
Docker Deployment:
# Build optimized container
docker build -t fandango:latest .
# Run with health checks
docker run -p 8080:8080 --name fandango-server fandango:latest
Kubernetes Deployment:
# Deploy to Kubernetes
kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/deployment.yaml
# Monitor deployment
kubectl get pods -l app=fandango
kubectl logs -f deployment/fandango-quantization-server
OCaml Deployment Orchestration:
# Build deployment orchestrator
cd deployment
dune build
# Deploy to staging
fandango-deploy deploy --env staging --strategy kubernetes --target staging-cluster
# Run deployment pipeline
fandango-deploy pipeline --config pipeline.json
# Install development dependencies
rustup component add rustfmt clippy
cargo install cargo-watch cargo-audit
# Run development server with hot reload
cargo watch -x "run --bin quantization_server"
# Run comprehensive tests
cargo test --all --verbose
cd quantization_server && cargo test --release
# Run benchmarks
cd quantization_server && cargo bench
# Format and lint
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
Fandango includes a comprehensive Container Circuit Proposition Framework for testing LLM quantization:
# Build the quantization suite
cd examples/llm_quantization_suite
cargo build --release
# Create a quantization circuit for LLaMA-2 7B
./target/release/llm_quantizer create \
--model llama2-7b \
--precision int4 \
--group-size 128 \
--output circuit.json
# Execute the quantization circuit
./target/release/llm_quantizer execute \
--config circuit.json \
--output ./results
# Run comprehensive test suite
./target/release/llm_quantizer test-suite \
--all-models \
--precisions int4 int8 fp16
Key Features:
Supported Models:
meta-llama/Llama-2-7b-hf)mistralai/Mistral-7B-v0.1)codellama/CodeLlama-7b-hf)Performance Results:
The production quantization server provides the following REST API:
GET /health
# Response: {"status":"ok"}
POST /api/quantize
Content-Type: application/json
{
"model_path": "/path/to/model",
"model_name": "llama-7b",
"bits": 4,
"dims": [4096, 4096]
}
# Response:
{
"status": "success",
"model_name": "llama-7b",
"original_size": 16777216,
"quantized_size": 4194304,
"compression_ratio": 4.0
}
POST /api/infer/{model_name}
Content-Type: application/json
{
"input": [1.0, 2.0, 3.0, ...]
}
# Response:
{
"status": "success",
"result": [0.1, 0.8, 0.1, ...],
"error": null
}
use fandango::quantization_server::QuantizedModel;
use candle_core::{Device, Tensor};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create sample model weights
let device = Device::Cpu;
let weights = Tensor::randn(0f32, 1.0, &[1024, 1024], &device)?;
// Quantize to 4-bit
let quantized = QuantizedModel::quantize(&weights, 4)?;
// Perform quantized inference
let input = Tensor::randn(0f32, 1.0, &[1, 1024], &device)?;
let output = quantized.quantized_matmul(&input)?;
println!("Quantized inference completed");
Ok(())
}
| Model | Precision | Memory (GB) | Tokens/s | Compression | Accuracy Loss |
|---|---|---|---|---|---|
| LLaMA-7B | FP16 | 13.5 | 45.2 | 1.0x | 0% |
| LLaMA-7B | 8-bit | 7.8 | 38.7 | 1.7x | <1% |
| LLaMA-7B | 4-bit | 4.2 | 32.1 | 3.2x | <2% |
| LLaMA-13B | FP16 | 26.0 | 28.1 | 1.0x | 0% |
| LLaMA-13B | 4-bit | 8.1 | 24.3 | 3.2x | <2% |
Benchmarks run on NVIDIA A100 80GB GPU
Fandango exposes comprehensive metrics for production monitoring:
quantization_requests_total: Total quantization requestsquantization_duration_seconds: Quantization operation durationquantization_failures_total: Failed quantization attemptsmodel_memory_usage_bytes: Memory usage per loaded modelcache_hit_ratio: KV-cache hit rate percentagefandango/
โโโ ๐ src/rust/ # Core Rust implementation
โ โโโ fused_attention_kernels/ # CUDA/Metal/CPU attention kernels
โ โโโ kvcache_manager/ # Dynamic KV-cache with precision scaling
โ โโโ visual_workspace/ # Interactive pipeline builder
โ โโโ cognitive_modeling/ # MCMC search and Bayesian inference
โ โโโ storage_engine/ # Learned structures and LSM-trees
โ โโโ quantization/ # Bit-level precision control
โ โโโ integration/ # External system connectors
โ โโโ nebula_integration/ # Graph database integration
โโโ ๐ quantization_server/ # Production-ready HTTP server
โ โโโ src/main.rs # Actix-web server implementation
โ โโโ tests/ # Integration and property tests
โ โโโ benches/ # Performance benchmarks
โโโ ๐ examples/ # Comprehensive example applications
โ โโโ llm_quantization_suite/ # ๐ Container Circuit Proposition Framework
โ โโโ src/ # LLM quantization with HuggingFace integration
โ โ โโโ circuit.rs # Container circuit executor
โ โ โโโ huggingface.rs # Safetensors & JSON model loading
โ โ โโโ orchestration.rs # Serverless concurrent MLP processing
โ โ โโโ quantization.rs # Advanced quantization algorithms
โ โ โโโ validation.rs # Comprehensive validation engine
โ โ โโโ bin/main.rs # CLI application
โ โโโ tests/ # Integration tests with real models
โ โโโ benches/ # Performance benchmarks
โ โโโ README.md # Complete usage guide
โโโ ๐ deployment/ # OCaml deployment orchestration
โ โโโ lib/fandango_deploy.ml # Type-safe deployment strategies
โ โโโ bin/main.ml # CLI deployment tool
โ โโโ dune-project # OCaml build configuration
โโโ ๐ k8s/ # Kubernetes manifests
โ โโโ deployment.yaml # Pod deployment with probes
โ โโโ configmap.yaml # Configuration and secrets
โ โโโ monitoring/ # Prometheus + Grafana setup
โโโ ๐ src/python/ # Python bindings and tools
โ โโโ ir_generator.py # Model IR generation
โ โโโ scheduler.py # Task scheduling
โ โโโ mermaid_flow.py # Pipeline visualization
โโโ ๐ .github/workflows/ # CI/CD automation
โ โโโ ci-cd.yml # Multi-stage deployment pipeline
โโโ ๐ docs/ # Comprehensive documentation
โ โโโ QUANTIZATION_LAYER.md # Integration guide
โโโ ๐ Dockerfile # Multi-stage container build
โโโ ๐ docker-compose.yml # Local development stack
โโโ ๐ deploy.sh # Quick deployment script
Quantization Precision Control:
Memory Layout Optimization:
Attention Kernel Fusion:
Container Security:
Kubernetes Integration:
Monitoring Stack:
We welcome contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
For questions or support, please open an issue or reach out to our team at [email protected]
src/ - Rust source code
bin/ - Binary targets including the quantization serverlib.rs - Library rootweb/ - Web server implementationcore/ - Core functionalityquantization_server/ - Standalone quantization server
src/ - Server implementationCargo.toml - Server dependenciesweb-ui/ - Web frontend (Yew + WebAssembly)
src/ - Frontend source codestatic/ - Static assetsThe quantization server provides the following endpoints:
GET /health - Health check endpointPOST /api/quantize - Quantize a modelPOST /api/infer/{model_name} - Run inference with a quantized modelSee QUANTIZATION_SERVER.md for detailed API documentation.
cd web-ui
wasm-pack build --target web --out-name wasm --out-dir ./static
Contributions are welcome! Please read our Contributing Guidelines for details on how to submit pull requests.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
29 commits
Rust
90.6%
OCaml
3.9%
Python
3.1%
HTML
1.5%