Files
Ziad ArafatandClaude Opus 5.5 20b1bc4c27 Ollama proxy; spread leases across GPUs
The proxy leases a not-yet-loaded model's size (+20%) and forces CPU-only
with 4 threads on a CPU grant; loaded models, other endpoints and a down
broker pass through. Spread leases let a model use both cards, as Ollama
does with gemma4-12b (8.4 GB > the 1080's 8 GB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 13:55:38 -07:00

159 lines
5.1 KiB
YAML

openapi: 3.0.3
info:
title: gpu-broker
version: 1.0.0
description: |
Hands out GPU memory on yveltal (GTX 1060 = GPU 0, GTX 1080 = GPU 1) so jobs don't fight over it.
A client asks for a lease with the VRAM it needs. The broker grants a GPU with room, or queues
the request (realtime > interactive > batch, first come first served within a priority). When
`max_wait_s` passes, a request with `cpu_fallback` is told to use the CPU instead. Leases expire
unless renewed (`ttl_s` in the status); release them when done.
Listens on 127.0.0.1 only; no authentication.
servers:
- url: http://127.0.0.1:8130
paths:
/v1/health:
get:
operationId: health
responses:
"200":
description: The broker is up and has a recent VRAM sample.
content:
application/json:
schema: {$ref: "#/components/schemas/Health"}
/v1/leases:
post:
operationId: acquireLease
description: Blocks until a GPU is free, the CPU fallback applies, or max_wait_s passes.
requestBody:
required: true
content:
application/json:
schema: {$ref: "#/components/schemas/LeaseRequest"}
responses:
"200":
description: Granted (a GPU, or the CPU).
content:
application/json:
schema: {$ref: "#/components/schemas/Grant"}
"400": {$ref: "#/components/responses/Problem"}
"413": {$ref: "#/components/responses/Problem"}
"503": {$ref: "#/components/responses/Problem"}
/v1/leases/{id}/renew:
post:
operationId: renewLease
parameters: [{$ref: "#/components/parameters/LeaseId"}]
responses:
"204": {description: Renewed.}
"404": {$ref: "#/components/responses/Problem"}
/v1/leases/{id}:
delete:
operationId: releaseLease
parameters: [{$ref: "#/components/parameters/LeaseId"}]
responses:
"204": {description: Released (also when it had already expired).}
/v1/status:
get:
operationId: status
responses:
"200":
description: GPUs, leases and the queue.
content:
application/json:
schema: {$ref: "#/components/schemas/Status"}
components:
parameters:
LeaseId:
name: id
in: path
required: true
schema: {type: string}
responses:
Problem:
description: Error.
content:
application/json:
schema: {$ref: "#/components/schemas/Problem"}
schemas:
Problem:
type: object
required: [error]
properties:
error: {type: string}
Health:
type: object
required: [status]
properties:
status: {type: string, enum: [ok, no_sample]}
Priority:
type: string
enum: [batch, interactive, realtime]
LeaseRequest:
type: object
required: [client, priority, vram_mb]
properties:
client: {type: string, description: "Who is asking, e.g. ollama-proxy, genres-guess."}
priority: {$ref: "#/components/schemas/Priority"}
vram_mb: {type: integer, minimum: 1}
max_wait_s: {type: integer, minimum: 0, description: "0 or absent: wait as long as it takes."}
cpu_fallback: {type: boolean, default: false}
prefer:
type: array
items: {type: integer}
description: GPU indexes to try first.
spread:
type: boolean
default: false
description: May be split across GPUs (Ollama splits a model that fits no single card).
Grant:
type: object
required: [device, gpu]
properties:
device: {type: string, enum: [gpu, cpu]}
gpu: {type: integer, description: "GPU index, -1 for the CPU."}
lease_id: {type: string, description: Absent for CPU grants.}
expires_at: {type: string, format: date-time}
Status:
type: object
required: [gpus, leases, waiting, ttl_s]
properties:
ttl_s: {type: integer}
gpus:
type: array
items: {$ref: "#/components/schemas/GpuStatus"}
leases:
type: array
items: {$ref: "#/components/schemas/LeaseInfo"}
waiting:
type: array
items: {$ref: "#/components/schemas/WaitInfo"}
GpuStatus:
type: object
required: [index, total_mb, used_mb, reserve_mb, free_mb]
properties:
index: {type: integer}
total_mb: {type: integer}
used_mb: {type: integer}
reserve_mb: {type: integer}
free_mb: {type: integer}
LeaseInfo:
type: object
required: [id, client, gpu, vram_mb, granted_at, expires_at]
properties:
id: {type: string}
client: {type: string}
gpu: {type: integer}
vram_mb: {type: integer}
granted_at: {type: string, format: date-time}
expires_at: {type: string, format: date-time}
WaitInfo:
type: object
required: [client, priority, vram_mb, since]
properties:
client: {type: string}
priority: {$ref: "#/components/schemas/Priority"}
vram_mb: {type: integer}
since: {type: string, format: date-time}