CoolFace
Apppublic

suryanshchattree/npa-ppo-train

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

Neural PagedAttention

RL environment for training AI agents to manage GPU KV Cache in LLM inference servers.

Motivation

Modern LLM servers are bottlenecked by memory. Standard heuristics like LRU fail under bimodal traffic because they cannot predict future requests or distinguish VIP from Free users. This environment trains RL agents to do both.

Environment Description

A deterministic Python simulator of PagedAttention hardware.

  • 1 Tick = 1 token generated across all active requests
  • GPU: 10,000 blocks (160,000 tokens)
  • CPU: 50,000 blocks (800,000 tokens) — swap target
  • Traffic: 80% Chatters, 20% Power Users, 30% Returning Users

Observation Space

20-dimensional normalized float array [0.0, 1.0] (trend: [-1.0, 1.0]).

#FieldDescription
1gpu_utilization_pctFraction of GPU blocks in use
2cpu_utilization_pctFraction of CPU blocks in use
3memory_pressure_trendGPU utilization slope over last 5 ticks (negative = falling)
4free_queue_pressureFree queue length / max (100)
5vip_queue_pressureVIP queue length / max (50)
6free_max_wait_time_pctOldest Free request wait / SLA threshold
7vip_max_wait_time_pctOldest VIP request wait / SLA threshold
8yield_preempt_activeLargest active request size / GPU capacity
9free_size_maxLargest idle Free GPU cache / GPU capacity
10free_size_meanMean idle Free GPU cache size
11free_size_std_devStd dev of idle Free GPU cache sizes
12vip_size_maxLargest idle VIP GPU cache / GPU capacity
13vip_size_meanMean idle VIP GPU cache size
14vip_size_std_devStd dev of idle VIP GPU cache sizes
15free_age_maxOldest idle Free GPU cache age (normalized to 500 ticks)
16free_age_meanMean idle Free GPU cache age
17free_age_std_devStd dev of idle Free GPU cache ages
18vip_age_maxOldest idle VIP GPU cache age
19vip_age_meanMean idle VIP GPU cache age
20vip_age_std_devStd dev of idle VIP GPU cache ages

Action Space

Discrete(18), indices 0–17.

IDAction
0Evict Largest Free cache (idle GPU only)
1Evict Largest VIP cache (idle GPU only)
2Evict Oldest Free cache (idle GPU only)
3Evict Oldest VIP cache (idle GPU only)
4Swap Largest Free cache GPU→CPU
5Swap Largest VIP cache GPU→CPU
6Swap Oldest Free cache GPU→CPU
7Swap Oldest VIP cache GPU→CPU
8Admit next Free user from queue
9Admit next VIP user from queue
10Reject next Free user (penalty if GPU has space)
11Reject next VIP user (penalty if GPU has space)
12Preempt & Shred Largest Active Free request
13Preempt & Shred Largest Active VIP request
14Preempt & Swap Largest Active Free → CPU
15Preempt & Swap Largest Active VIP → CPU
16Garbage Collect (delete idle Free CPU caches > 200 ticks)
17Do Nothing

Tasks

TaskTrafficSLA FreeSLA VIPMax Ticks
easy1 req/tickNoneNone2,000
mediumDay/night100505,000
hardViral spikes502510,000

Baseline Scores

TaskRandom AgentLLM Baseline
easyTBDTBD
mediumTBDTBD
hardTBDTBD

Setup

bash
docker build -t neural-paged-attention ./server
docker run -p 7860:7860 neural-paged-attention

Running Inference

bash
export HF_TOKEN=your_token
export MODEL_NAME=TinyLlama/TinyLlama-1.1B-Chat-v1.0
python inference.py