Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

38 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

model-runtime

A controllable and reproducible runtime for running, evaluating, and monitoring AI models across heterogeneous inference backends.

model-runtime is an open-source orchestration layer for managing the full lifecycle of local and GPU-hosted AI models: model startup, GPU allocation, inference, training workflows, experiment tracking, artifact management, and evaluation.

The project is designed around a simple principle:

Policy and experiment logic should be separated from model execution.

This architecture makes the runtime useful not only for local AI deployment and MLOps, but also for reproducible AI evaluation, monitoring, control, and safety research.


Why this project exists

Running modern open-weight models often requires coordinating many independent systems:

  • model downloading and caching
  • CUDA and GPU allocation
  • inference engines such as vLLM
  • container lifecycle management
  • model adapters such as LoRA
  • experiment tracking
  • artifact storage
  • training and evaluation workflows
  • API gateways
  • model monitoring
  • reproducibility across experiments

These components are usually configured independently, making experiments difficult to reproduce and model execution difficult to control.

model-runtime provides a unified orchestration layer that separates:

Policy / experiment definition
            ↓
      Control Plane
            ↓
   Runtime Management
            ↓
     Model Execution
            ↓
 Monitoring / Evaluation
            ↓
     Logs & Artifacts

Architecture

The current system consists of several independent services.

                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚       Frontend        β”‚
                     β”‚  experiment / model   β”‚
                     β”‚      management       β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚    API Dispatcher     β”‚
                     β”‚     FastAPI layer     β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚                             β”‚
                  β–Ό                             β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  Control Plane   β”‚          β”‚ Model Runtime    β”‚
        β”‚                  β”‚          β”‚ Manager (MRM)    β”‚
        β”‚ policy / runs /  β”‚          β”‚                  β”‚
        β”‚ state machine    β”‚          β”‚ GPU + containers β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                 β”‚                             β”‚
                 β–Ό                             β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚    PostgreSQL    β”‚          β”‚ vLLM containers  β”‚
        β”‚    + Alembic     β”‚          β”‚ / model workers  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                               β”‚
                                               β–Ό
                                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                      β”‚     LiteLLM      β”‚
                                      β”‚ OpenAI-compatibleβ”‚
                                      β”‚      proxy       β”‚
                                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                               β”‚
                                               β–Ό
                                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                      β”‚      Gateway     β”‚
                                      β”‚      Nginx       β”‚
                                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Supporting services include:

  • Redis β€” runtime state
  • MLflow β€” experiment tracking
  • S3-compatible storage β€” artifacts
  • Hugging Face Hub β€” model retrieval
  • Infinity β€” embeddings
  • Neo4j β€” optional RAG / knowledge graph
  • NVIDIA / CUDA β€” GPU execution

Core design principle

Control Plane decides. Runtime executes.

The Control Plane does not directly perform ML operations.

Its responsibility is to define and track:

  • experiment contracts
  • run state
  • workflow transitions
  • model and dataset references
  • artifacts
  • execution policy

Actual model execution is delegated to dedicated runtime workers.

This separation provides a useful boundary for reproducible and auditable AI experiments.


Model Runtime Manager

The Model Runtime Manager (MRM) manages inference containers and GPU resources.

Responsibilities include:

  • model startup
  • GPU reservation
  • Docker container lifecycle
  • runtime health checks
  • idle model eviction
  • runtime state synchronization
  • model availability tracking

The runtime follows an ensure + touch lifecycle model.

Client
  β”‚
  β”œβ”€β”€ ensure(model)
  β”‚       β”‚
  β”‚       β–Ό
  β”‚   model available
  β”‚
  └── touch(model)
          β”‚
          β–Ό
     keep runtime active

Redis acts as the canonical runtime state while Docker is treated as an execution-layer sensor.


Experiment contracts

The Control Plane represents ML workflows using explicit versioned contracts.

Current examples include:

dataset.build.v1
train.qlora.v1
train.dpo.v1
eval.standard.v1

A typical experiment can move through states such as:

CREATED
   ↓
DATASET_RUNNING
   ↓
DATASET_READY
   ↓
TRAIN_RUNNING
   ↓
TRAIN_READY
   ↓
DONE

Failures are explicitly represented and stored rather than hidden inside worker processes.

This makes experiments easier to inspect and reproduce.


AI safety and evaluation use cases

The architecture is intentionally general, but it can serve as infrastructure for AI safety research.

Potential research uses include:

Reproducible model evaluations

Run the same evaluation protocol across:

  • different models
  • model versions
  • inference engines
  • quantization settings
  • LoRA adapters
  • hardware configurations

while keeping experiment definitions and artifacts consistent.


Model monitoring

The runtime can provide a common layer for recording:

  • prompts
  • responses
  • model metadata
  • tool calls
  • runtime events
  • latency
  • resource usage
  • evaluation results

This allows model behavior to be analyzed after execution.


AI control experiments

A runtime-level control layer can be used to investigate questions such as:

Can infrastructure enforce meaningful constraints on an untrusted model?

Examples include policies for:

  • tool access
  • network access
  • filesystem access
  • model lifecycle
  • resource limits
  • allowed inference backends
  • execution environments

Auditable inference

Separating policy decisions from model execution makes it possible to build experiment logs describing:

what model ran
where it ran
what configuration was used
what resources it accessed
what experiment contract requested it
what artifacts were produced

This is useful for AI control, monitoring, red-team experiments, and safety evaluations.


Model-behavior comparison

The same runtime can be used to compare behavioral properties across models without rebuilding infrastructure for every experiment.

For example:

Model A ─┐
Model B ─┼──► common evaluation runtime ──► metrics
Model C β”€β”˜

Current services

Control Plane

Port: 8004

Technology:

  • FastAPI
  • SQLAlchemy 2.0
  • asyncpg
  • PostgreSQL
  • Alembic

Responsibilities:

  • experiment definitions
  • run state
  • workflow orchestration
  • contracts
  • artifact references

Model Runtime Manager

Port: 8010

Responsibilities:

  • vLLM container lifecycle
  • GPU reservation
  • model startup
  • model shutdown
  • model health
  • idle eviction

Core endpoints include:

POST /models/ensure
POST /models/touch
POST /models/stop
POST /models/remove

GET /models/status

API Dispatcher

Port: 8005

The dispatcher acts as the execution bridge between clients and runtime services.

Responsibilities include:

  • chat requests
  • runtime discovery
  • model activation
  • LoRA materialization
  • RAG context injection
  • routing inference requests

Frontend

The frontend provides interfaces for:

  • chat
  • GPU monitoring
  • model registry
  • training
  • deployment management
  • orchestration
  • prompt experiments
  • Hugging Face registry
  • dataset building
  • documentation tools

Inference stack

Current inference architecture:

Application
    ↓
API Dispatcher
    ↓
Model Runtime Manager
    ↓
vLLM
    ↓
LiteLLM
    ↓
OpenAI-compatible API

This allows client applications to interact with different model backends through a common interface.


Technology stack

Backend

  • Python 3.10–3.12
  • FastAPI
  • Uvicorn
  • Pydantic
  • SQLAlchemy
  • asyncpg

Infrastructure

  • Docker
  • Docker Compose
  • PostgreSQL
  • Redis
  • Nginx

AI / ML

  • vLLM
  • LiteLLM
  • Hugging Face Hub
  • NVIDIA CUDA
  • pynvml
  • LoRA / QLoRA
  • DPO

Experiment infrastructure

  • MLflow
  • S3-compatible artifact storage
  • Alembic migrations

Optional components

  • Neo4j
  • Infinity embeddings
  • RAG pipelines

Running locally

Clone the repository:

git clone https://github.com/NikoriakViktot/model-runtime.git
cd model-runtime

Start the development stack:

docker compose -f docker-compose.dev.yml up

A lightweight configuration is also available:

docker compose -f docker-compose.lite.yml up

GPU-specific services can be enabled with:

docker compose \
  -f docker-compose.dev.yml \
  -f docker-compose.gpu.yml \
  up

Example request flow

A typical chat request follows this path:

1. Client sends request
        ↓
2. Dispatcher asks MRM to ensure the model is running
        ↓
3. MRM reserves resources / starts runtime if necessary
        ↓
4. Dispatcher touches the runtime
        ↓
5. Optional LoRA / RAG context is materialized
        ↓
6. Request is routed through LiteLLM
        ↓
7. vLLM performs inference
        ↓
8. Response is returned to the client

Research direction

A major future direction of the project is turning model-runtime into an experimental platform for AI control, monitoring, and reproducible safety evaluation.

The central research question is:

Can runtime infrastructure provide enforceable and auditable control boundaries for experiments involving capable or potentially untrusted AI models?

Possible extensions include:

  • policy-enforced tool access
  • sandboxed model execution
  • network-access policies
  • filesystem-access policies
  • structured model-event logging
  • monitor-model integration
  • red-team / blue-team experiment support
  • standardized evaluation contracts
  • deterministic experiment manifests
  • provenance tracking
  • model behavior comparison
  • automatic safety-evaluation pipelines

Project status

model-runtime is currently an experimental research and engineering project.

The architecture and APIs are still evolving.

The immediate priorities are:

  • stabilize model-runtime contracts
  • improve experiment reproducibility
  • extend evaluation support
  • improve runtime isolation
  • add structured monitoring
  • strengthen security boundaries between models and host infrastructure

Contributing

Issues, experiments, architectural suggestions, and research collaborations are welcome.

Particular areas of interest include:

  • AI control
  • model monitoring
  • evaluations
  • inference security
  • sandboxing
  • reproducible ML systems
  • model deployment security
  • adversarial testing

License

Copyright Β© 2026 Viktor Nikoriak.

MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages