COELANOX is a universal binary container system for AI models that provides secure, fast, and hardware-optimized model deployment. This document describes the architecture of the COELANOX system: security hash, backend manager, and AOT selection.
COELANOX uses a three-command architecture for defense-in-depth security:
coelanox package)Purpose: Create a COELANOX container from a source model.
Process:
.cnox fileKey Features:
Location: coelanox-packager/src/lib.rs
coelanox verify)Purpose: Standalone verification of container integrity.
Process:
Key Features:
Location: coelanox-core/src/format.rs (verify_security_hash)
coelanox run)Purpose: Verify, load, and execute a container.
Process:
Key Features:
Location: coelanox-cli/src/main.rs (run_command)
The security hash is calculated during packaging:
Container Creation: Container is built in memory with all components:
security_hash initially set to [0; 32])Hash Calculation:
security_hash fieldHash Verification:
Location: coelanox-core/src/format.rs
Key Functions:
CoelanoxContainer::write_binary_file() - Calculates and stores hashverify_security_hash() - Verifies container integrityThe Backend Manager discovers and manages CLF (Coelanox Library File) backends. It operates at package time to discover .clfc files for AOT compilation.
For the CLF binary layout, coelanox-clf reader API (ClfReader, get_blob, build_code_section), the canonical op_id registry, and how execution plans tie IR to blobs vs linked SIMD symbols, see sdk/clf.md and sdk/pipeline.md.
Location: coelanox-orchestrator/src/backend_manager.rs
Responsibilities:
Key Methods:
new() - Create new BackendManagerdiscover_backends() - Scan search paths for CLF filesvalidate_backend() - Check if backend existsselect_backend_with_fallback() - Select backend using fallback strategyStructure:
pub struct BackendInfo {
pub name: String, // Backend name (e.g., "nvidia-h100")
pub version: String, // Backend version
pub library_path: PathBuf, // Path to CLF file (.clfc)
pub supported_targets: Vec<HardwareTarget>, // Supported hardware targets
}
Structure:
pub struct DiscoveryResult {
pub discovered: Vec<BackendInfo>, // Successfully discovered backends
pub failures: Vec<(PathBuf, String)>, // Failed paths with error messages
pub total_scanned: usize, // Total files scanned
}
Search Paths: BackendManager scans default search paths:
~/.coelanox/clf/ with subdirs clfc/, clfmm/, clfmp/, clfe/COELANOX_CLF_PATH (override)COELANOX_BACKEND_PATH (extra paths, colon-separated)CLF Detection: Identifies CLF files (.clfc, legacy .clf)
CLF Loading: Reads CLF header to extract backend metadata and supported targets
Registration: Registers valid backends for use during packaging
Location: coelanox-orchestrator/src/backend_manager.rs
Strategies:
PrimaryOnly - Use primary backend only (fail if unavailable)PrimaryWithFallback - Use primary with fallback to scalarTryAll - Try all backends in order until one succeedsAOT (Ahead-of-Time) selection allows choosing which backends to compile into the container at package time. This enables:
Usage: coelanox package --target cpu
Behavior:
--backend-addBackendMetadataMetadata Structure:
BackendSelectionMode::Slim {
primary: String, // Primary backend name
additional: Vec<String>, // Additional backends
}
Usage: coelanox package --fat
Behavior:
BackendMetadataMetadata Structure:
BackendSelectionMode::Fat {
backends: Vec<String>, // All available backends
}
Usage: coelanox package --auto
Behavior:
Metadata Structure:
BackendSelectionMode::Auto {
backends: Vec<String>, // Auto-detected backends
}
Location: coelanox-core/src/format.rs
Structure:
pub struct BackendMetadata {
pub selection_mode: BackendSelectionMode,
pub device_id_mapping: HashMap<usize, String>, // Device ID -> Backend name
}
Device ID Mapping:
Location: coelanox-packager/src/lib.rs
Key Function: determine_backend_selection()
--fat, --auto, --backend-add)BackendMetadata structure┌─────────────────────────────────────────────────────────┐
│ COELANOX Container │
├─────────────────────────────────────────────────────────┤
│ Header (76 bytes) │
│ ├── Magic Number: "COEL" (4 bytes) │
│ ├── Version: 0.1.0.0 (4 bytes) │
│ ├── Security Hash: SHA-256 (32 bytes) │
│ └── Reserved (36 bytes) │
├─────────────────────────────────────────────────────────┤
│ Manifest Length (4 bytes) │
├─────────────────────────────────────────────────────────┤
│ Manifest (JSON) │
│ ├── Model metadata │
│ ├── Input/output shapes │
│ └── Backend metadata (AOT selection) │
├─────────────────────────────────────────────────────────┤
│ Machine Code Length (4 bytes) │
├─────────────────────────────────────────────────────────┤
│ Machine Code (binary) │
├─────────────────────────────────────────────────────────┤
│ Compressed Weights Length (4 bytes) │
├─────────────────────────────────────────────────────────┤
│ Compressed Weights (binary; Zstd/LZ4 or uncompressed) │
├─────────────────────────────────────────────────────────┤
│ IR Data Length (4 bytes) │
├─────────────────────────────────────────────────────────┤
│ IR Data (bincode serialized OptimizedIR) │
└─────────────────────────────────────────────────────────┘
Location: coelanox-core/src/format.rs
pub struct CoelanoxHeader {
pub magic: [u8; 4], // "COEL"
pub version: [u8; 4], // Version bytes
pub security_hash: [u8; 32], // SHA-256 hash
pub reserved: [u8; 36], // Reserved for future use
}
Location: coelanox-core/src/format.rs
pub struct CoelanoxManifest {
pub model_name: String,
pub model_format: ModelFormat,
pub input_shapes: Vec<Vec<usize>>,
pub output_shapes: Vec<Vec<usize>>,
pub machine_code_size: usize,
pub backend_metadata: Option<BackendMetadata>, // AOT selection metadata
}
BackendMetadataLocation: coelanox-orchestrator/src/runtime.rs
Current Implementation:
coelanox-orchestrator/src/fallback/ using coelanox-core scalar opscoelanox-core
├── format.rs # Container format, security hash
├── ir.rs # Universal IR structures
├── error.rs # Error types
└── scalar/ # Scalar operations (reference implementation)
coelanox-packager
├── lib.rs # Packaging logic, AOT selection
├── backend_trait/ # Backend translator trait, op mappings
├── optimizers/ # IR optimization
├── translators/ # Model translators (ONNX, BERT, ResNet)
└── memory/ # NVMe allocator, memory management
coelanox-orchestrator
├── runtime.rs # Runtime execution, container loading
├── backend_manager.rs # Backend discovery and management
├── fallback/ # Scalar fallback (uses coelanox-core scalar)
└── execution_backend.rs # Execution dispatch
coelanox-cli
└── main.rs # CLI commands (package, verify, run)
Location: coelanox-core/src/error.rs
Key Error Variants:
SecurityHashMismatch - Hash verification failedBackendNotFound - Requested backend not availableBackendLibraryNotFound - CLF file not foundBackendDiscoveryFailed - Backend discovery failedDeviceIdOutOfRange - Invalid device IDCoelanoxResult<T> type| Crate | Purpose | Key files |
|---|---|---|
| coelanox-core | Format, IR, scalar ops | format.rs, ir.rs, scalar/ |
| coelanox-packager | Translate → optimize → .cnox | lib.rs, translators/, optimizers/ |
| coelanox-orchestrator | Load, execute (CLF or scalar) | runtime.rs, fallback/ |
| coelanox-executor | Plan walker, kernel dispatch | lib.rs |
| coelanox-clf | CLF reader, op_id registry | reader.rs, op_registry.rs |
| coelanox-cli | Commands | main.rs |
| Section | Offset | Size | Description |
|---|---|---|---|
| Header | 0 | 76 | Magic COEL, version, flags, sizes, SHA-256 hash |
| Manifest | 76 | 4+L | Length (u32 LE) + JSON |
| Code | 76+4+L | manifest.model_size | Machine code (CLF blobs or empty) |
| Weights | next | 4+W | Length + bytes |
| IR data | next | 4+I | Length + bincode OptimizedIR |
| NVMe backing | next | 8+N | Optional |
| CLFMM / CLFMP | next | 8+size | Optional HAL blobs |
OpType (IR) → CLF op_id → kernel blob. Region kinds: Code (executable), Weights (read-only), Intermediates (RW). Protection HAL applies code=X, weights=R, intermediates=RW. See coelanox-core/src/hal_mapping.rs.