Manzana
Safe Rust interfaces to Apple hardware for Sovereign AI
Overview
Manzana (Spanish: "apple") provides safe, pure Rust interfaces to Apple hardware subsystems for the Sovereign AI Stack. It enables on-premise, privacy-preserving machine learning workloads on macOS by exposing Apple-specific accelerators through memory-safe abstractions.
Supported Hardware
| Accelerator | Module | Mac Pro | Apple Silicon | Intel Mac |
|---|---|---|---|---|
| Afterburner FPGA | afterburner |
✓ | - | - |
| Neural Engine | neural_engine |
- | ✓ | - |
| Metal GPU | metal |
✓ | ✓ | ✓ |
| Secure Enclave | secure_enclave |
T2 | ✓ | T2 |
| Unified Memory | unified_memory |
- | ✓ | - |
Installation
Add to your Cargo.toml:
[]
= "0.1"
Feature Flags
[]
= []
= [] # Mac Pro Afterburner support
= [] # Apple Silicon Neural Engine
= [] # Metal GPU compute
= [] # Secure Enclave signing
= ["afterburner", "neural-engine", "metal", "secure-enclave"]
Quick Start
Hardware Discovery
use ;
Secure Enclave Signing
use ;
Metal GPU Compute
use MetalCompute;
Neural Engine Inference
use NeuralEngineSession;
Examples
Run the included examples:
# Discover all available Apple hardware
# Secure Enclave P-256 ECDSA signing demo
# Metal GPU compute demo
Safety Architecture
Manzana follows a strict safety architecture with all unsafe code quarantined in the FFI layer:
+-------------------------------------------------------------+
| PUBLIC API (100% Safe Rust) |
| #![deny(unsafe_code)] |
| |
| +-------------+ +-------------+ +-------------+ +---------+|
| | Afterburner | |NeuralEngine | | Metal | | Secure ||
| | Monitor | | Session | | Compute | | Enclave ||
| +------+------+ +------+------+ +------+------+ +----+----+|
+---------+---------------+---------------+-----------+-------+
| | | |
v v v v
+-----------------------------------------------------------+
| FFI QUARANTINE ZONE |
| #![allow(unsafe_code)] - Audited, MIRI-verified |
| src/ffi/iokit.rs | src/ffi/security.rs |
+-----------------------------------------------------------+
+---------+---------------+---------------+-----------+-------+
| macOS KERNEL / FRAMEWORKS |
| IOKit.framework | CoreML.framework | Metal | Security |
+-------------------------------------------------------------+
Quality Metrics
| Metric | Value |
|---|---|
| Tests | 174 passing |
| Clippy | 0 warnings (pedantic + nursery) |
| Unsafe Code | FFI quarantine only |
| Documentation | 100% public API |
Use Cases
-
Afterburner FPGA (Mac Pro 2019+)
- ProRes video decode acceleration for ML training data pipelines
- 23x 4K streams or 6x 8K streams simultaneous decode
- Real-time stream monitoring via
AfterburnerMonitor
-
Neural Engine (Apple Silicon)
- CoreML model inference at 15.8+ TOPS
- Zero-copy with Unified Memory Architecture
- Privacy-preserving on-device inference
-
Metal GPU (All Macs)
- General-purpose GPU compute
- Multi-GPU support (Mac Pro dual GPUs)
- SIMD acceleration
-
Secure Enclave (T2/Apple Silicon)
- P-256 ECDSA signing for model attestation
- Hardware-bound keys (non-extractable)
- Biometric authentication support (Touch ID/Face ID)
-
Unified Memory (Apple Silicon)
- Zero-copy CPU/GPU data sharing
- Page-aligned buffers for Metal
- Efficient ML tensor management
Part of the Sovereign AI Stack
Manzana is part of the Batuta Sovereign AI orchestration stack:
+---------------------------------------------------------------------+
| BATUTA ORCHESTRATION |
| |
| +----------+ +----------+ +----------+ +----------------------+ |
| | realizar | | repartir | | entrenar | | manzana | |
| | (exec) | | (sched) | | (train) | | (Apple hardware) | |
| +----+-----+ +----+-----+ +----+-----+ +----------+-----------+ |
| | | | | |
| +-------------+-------------+-------------------+ |
| | |
| +------v------+ |
| | trueno | |
| | (compute) | |
| +-------------+ |
+---------------------------------------------------------------------+
License
MIT License - see LICENSE for details.