Skip to content
Limited preview Core mixed-integer linear modeling and execution are available. Formulation planning and algorithmic discovery are not included yet.

GPU allocation

This example creates one candidate row for every compatible pool and workload pair. The model allocates integer GPU units while respecting capacity and demand on both sides.

Download gpu_pools.csv and workloads.csv, or create them from the snippets below.

gpu_pools.csv
pool_id,capacity,mem_gb,cost
1,8,24,255
2,6,16,180
3,4,32,218
workloads.csv
workload_id,demand,min_mem
101,4,8
102,1,8
103,3,32
pools_candidates.deql
CREATE CANDIDATES pool_assignments
DECISION KEY (pool_id, workload_id)
AS (
SELECT
pool_id,
workload_id,
capacity,
demand,
mem_gb,
min_mem,
cost
FROM gpu_pools
CROSS JOIN workloads
WHERE mem_gb >= min_mem
);

The cross join creates possible assignments. The WHERE clause removes pools without enough memory for a workload.

pools_query.deql
DECIDE INTO allocation
FROM pool_assignments
DECISION COLUMNS (
gpus INTEGER BETWEEN 0 AND 6
)
SUBJECT TO
CONSTRAINT capacity:
SUM(gpus) <= capacity BY (pool_id),
CONSTRAINT demand:
SUM(gpus) = demand BY (workload_id)
MINIMIZE SUM(cost * gpus);

The capacity constraint is repeated for every pool. The demand constraint is repeated for every workload.

Terminal window
./deql \
--register-files gpu_pools.csv,workloads.csv \
pools_candidates.deql \
pools_query.deql

The minimum-cost solution places workloads 101 and 102 on pool 2, then serves workload 103 from pool 3.

Non-zero allocation rows
pool_id workload_id capacity demand mem_gb min_mem cost gpus
2 101 6 4 16 8 180 4.0
2 102 6 1 16 8 180 1.0
3 103 4 3 32 32 218 3.0
optimal · objective 1554 · highs