# jamessshhh/bayesian-llm-inference-scheduling architecture

> Architecture diagram of the GitHub repository jamessshhh/bayesian-llm-inference-scheduling, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jamessshhh/bayesian-llm-inference-scheduling
- Repository: https://github.com/jamessshhh/bayesian-llm-inference-scheduling

## Overview

LATENT is a research simulator for evaluating uncertainty-aware scheduling of LLM inference requests, not a production serving system. The main workflow generates synthetic or ShareGPT workloads, supplies predicted service costs and uncertainty, chooses among scheduling policies, simulates a single non-preemptive worker, and summarizes latency and starvation-related metrics. Its internal layers include request data, posterior estimation, and optional online uncertainty recalibration. The README documents the overall workflow; source excerpts show simulator and policy behavior, while several predictor and policy modules are indexed but not excerpted, so their internal links are omitted where unverified.

Main entry points: [`experiments/run2.py`](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/experiments/run2.py) (Synthetic experiments), [`latent/policies/base.py`](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/base.py) (FIFO and policy base), [`experiments/run6.py`](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/experiments/run6.py) (ShareGPT experiments), [`latent/sim/simulator.py`](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/sim/simulator.py) (Single-worker simulator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workloads["Workload generation"]
  node_synthetic_workload["Synthetic workloads<br/>[synthetic.py]"]
  node_sharegpt_workload["ShareGPT workloads<br/>[sharegpt.py]"]
end

subgraph group_prediction["Prediction and uncertainty"]
  node_noisy_predictor["Synthetic predictions<br/>[noisy.py]"]
  node_learned_predictor["Learned predictor<br/>[learned.py]"]
  node_posterior["Posterior estimates<br/>[posterior.py]"]
  node_recalibrator["Online recalibration<br/>[recalibrate.py]"]
end

subgraph group_scheduling["Scheduling policies"]
  node_policy_base["FIFO and policy base<br/>[base.py]"]
  node_sjf_policy["Oracle and point SJF<br/>[sjf.py]"]
  node_aging_policy["Aging SJF<br/>[aging.py]"]
  node_latent_policy["LATENT policy<br/>[latent_policy.py]"]
  node_tie_policy["TIE-style policy<br/>[tie.py]"]
end

subgraph group_simulation["Simulation and results"]
  node_request["Request records<br/>[request.py]"]
  node_simulator["Single-worker simulator<br/>[simulator.py]"]
  node_metrics["Latency metrics<br/>[metrics.py]"]
  node_synthetic_experiment["Synthetic experiments<br/>[run2.py]"]
  node_sharegpt_experiment["ShareGPT experiments<br/>[run6.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs"| node_synthetic_experiment
node_researcher -->|"runs"| node_sharegpt_experiment
node_synthetic_experiment -->|"generates"| node_synthetic_workload
node_sharegpt_experiment -->|"generates"| node_sharegpt_workload
node_synthetic_workload -->|"creates"| node_request
node_sharegpt_workload -->|"creates"| node_request
node_synthetic_experiment -->|"adds predictions"| node_noisy_predictor
node_sharegpt_workload -.->|"uses predictions"| node_learned_predictor
node_synthetic_experiment -->|"runs"| node_simulator
node_sharegpt_experiment -->|"runs"| node_simulator
node_simulator -->|"selects via"| node_policy_base
node_latent_policy -->|"estimates cost"| node_posterior
node_latent_policy -->|"optionally recalibrates"| node_recalibrator
node_simulator -.->|"summarizes results"| node_metrics
node_synthetic_experiment -->|"computes metrics"| node_metrics
node_sharegpt_experiment -->|"computes metrics"| node_metrics
node_sjf_policy -.->|"implements"| node_policy_base
node_aging_policy -.->|"implements"| node_policy_base
node_latent_policy -->|"implements"| node_policy_base
node_tie_policy -.->|"implements"| node_policy_base

click node_synthetic_workload "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/workload/synthetic.py"
click node_sharegpt_workload "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/workload/sharegpt.py"
click node_request "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/sim/request.py"
click node_noisy_predictor "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/predictor/noisy.py"
click node_learned_predictor "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/predictor/learned.py"
click node_posterior "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/predictor/posterior.py"
click node_recalibrator "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/predictor/recalibrate.py"
click node_policy_base "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/base.py"
click node_sjf_policy "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/sjf.py"
click node_aging_policy "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/aging.py"
click node_latent_policy "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/latent_policy.py"
click node_tie_policy "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/tie.py"
click node_simulator "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/sim/simulator.py"
click node_metrics "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/sim/metrics.py"
click node_synthetic_experiment "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/experiments/run2.py"
click node_sharegpt_experiment "https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/experiments/run6.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_synthetic_workload,node_sharegpt_workload toneBlue
class node_noisy_predictor,node_learned_predictor,node_posterior,node_recalibrator toneAmber
class node_policy_base,node_sjf_policy,node_aging_policy,node_latent_policy,node_tie_policy toneMint
class node_request,node_simulator,node_metrics,node_synthetic_experiment,node_sharegpt_experiment toneRose
class node_researcher toneIndigo
```

## Components

### Workload generation

- [Synthetic workloads](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/workload/synthetic.py): `latent/workload/synthetic.py`
- [ShareGPT workloads](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/workload/sharegpt.py): `latent/workload/sharegpt.py`

### Prediction and uncertainty

- [Synthetic predictions](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/predictor/noisy.py): `latent/predictor/noisy.py`
- [Learned predictor](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/predictor/learned.py): `latent/predictor/learned.py`
- [Posterior estimates](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/predictor/posterior.py): `latent/predictor/posterior.py`
- [Online recalibration](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/predictor/recalibrate.py): `latent/predictor/recalibrate.py`

### Scheduling policies

- [FIFO and policy base](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/base.py): `latent/policies/base.py`
- [Oracle and point SJF](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/sjf.py): `latent/policies/sjf.py`
- [Aging SJF](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/aging.py): `latent/policies/aging.py`
- [LATENT policy](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/latent_policy.py): `latent/policies/latent_policy.py`
- [TIE-style policy](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/policies/tie.py): `latent/policies/tie.py`

### Simulation and results

- [Request records](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/sim/request.py): `latent/sim/request.py`
- [Single-worker simulator](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/sim/simulator.py): `latent/sim/simulator.py`
- [Latency metrics](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/latent/sim/metrics.py): `latent/sim/metrics.py`
- [Synthetic experiments](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/experiments/run2.py): `experiments/run2.py`
- [ShareGPT experiments](https://github.com/jamessshhh/bayesian-llm-inference-scheduling/blob/main/experiments/run6.py): `experiments/run6.py`

### Other components

- **Researcher**

## Connections

- Researcher → Synthetic experiments: runs (evidence: `README.md`)
- Researcher → ShareGPT experiments: runs (evidence: `README.md`)
- Synthetic experiments → Synthetic workloads: generates (evidence: `experiments/run2.py`)
- ShareGPT experiments → ShareGPT workloads: generates (evidence: `experiments/run6.py`)
- Synthetic workloads → Request records: creates (evidence: `latent/workload/synthetic.py`)
- ShareGPT workloads → Request records: creates (evidence: `latent/workload/sharegpt.py`)
- Synthetic experiments → Synthetic predictions: adds predictions (evidence: `experiments/run2.py`)
- ShareGPT workloads → Learned predictor: uses predictions
- Synthetic experiments → Single-worker simulator: runs (evidence: `experiments/run2.py`)
- ShareGPT experiments → Single-worker simulator: runs (evidence: `experiments/run6.py`)
- Single-worker simulator → FIFO and policy base: selects via (evidence: `latent/sim/simulator.py`)
- LATENT policy → Posterior estimates: estimates cost (evidence: `latent/policies/latent_policy.py`)
- LATENT policy → Online recalibration: optionally recalibrates (evidence: `latent/policies/latent_policy.py`)
- Single-worker simulator → Latency metrics: summarizes results
- Synthetic experiments → Latency metrics: computes metrics (evidence: `experiments/run2.py`)
- ShareGPT experiments → Latency metrics: computes metrics (evidence: `experiments/run6.py`)
- Oracle and point SJF → FIFO and policy base: implements (evidence: `latent/policies/sjf.py`)
- Aging SJF → FIFO and policy base: implements (evidence: `latent/policies/aging.py`)
- LATENT policy → FIFO and policy base: implements (evidence: `latent/policies/latent_policy.py`)
- TIE-style policy → FIFO and policy base: implements (evidence: `latent/policies/tie.py`)
