Skip to content

High-performance Hybrid C++/Python ML training engine featuring GCP Spot VM auto-recovery, LoRA/DPO/FSDP support, and 60% cost reduction. The training backbone for the JARVIS ecosystem.

License

Notifications You must be signed in to change notification settings

drussell23/JARVIS-Reactor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JARVIS Reactor

An Advanced AI/ML Training & Serving Engine for AGI OS

JARVIS Reactor (formerly Reactor Core) is the "nervous system" of the JARVIS AGI ecosystem, providing enterprise-grade ML training, model serving, and real-time event coordination across distributed AI systems.

Python 3.9+ License: MIT Code style: black


πŸš€ What is JARVIS Reactor?

JARVIS Reactor is a production-grade ML infrastructure combining:

  • Advanced Training Methods: DPO, RLHF, Constitutional AI, Curriculum Learning
  • Model Serving: Hot-reload model server with multi-backend support (vLLM, llama.cpp, MLX)
  • Async Infrastructure: Circuit breakers, backpressure, bulkheads, dead letter queues
  • API Platform: FastAPI server with telemetry, scheduling, model registry, health monitoring
  • Trinity Orchestration: Multi-repo coordination with heartbeat monitoring and state sync
  • Event Streaming: Real-time WebSocket/Redis pub-sub across JARVIS ecosystem
  • GCP Integration: Spot VM resilience, Cloud SQL storage, auto-checkpointing
  • MLForge C++ Core: High-performance ML primitives (optional submodule)

πŸ“‹ Table of Contents


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        REACTOR CORE v77.1                            β”‚
β”‚                    (AGI OS Nervous System)                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                   UNIFIED API SERVER (v77.0)                  β”‚   β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚   β”‚
β”‚  β”‚  β”‚ Telemetry   β”‚  β”‚  Night      β”‚  β”‚  Model               β”‚  β”‚   β”‚
β”‚  β”‚  β”‚ Collector   β”‚  β”‚  Scheduler  β”‚  β”‚  Registry            β”‚  β”‚   β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                HOT-RELOAD MODEL SERVER (v77.1)                β”‚   β”‚
β”‚  β”‚  β€’ Multi-backend support (vLLM, llama.cpp, MLX, Transformers)β”‚   β”‚
β”‚  β”‚  β€’ Zero-downtime model swaps                                  β”‚   β”‚
β”‚  β”‚  β€’ LRU cache + semantic response caching                      β”‚   β”‚
β”‚  β”‚  β€’ Priority request queue                                     β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚            ADVANCED TRAINING ENGINE (v76.0)                   β”‚   β”‚
β”‚  β”‚                                                                β”‚   β”‚
β”‚  β”‚   Experience Buffer β†’ Data Selector β†’ Training Router         β”‚   β”‚
β”‚  β”‚                               β”‚                                β”‚   β”‚
β”‚  β”‚       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚   β”‚
β”‚  β”‚       β”‚                       β”‚                       β”‚        β”‚   β”‚
β”‚  β”‚       β–Ό                       β–Ό                       β–Ό        β”‚   β”‚
β”‚  β”‚   DPO Trainer          RLHF Pipeline        Constitutional AI β”‚   β”‚
β”‚  β”‚   β€’ Preference         β€’ PPO Algorithm       β€’ Self-supervisedβ”‚   β”‚
β”‚  β”‚     Learning           β€’ Reward Modeling     β€’ Safety         β”‚   β”‚
β”‚  β”‚   β€’ Memory Efficient   β€’ Value Functions     β€’ Alignment      β”‚   β”‚
β”‚  β”‚                                                                β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚           ASYNC INFRASTRUCTURE (v76.1)                        β”‚   β”‚
β”‚  β”‚  β€’ CircuitBreaker    β€’ Backpressure    β€’ DeadLetterQueue     β”‚   β”‚
β”‚  β”‚  β€’ Bulkhead          β€’ HealthMonitor   β€’ AdaptiveRateLimiter  β”‚   β”‚
β”‚  β”‚  β€’ TimeoutPolicy     β€’ MetricsCollector β€’ AsyncRetry          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚              TRINITY ORCHESTRATOR (v75.0)                     β”‚   β”‚
β”‚  β”‚  β€’ Multi-repo heartbeat monitoring                            β”‚   β”‚
β”‚  β”‚  β€’ Command routing with load balancing                        β”‚   β”‚
β”‚  β”‚  β€’ State reconciliation                                       β”‚   β”‚
β”‚  β”‚  β€’ Dead Letter Queue for failed commands                      β”‚   β”‚
β”‚  β”‚  β€’ Atomic file I/O (v73.0)                                    β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                EVENT STREAMING (v10.3)                        β”‚   β”‚
β”‚  β”‚  β€’ WebSocket real-time events                                 β”‚   β”‚
β”‚  β”‚  β€’ Redis pub/sub (optional)                                   β”‚   β”‚
β”‚  β”‚  β€’ Safety audit trail                                         β”‚   β”‚
β”‚  β”‚  β€’ Cost tracking & budget alerts                              β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                                      β”‚
β”‚         β–Ό                       β–Ό                      β–Ό             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚  β”‚  MLForge C++ β”‚      β”‚  Cloud SQL   β”‚      β”‚ GCP Storage  β”‚      β”‚
β”‚  β”‚   (Optional) β”‚      β”‚  (Events DB) β”‚      β”‚(Checkpoints) β”‚      β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β”‚                                                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

JARVIS-Reactor/
β”œβ”€β”€ reactor_core/
β”‚   β”œβ”€β”€ training/              # Advanced training methods
β”‚   β”‚   β”œβ”€β”€ advanced_training.py   # DPO, RLHF, Constitutional AI (2,899 lines)
β”‚   β”‚   β”œβ”€β”€ unified_pipeline.py    # End-to-end training orchestration
β”‚   β”‚   β”œβ”€β”€ trainer.py             # Base trainer class
β”‚   β”‚   └── lora.py                # LoRA/QLoRA implementations
β”‚   β”‚
β”‚   β”œβ”€β”€ serving/               # Model serving infrastructure
β”‚   β”‚   β”œβ”€β”€ model_server.py        # Hot-reload model server (1,545 lines)
β”‚   β”‚   └── inference_engine.py    # Multi-backend inference (1,891 lines)
β”‚   β”‚
β”‚   β”œβ”€β”€ api/                   # REST API server
β”‚   β”‚   β”œβ”€β”€ server.py              # FastAPI endpoints (2,252 lines)
β”‚   β”‚   β”œβ”€β”€ telemetry.py           # Metrics & observability (1,128 lines)
β”‚   β”‚   β”œβ”€β”€ scheduler.py           # Night Shift scheduler (1,030 lines)
β”‚   β”‚   β”œβ”€β”€ model_registry.py      # Model versioning (1,301 lines)
β”‚   β”‚   └── health_aggregator.py   # Health monitoring (999 lines)
β”‚   β”‚
β”‚   β”œβ”€β”€ orchestration/         # Trinity coordination
β”‚   β”‚   └── trinity_orchestrator.py # Multi-repo orchestrator
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/                 # Core utilities
β”‚   β”‚   β”œβ”€β”€ async_helpers.py       # Async patterns (1,746 lines)
β”‚   β”‚   └── dependencies.py        # Dependency injection (913 lines)
β”‚   β”‚
β”‚   β”œβ”€β”€ integration/           # Cross-repo integration
β”‚   β”‚   β”œβ”€β”€ event_bridge.py        # Event streaming
β”‚   β”‚   β”œβ”€β”€ cost_bridge.py         # Cost tracking
β”‚   β”‚   β”œβ”€β”€ jarvis_connector.py    # JARVIS integration
β”‚   β”‚   └── prime_connector.py     # Prime integration
β”‚   β”‚
β”‚   β”œβ”€β”€ eval/                  # Model evaluation
β”‚   β”‚   └── advanced_evaluation.py # Comprehensive eval suite (1,536 lines)
β”‚   β”‚
β”‚   β”œβ”€β”€ data/                  # Data loading & preprocessing
β”‚   β”œβ”€β”€ gcp/                   # GCP Spot VM support
β”‚   └── config/                # Configuration management
β”‚
β”œβ”€β”€ run_supervisor.py          # AGI OS unified supervisor (1,635 lines)
β”œβ”€β”€ mlforge/                   # C++ ML core (submodule)
β”œβ”€β”€ docker/                    # Docker configurations
β”œβ”€β”€ scripts/                   # Utility scripts
└── tests/                     # Test suite

Total: ~18,996+ lines of production code added in v75.0-v77.1

⭐ Key Features

🧠 Advanced Training Methods (v76.0)

  • DPO (Direct Preference Optimization): Preference learning without reward models
  • RLHF (Reinforcement Learning from Human Feedback): Full PPO pipeline
  • Constitutional AI: Self-supervised safety alignment
  • Curriculum Learning: Progressive difficulty scheduling
  • Memory Management: Dynamic batch sizing, gradient checkpointing, CPU offloading
  • FSDP Support: Fully Sharded Data Parallel for large models
  • Experience Replay: Priority-based sampling from interaction logs

⚑ Async Infrastructure (v76.1)

  • CircuitBreaker: Automatic failure detection and recovery
  • Backpressure: Adaptive load management with queue shedding
  • Bulkhead: Failure isolation between components
  • DeadLetterQueue: Failed operation tracking and replay
  • HealthMonitor: Real-time component health tracking
  • AdaptiveRateLimiter: Dynamic rate limiting based on success rates
  • TimeoutPolicy: Configurable timeouts with fallback strategies
  • MetricsCollector: Comprehensive observability

🌐 API Server & Telemetry (v77.0)

  • FastAPI Server: Production-grade REST API with auto-docs
  • Telemetry Collector: Real-time metrics ingestion with WebSocket streaming
  • Night Shift Scheduler: Automated training during off-peak hours
  • Model Registry: Version management, A/B testing, rollback support
  • Health Aggregator: Multi-service health dashboard
  • Cost Tracking: Budget alerts and spend analytics
  • WebSocket Events: Real-time training progress streaming

πŸ”₯ Model Serving & Hot Reload (v77.1)

  • Hot-Reload: Zero-downtime model updates via file watcher
  • Multi-Backend Support: vLLM, llama.cpp, MLX, Transformers
  • LRU Model Cache: Memory-aware model eviction
  • Priority Queue: Request prioritization for SLA compliance
  • Semantic Caching: Hash-based response deduplication
  • Circuit Breaker: Backend failure protection
  • Async Loading: Non-blocking model initialization
  • Version Management: Seamless model version switching

🎯 Trinity Orchestrator (v75.0)

  • Multi-Repo Coordination: Heartbeat monitoring across JARVIS, Prime, Reactor
  • Command Routing: Intelligent load balancing with priority queues
  • State Reconciliation: Consistent state across distributed system
  • Dead Letter Queue: Failed command tracking and retry
  • Atomic File I/O: Zero-corruption file operations (v73.0)
  • Self-Heartbeat: Liveness monitoring (v72.0)
  • Circuit Breakers: Fault tolerance with automatic recovery

πŸ”„ Event Streaming (v10.3)

  • WebSocket Streaming: Real-time event broadcasting
  • Redis Pub/Sub: Optional Redis backend for scale
  • Event Deduplication: Hash-based duplicate prevention
  • Priority System: Safety-critical event prioritization
  • Safety Audit Trail: Comprehensive action logging
  • Cost Events: Budget tracking with alerts
  • Multi-Transport: WebSocket, file-watching, Redis

☁️ GCP Integration

  • Spot VM Resilience: Auto-resume from preemption
  • Cloud SQL Storage: Event and metric persistence
  • GCS Checkpointing: Distributed checkpoint storage
  • Auto-Detection: M1 local vs GCP remote environment detection

πŸ“¦ Installation

Quick Install (Python only, no C++ bindings)

pip install jarvis-reactor

Build from Source (with MLForge C++ bindings)

# Clone with submodules
git clone --recursive https://github.com/drussell23/JARVIS-Reactor.git
cd JARVIS-Reactor

# Install dependencies (requires CMake and pybind11)
pip install pybind11 cmake

# Build and install
pip install -e .

Environment-Specific Installation

# For local development (M1 Mac)
pip install jarvis-reactor[local]

# For GCP training (32GB+ VM)
pip install jarvis-reactor[gcp]

# For full development (includes testing, linting, docs)
pip install -e ".[dev]"

Docker Installation

# Build Docker image
docker-compose build

# Run API server
docker-compose up api

# Run model server
docker-compose up model-server

# Run unified supervisor
docker-compose up supervisor

πŸš€ Quick Start

Basic Training

from reactor_core import Trainer, TrainingConfig
from reactor_core.gcp import SpotVMCheckpointer

# Configure training
config = TrainingConfig(
    model_name="llama-2-7b",
    use_lora=True,
    lora_rank=16,
    num_epochs=3,
    batch_size=4,
    gradient_checkpointing=True,
)

# Auto-detect environment (M1 local vs GCP remote)
trainer = Trainer(config)

# Train with auto-resume on Spot VM preemption
trainer.train("./data/train.jsonl")

Advanced Training with DPO

from reactor_core.training.advanced_training import (
    DPOTrainer,
    DPOConfig,
    PreferenceDataset,
)

# Configure DPO
dpo_config = DPOConfig(
    model_name="llama-2-7b",
    beta=0.1,  # KL divergence penalty
    learning_rate=5e-7,
    max_length=512,
    batch_size=4,
)

# Initialize DPO trainer
dpo_trainer = DPOTrainer(dpo_config)

# Train on preference pairs
await dpo_trainer.train(
    preference_dataset=PreferenceDataset(
        chosen_responses=chosen_data,
        rejected_responses=rejected_data,
    ),
    num_epochs=3,
)

Model Serving with Hot Reload

from reactor_core.serving.model_server import ModelServer, ModelServerConfig

# Configure model server
config = ModelServerConfig(
    models_dir="/path/to/models",
    enable_hot_reload=True,
    backend="vllm",  # or "transformers", "llamacpp", "mlx"
    max_cached_models=3,
)

# Initialize server
server = ModelServer(config)
await server.start()

# Serve inference requests
response = await server.predict(
    prompt="What is machine learning?",
    model_id="llama-2-7b",
    max_tokens=256,
)
print(response.text)

# Hot-reload: Just update the model file, server auto-reloads!

API Server & Scheduler

# Start API server
uvicorn reactor_core.api.server:app --host 0.0.0.0 --port 8003 --reload
import requests

# Trigger training via API
response = requests.post(
    "http://localhost:8003/training/trigger",
    json={
        "model_name": "llama-2-7b",
        "training_type": "dpo",
        "config": {
            "num_epochs": 3,
            "batch_size": 4,
            "learning_rate": 5e-7,
        },
    },
)

# Schedule nightly training
response = requests.post(
    "http://localhost:8003/scheduler/schedule",
    json={
        "name": "nightly_dpo_training",
        "schedule_type": "cron",
        "cron_expression": "0 2 * * *",  # 2 AM daily
        "job_config": {
            "training_type": "dpo",
            "model_name": "llama-2-7b",
        },
    },
)

Trinity Orchestrator (Multi-Repo Coordination)

from reactor_core.orchestration.trinity_orchestrator import (
    initialize_orchestrator,
    get_orchestrator,
)

# Initialize orchestrator
orchestrator = await initialize_orchestrator()

# Dispatch command to JARVIS/Prime
await orchestrator.dispatch_command(
    intent="start_surveillance",
    payload={
        "app_name": "Chrome",
        "trigger_text": "bouncing ball",
    },
    target_components=["jarvis"],
)

# Check component health
health = await orchestrator.get_health_status()
print(f"JARVIS: {health['jarvis'].status}")
print(f"Prime: {health['prime'].status}")
print(f"Reactor: {health['reactor'].status}")

Unified Supervisor (One-Command Startup)

# Start entire AGI OS ecosystem
python3 run_supervisor.py

# With specific components
python3 run_supervisor.py --components jarvis,prime,reactor

# Development mode (verbose logging)
python3 run_supervisor.py --dev --log-level DEBUG

πŸ”¬ Advanced Features

Advanced Training Methods (v76.0)

Comprehensive documentation for DPO, RLHF, Constitutional AI, Curriculum Learning with code examples for memory management, experience replay, and multi-GPU training.

Async Infrastructure (v76.1)

Production-ready async patterns including circuit breakers, backpressure management, dead letter queues, health monitoring, and adaptive rate limiting.

API Server & Telemetry (v77.0)

FastAPI server with telemetry collection, Night Shift scheduling, model registry, health aggregation, and real-time WebSocket streaming.

Model Serving & Hot Reload (v77.1)

Zero-downtime model serving with hot-reload, multi-backend support (vLLM, llama.cpp, MLX, Transformers), LRU caching, and semantic response caching.

Trinity Orchestrator (v75.0)

Multi-repo coordination with heartbeat monitoring, command routing, state reconciliation, dead letter queue, and atomic file I/O.

(See full documentation in sections below)


πŸ”— Integration Architecture

JARVIS Ecosystem Integration

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       JARVIS AGI ECOSYSTEM                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚  β”‚  JARVIS-AI-Agent │◄────────►│  JARVIS Prime    β”‚                 β”‚
β”‚  β”‚  (Claude Body)   β”‚  Events  β”‚  (LLM Mind)      β”‚                 β”‚
β”‚  β”‚                  β”‚          β”‚                  β”‚                 β”‚
β”‚  β”‚ β€’ Computer Use   β”‚          β”‚ β€’ Local LLM      β”‚                 β”‚
β”‚  β”‚ β€’ macOS Control  β”‚          β”‚ β€’ Reasoning      β”‚                 β”‚
β”‚  β”‚ β€’ Voice Auth     β”‚          β”‚ β€’ Context        β”‚                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚            β”‚                              β”‚                          β”‚
β”‚            β”‚         Event Bridge         β”‚                          β”‚
β”‚            β”‚      (WebSocket/Redis)       β”‚                          β”‚
β”‚            β”‚                              β”‚                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚  β”‚            Reactor Core (Nervous System)        β”‚                 β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚                 β”‚
β”‚  β”‚  β”‚         Trinity Orchestrator             β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ Heartbeat monitoring                  β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ Command routing                       β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ State reconciliation                  β”‚   β”‚                 β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚                 β”‚
β”‚  β”‚                                                  β”‚                 β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚                 β”‚
β”‚  β”‚  β”‚         Training & Serving               β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ DPO, RLHF, Constitutional AI          β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ Hot-reload model server               β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ Night Shift scheduler                 β”‚   β”‚                 β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚                 β”‚
β”‚  β”‚                                                  β”‚                 β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚                 β”‚
β”‚  β”‚  β”‚         Event Streaming                  β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ Safety audit trail                    β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ Cost tracking                         β”‚   β”‚                 β”‚
β”‚  β”‚  β”‚  β€’ Telemetry collection                  β”‚   β”‚                 β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚                                                                      β”‚
β”‚            β–Ό                             β–Ό                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                  β”‚
β”‚  β”‚   Cloud SQL      β”‚         β”‚   GCP Storage    β”‚                  β”‚
β”‚  β”‚   (Events DB)    β”‚         β”‚  (Checkpoints)   β”‚                  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
β”‚                                                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ˆ Version History

v77.1 - Model Serving & Hot Reload (2025-01-07)

  • Hot-reload model server with zero-downtime updates (1,545 lines)
  • Multi-backend inference engine: vLLM, llama.cpp, MLX, Transformers (1,891 lines)
  • Unified supervisor for one-command AGI OS startup (1,635 lines)
  • LRU model cache with memory-aware eviction
  • Priority request queue for SLA compliance
  • Semantic response caching with hash-based deduplication

v77.0 - Advanced API Server (2025-01-07)

  • Telemetry collection system with WebSocket streaming (1,128 lines)
  • Night Shift scheduler for automated training (1,030 lines)
  • Model registry with versioning and A/B testing (1,301 lines)
  • Health aggregator with multi-service dashboard (999 lines)
  • Enhanced FastAPI server (2,252 lines)

v76.1 - Async Infrastructure (2025-01-07)

  • Advanced async patterns library (1,746 lines)
  • Circuit breaker, backpressure, bulkhead patterns
  • Dead letter queue, health monitor, adaptive rate limiter
  • Dependency injection system (913 lines)

v76.0 - Advanced Training Methods (2025-01-07)

  • DPO, RLHF, Constitutional AI, Curriculum Learning (2,899 lines)
  • Memory manager with dynamic batch sizing
  • Advanced evaluation suite (1,536 lines)

v75.0 - Trinity Dead Letter Queue (2024-12-25)

  • DLQ for failed/expired commands
  • Automatic retry with exponential backoff

v73.0 - Atomic File I/O (2024-11-15)

  • Zero-corruption file operations via atomic renames

v10.3 - Vision Safety Integration (2024-10-20)

  • Safety audit trail and kill switch mechanism

v10.0 - Cross-Repository Integration (2024-10-01)

  • Real-time event streaming across JARVIS ecosystem

v1.0.0 - Initial Release (2024-09-01)

  • PyTorch-first ML training framework
  • LoRA/QLoRA, DPO, FSDP support
  • GCP Spot VM resilience

πŸ”— Links


πŸ“„ License

MIT License - See LICENSE file for details.


Built with ❀️ for the JARVIS AGI Ecosystem

About

High-performance Hybrid C++/Python ML training engine featuring GCP Spot VM auto-recovery, LoRA/DPO/FSDP support, and 60% cost reduction. The training backbone for the JARVIS ecosystem.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages