Skip to main content

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

Python 3.10+ License: Apache-2.0 PyPI version Documentation Production Ready Enterprise

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 checking
  • uhcr docker/k8s - Generate deployment manifests
  • uhcr hw - Comprehensive hardware detection
  • uhcr safety - Runtime safety management
  • uhcr 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

Apache License 2.0

🔗 Links

🌟 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

uhcr-5.2.0.tar.gz (209.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uhcr-5.2.0-py3-none-any.whl (197.3 kB view details)

Uploaded Python 3

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

Hashes for uhcr-5.2.0.tar.gz
Algorithm Hash digest
SHA256 413c91f6b2705b6665854b42e2b3864234223684adb14bba6f0826700fa28864
MD5 4a2878968900a082568bae3802ef7e52
BLAKE2b-256 2c7f548eb5a93a97acd355fe35ee1389da539cfa6fcb19f0bb9d00e67bb0d3bc

See more details on using hashes here.

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

Hashes for uhcr-5.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4819029c6e44bd503187a7bf9d9689c935ec67042f80b09308800dc180f2492
MD5 f15b1213acc7f15d772855309f226368
BLAKE2b-256 7b8e96ae26f2a5e74ed3654cd313c4ccf4d26c01543af12abb2cd3472358b484

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page