Universal Hardware-Aware Compute Runtime — Enterprise-grade modular execution stack with C++ safety checking
Project description
UHCR - Universal Hardware-Aware Compute Runtime
Enterprise-Grade Modular Execution Stack with C++ Safety Checking
UHCR is a production-ready Python framework for hardware-optimized computation with comprehensive safety checking, JIT compilation, and enterprise deployment tools.
🚀 Key Features
🛡️ Enterprise Safety (NEW in v5.2)
- C++ Safety Checkers - Native memory bounds, overflow detection, division-by-zero prevention
- Runtime Protection - Stack overflow, heap exhaustion, execution timeout enforcement
- 17 Violation Types - Comprehensive dangerous operation detection
- Python Fallbacks - Full safety even without native library
- All Over Same - Same production continues on pypi, testpypi, github, docs
⚡ Performance
- JIT Compilation - Traces Python functions and compiles to native machine code
- Multi-Backend - CPU (AVX512/AVX2/SSE), CUDA, Metal, ROCm
- SIMD Optimization - Automatic vectorization and hardware feature detection
- Near-Zero Overhead - ~1-2ns safety check latency with native library
🔧 Complete CLI Toolkit (18 Commands)
uhcr compile- AOT compilation with integrity checkinguhcr docker/k8s- Generate deployment manifestsuhcr hw- Comprehensive hardware detectionuhcr safety- Runtime safety managementuhcr mcp_start- AI agent integration (MCP server)- ...and more!
🏢 Enterprise Ready
- Provenance Tracking - Full build metadata and SHA-256 checksums
- Container Support - Docker and Kubernetes manifest generation
- Plugin System - Extensible architecture with TOML manifests
- Type Safety - Full type hints with py.typed marker
📦 Installation
# Basic installation
pip install uhcr
# With enterprise features
pip install uhcr[enterprise]
# With all features
pip install uhcr[all]
# Build native safety library (optional but recommended)
uhcr build
🎯 Quick Start
Basic JIT Compilation
import uhcr
@uhcr.jit(eager=True)
def compute(a, b):
return (a + b) * 2
result = compute(5, 3) # Compiled on first call
With Safety Checking
from uhcr.security import enable_safety_checks, safe_add, safe_mul
# Enable runtime safety
enable_safety_checks()
# Safe operations - automatically checked
result = safe_add(a, b) # Raises SafetyViolation on overflow
result = safe_mul(x, y) # Protected multiplication
Compile for Production
# Compile Python to native with integrity checks
uhcr compile myapp.py --optimize 3
# Creates myapp.uhcrc/ with:
# • source.py - Original code
# • metadata.json - Build provenance
# • checksums.json - SHA-256 integrity
# • __main__.py - Executable runner
# • README.md - Documentation
# Run compiled module
python myapp.uhcrc/
Hardware Detection
# Full hardware report
uhcr hw
# Just the fingerprint
uhcr hw --fingerprint
# Output: Windows-AMD64-avx2-cuda_12.4+vulkan
Container Deployment
# Generate Dockerfile
uhcr docker myapp.py --image mycompany/app:v1
# Generate Kubernetes manifest
uhcr k8s myapp.py --image mycompany/app:v1 \
--replicas 5 \
--cpu-request 500m \
--memory-request 1Gi
AI Agent Integration
# Start MCP server for AI agents
uhcr mcp_start --transport http --port 3000
# AI agents can now use UHCR tools:
# • compile_code
# • optimize_code
# • detect_hardware
# • run_benchmark
# • generate_docker/k8s
📋 CLI Commands
uhcr -v # Version
uhcr hw # Hardware detection
uhcr compile script.py # Compile to native
uhcr docker script.py # Generate Dockerfile
uhcr k8s script.py # Generate K8s manifest
uhcr safety status # Safety system status
uhcr safety test # Test safety features
uhcr build # Build C++ safety library
uhcr run script.py --jit # Run with JIT
uhcr optimize script.py # Optimize code
uhcr mcp_start # Start MCP server
# ... 18 total commands
🏗️ Architecture
Core Components
- Compiler - IR-based multi-backend code generation
- Runtime - JIT execution and memory management
- Hardware - CPUID, GPU detection, NUMA topology
- Safety - C++ bounds checking, overflow detection
- Backends - CPU (AVX512/AVX2), CUDA, Metal, ROCm
- Storage - Memory pooling and hierarchical caching
- Network - gRPC/HTTP server, distributed coordination
Safety System
uhcr/native/
├── safety_checker.hpp # C++ safety header
├── safety_checker.cpp # C++ implementation
├── CMakeLists.txt # Build config
└── build_native.py # Python build script
uhcr/security/
├── runtime_safety.py # Python bindings
└── __init__.py # Public API
🛡️ Safety Features
Memory Safety
- ✅ Buffer overflow/underflow prevention
- ✅ Null pointer dereference detection
- ✅ Array bounds validation
- ✅ Use-after-free detection
Arithmetic Safety
- ✅ Integer overflow/underflow detection
- ✅ Division by zero prevention
- ✅ Safe casting validation
Resource Safety
- ✅ Stack overflow protection (10K recursion limit)
- ✅ Heap exhaustion prevention (1GB limit)
- ✅ Execution timeout (30s default)
- ✅ Infinite loop detection
Complete Safety Documentation →
📊 Performance
# Benchmark example
uhcr benchmark --suite tensor --output results.json
# Expected performance:
# - Native safety checks: ~1-2ns overhead
# - Python fallbacks: ~10-50ns overhead
# - JIT compilation: 10-100x speedup vs Python
🏢 Enterprise Use Cases
Financial Services
- High-frequency trading with safety guarantees
- Risk calculation with overflow protection
- Regulatory compliance (provenance tracking)
Healthcare
- Medical imaging processing
- Patient data analysis with safety checks
- HIPAA-compliant deployments
AI/ML
- Model training with GPU acceleration
- Inference optimization
- AI agent integration via MCP
DevOps
- Automated code optimization
- Container generation
- CI/CD integration
📚 Documentation
🤝 Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
# Development setup
git clone https://github.com/VishveshJoshi89/UHCR
cd UHCR
pip install -e .[dev]
uhcr build
pytest tests/
📄 License
🔗 Links
- PyPI: https://pypi.org/project/uhcr/
- Repository: https://github.com/VishveshJoshi89/UHCR
- Documentation: https://vishveshjoshi89.github.io/UHCR-DOCS/
- Bug Tracker: https://github.com/VishveshJoshi89/UHCR/issues
- Changelog: https://github.com/VishveshJoshi89/UHCR/blob/main/CHANGELOG.md
🌟 Star History
If you find UHCR useful, please consider starring the repository!
Built with ❤️ for enterprise Python developers
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 uhcr-5.2.0.tar.gz.
File metadata
- Download URL: uhcr-5.2.0.tar.gz
- Upload date:
- Size: 209.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
413c91f6b2705b6665854b42e2b3864234223684adb14bba6f0826700fa28864
|
|
| MD5 |
4a2878968900a082568bae3802ef7e52
|
|
| BLAKE2b-256 |
2c7f548eb5a93a97acd355fe35ee1389da539cfa6fcb19f0bb9d00e67bb0d3bc
|
File details
Details for the file uhcr-5.2.0-py3-none-any.whl.
File metadata
- Download URL: uhcr-5.2.0-py3-none-any.whl
- Upload date:
- Size: 197.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4819029c6e44bd503187a7bf9d9689c935ec67042f80b09308800dc180f2492
|
|
| MD5 |
f15b1213acc7f15d772855309f226368
|
|
| BLAKE2b-256 |
7b8e96ae26f2a5e74ed3654cd313c4ccf4d26c01543af12abb2cd3472358b484
|