Skip to content

milyas2001/cortex-gpu-scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CORTEX

Hardware-aware AI workload scheduler with kernel bypass networking.
GPU topology discovery, NVLink-aware placement, DPDK zero-copy transfers,
and predictive autoscaling for production GPU clusters.

Build Release Stars MIT

Features Β· Architecture Β· Quick Start Β· Benchmarks Β· Contributing


CORTEX β€” GPU cluster dashboard with topology view, scheduling timeline, and memory allocation


Table of Contents


Features

  • NVML Topology Discovery -- Reads physical GPU interconnect hierarchy at runtime
  • NVLink-Aware Bin-Packing -- Places workloads on GPUs connected via high-bandwidth NVLink
  • NUMA Affinity Scoring -- Weighted affinity model across NVLink, PCIe, NUMA, and socket boundaries
  • DPDK Kernel Bypass -- Eliminates kernel overhead for tensor transfers (~5us vs ~100us)
  • io_uring Zero-Copy -- Asynchronous I/O with zero-copy semantics for data plane operations
  • Buddy Allocator -- Efficient GPU memory management with splitting, coalescing, and defragmentation
  • Prophet + LSTM Autoscaling -- Ensemble forecasting for predictive cluster scaling
  • Energy & Carbon Tracking -- NVML power monitoring, dynamic frequency scaling, carbon-aware scheduling
  • Kubernetes Native -- Scheduler extender, device plugin, and custom metrics server

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        CORTEX Control Plane                         β”‚
β”‚                                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Scheduler   β”‚  β”‚  Autoscaler  β”‚  β”‚  Energy   β”‚  β”‚ Dashboard  β”‚  β”‚
β”‚  β”‚  (Rust)      β”‚  β”‚  (Python)    β”‚  β”‚  (Rust)   β”‚  β”‚ (React)    β”‚  β”‚
β”‚  β”‚             β”‚  β”‚              β”‚  β”‚           β”‚  β”‚            β”‚  β”‚
β”‚  β”‚ - Topology  β”‚  β”‚ - Prophet    β”‚  β”‚ - NVML    β”‚  β”‚ - Topology β”‚  β”‚
β”‚  β”‚ - Affinity  β”‚  β”‚ - LSTM       β”‚  β”‚ - Clock   β”‚  β”‚ - Heatmap  β”‚  β”‚
β”‚  β”‚ - Placement β”‚  β”‚ - K8s HPA    β”‚  β”‚ - Carbon  β”‚  β”‚ - Latency  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚         β”‚                β”‚                β”‚               β”‚         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                    Kubernetes Integration                     β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚ Scheduler    β”‚  β”‚ Device Plugin β”‚  β”‚ Custom Metrics     β”‚  β”‚  β”‚
β”‚  β”‚  β”‚ Extender(Go) β”‚  β”‚ (Go)          β”‚  β”‚ Server (Go)        β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Data Plane                                    β”‚
β”‚                                                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  Network Layer   β”‚     β”‚  Memory Manager                     β”‚    β”‚
β”‚  β”‚  (Rust)          β”‚     β”‚  (Rust)                             β”‚    β”‚
β”‚  β”‚                  β”‚     β”‚                                     β”‚    β”‚
β”‚  β”‚  - DPDK Bypass   β”‚     β”‚  - Buddy Allocator                 β”‚    β”‚
β”‚  β”‚  - io_uring      │◄───►│  - Defragmenter                    β”‚    β”‚
β”‚  β”‚  - Tensor Xfer   β”‚     β”‚  - Pattern Monitor                 β”‚    β”‚
β”‚  β”‚  - Zero-copy     β”‚     β”‚  - Compactor                       β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

GPU Topology Awareness

CORTEX reads the physical GPU topology via NVML and makes placement decisions that respect the hardware interconnect hierarchy:

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   CPU 0     β”‚
                    β”‚  (NUMA 0)   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                           β”‚ QPI/UPI
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚              β”‚              β”‚
       β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
       β”‚ PCIe    β”‚   β”‚ PCIe    β”‚   β”‚ PCIe    β”‚
       β”‚ Switch 0β”‚   β”‚ Switch 1β”‚   β”‚ Root    β”‚
       β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜   β”‚ Complex β”‚
            β”‚              β”‚        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
       β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”        β”‚
       β”‚         β”‚   β”‚         β”‚   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
   β”Œβ”€β”€β”€β”΄β”€β”€β” β”Œβ”€β”€β”€β”΄β”€β”€β”β”Œβ”€β”€β”΄β”€β”€β”β”Œβ”€β”€β”΄β”€β”€β”β”‚  CPU 1  β”‚
   β”‚GPU 0 β”‚ β”‚GPU 1 β”‚β”‚GPU 2β”‚β”‚GPU 3β”‚β”‚ (NUMA 1)β”‚
   β”‚      β”‚ β”‚      β”‚β”‚     β”‚β”‚     β”‚β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
   β””β”€β”€β”€β”¬β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”˜β””β”€β”€β”¬β”€β”€β”˜β””β”€β”€β”¬β”€β”€β”˜     β”‚
       β”‚  NVLink β”‚      β”‚NVLinkβ”‚   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”˜   β”‚         β”‚
                              β”Œβ”€β”€β”€β”΄β”€β”€β” β”Œβ”€β”€β”€β”΄β”€β”€β”
                              β”‚GPU 4 β”‚ β”‚GPU 5 β”‚
                              β””β”€β”€β”€β”¬β”€β”€β”˜ β””β”€β”€β”€β”¬β”€β”€β”˜
                                  β”‚NVLinkβ”‚
                                  β””β”€β”€β”€β”€β”€β”€β”˜

  Affinity Score Calculation:
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Same GPU         β†’ Score: 1.0      β”‚
  β”‚ NVLink Peer      β†’ Score: 0.9      β”‚
  β”‚ Same PCIe Switch β†’ Score: 0.7      β”‚
  β”‚ Same NUMA Node   β†’ Score: 0.5      β”‚
  β”‚ Cross NUMA (QPI) β†’ Score: 0.2      β”‚
  β”‚ Cross Socket     β†’ Score: 0.1      β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Memory Management: Buddy Allocator

  GPU Memory Space (e.g., 16 GB)
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                    Order 10 (16 GB)                    β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚     Order 9 (8 GB)      β”‚      Order 9 (8 GB)         β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚  O8 (4GB)  β”‚  O8 (4GB)  β”‚  O8 (4GB)  β”‚   O8 (4GB)    β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚O7 2G β”‚O7 2Gβ”‚O7 2G β”‚O7 2Gβ”‚O7 2G β”‚O7 2Gβ”‚O7 2G β”‚O7 2G  β”‚
  β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  Allocation: Split larger blocks until right size found
  Deallocation: Merge buddy pairs back into larger blocks
  Defragmentation: Compact scattered allocations

Kernel Bypass Networking

  Traditional Path:              CORTEX Path:
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ App      β”‚                   β”‚ App      β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ gRPC     β”‚                   β”‚ Tensor   β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€                   β”‚ Protocol β”‚
  β”‚ HTTP/2   β”‚                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€        vs.        β”‚ io_uring β”‚
  β”‚ TCP      β”‚                   β”‚ zero-copyβ”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ Kernel   β”‚                   β”‚ DPDK     β”‚
  β”‚ Network  β”‚                   β”‚ (bypass) β”‚
  β”‚ Stack    β”‚                   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€                        β”‚
  β”‚ NIC      β”‚                   β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β”‚ NIC      β”‚
                                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  Latency: ~100us                Latency: ~5us

Components

Component Language Description
scheduler/ Rust GPU topology discovery, NVLink-aware bin-packing, NUMA affinity
network/ Rust DPDK kernel bypass, io_uring zero-copy, tensor transfer protocol
memory/ Rust Buddy allocator for GPU memory, defragmentation, compaction
autoscaler/ Python Prophet + LSTM ensemble forecasting, K8s HPA integration
energy/ Rust NVML power monitoring, dynamic frequency scaling, carbon tracking
kubernetes/ Go Scheduler extender, device plugin, custom metrics server
dashboard/ TypeScript/React Real-time topology, memory heatmap, latency, energy dashboards

Quick Start

Prerequisites

  • Rust 1.75+ with nightly toolchain (for io_uring)
  • Go 1.21+
  • Node.js 20+ and pnpm
  • Python 3.11+ with Poetry
  • NVIDIA drivers with NVML support
  • Linux kernel 5.19+ (for io_uring features)
  • Kubernetes 1.28+ (for cluster deployment)

Build

# Build all Rust components
make build-rust

# Build Go components
make build-go

# Build dashboard
make build-dashboard

# Install Python autoscaler
make install-autoscaler

# Build everything
make all

Run Locally (Development)

# Start the scheduler with mock GPU topology
CORTEX_MOCK_TOPOLOGY=1 cargo run --bin cortex-scheduler

# Start the dashboard
cd dashboard && pnpm dev

# Start the autoscaler
cd autoscaler && poetry run cortex-autoscaler --dev

Deploy to Kubernetes

# Apply CRDs and RBAC
kubectl apply -f deploy/k8s/

# Deploy CORTEX components
make deploy

# Verify
kubectl get pods -n cortex-system

Benchmarks

# Run all benchmarks
cargo bench

# Run specific benchmark
cargo bench --bench scheduler_bench
cargo bench --bench memory_bench

Configuration

CORTEX is configured via environment variables and a TOML config file:

[scheduler]
topology_refresh_interval_secs = 30
placement_strategy = "bin-pack"        # bin-pack | spread | affinity-first
nvlink_weight = 0.4
numa_weight = 0.3
pcie_weight = 0.2
memory_weight = 0.1

[network]
transport = "io-uring"                 # io-uring | dpdk | tcp
zero_copy = true
ring_size = 256
tensor_chunk_size = "4MB"

[memory]
min_block_order = 12                   # 4 KB minimum
max_block_order = 34                   # 16 GB maximum
defrag_threshold = 0.3
compaction_interval_secs = 60

[energy]
power_cap_watts = 300
carbon_region = "us-west-2"
frequency_scaling = true

[autoscaler]
forecast_horizon_minutes = 30
lstm_sequence_length = 60
prophet_changepoint_prior = 0.05
ensemble_weight_lstm = 0.6
ensemble_weight_prophet = 0.4

Contributing

We welcome contributions of all kinds. Please read our Contributing Guide to get started.

Before contributing, please also review our Code of Conduct.


License

MIT License -- See LICENSE for details.

About

CORTEX - Hardware-Aware AI Workload Scheduler

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors