feat!: layer GPU settings and total execution limits (#5146)

BREAKING CHANGE: Resource inputs use the same names at Function
registration, column/MV creation, and refresh. Use total_cpu_millis,
total_memory_bytes, and total_gpu_count for execution-wide worker
budgets, plus gpu_class and positive gpu_count for each worker. Replace
budget dictionary inputs and unprefixed aggregate limits with these
fields. Move existing refresh gpu_count caps to total_gpu_count;
gpu_count now selects devices per worker.

Each setting resolves independently: refresh > column/MV creation >
Function annotation > deployment. Creation settings also apply to
initial MV population and automatic refresh. MVs sum total budgets
across distinct pinned Function versions; per-worker GPU counts use the
largest Function default unless overridden. An unset GPU class resolves
to gpu_class="any" after inheritance; an explicit "any" overrides a
registered concrete class. Use gpu_class="default" to pin the default
pool explicitly.

```python
@function(
    gpu=True, gpu_class="h100", gpu_count=2,
    total_cpu_millis=8000,
    total_memory_bytes=16 * 1024**3,
    total_gpu_count=4,
)
def embed(text: str) -> list[float]: ...

version = db.create_function(embed)
table.add_columns(
    {"embedding": version(text=col("text"))},
    gpu_class="any", gpu_count=1, total_gpu_count=8,
)
table.refresh_column_async(
    "embedding", gpu_class="h100", gpu_count=4, total_gpu_count=8,
)

mv = db.create_materialized_view(
    "embeddings", query="SELECT embed(text) AS embedding FROM documents",
    gpu_class="any", gpu_count=2, total_gpu_count=8,
)
mv.refresh(gpu_count=4, total_gpu_count=8)
```

```mermaid
flowchart TD
    R["Refresh settings"] --> E["Effective settings, resolved per field"]
    D["Column or MV creation settings"] --> E
    F["Function settings"] --> E
    C["Deployment defaults"] --> E
    E --> W["GPU class and device count per worker"]
    E --> T["Total CPU, memory and GPU ceilings"]
```

Pinned Function images retain their identity. Registration GPU counts
are defaults; execution overrides determine worker allocation. Admission
rejects GPU counts below an image's minimum requirement or above the
total budget. Python, Rust, SQL/REST and supported TypeScript operations
use the same resource model.

No local builds or tests, as requested; regression coverage runs in CI.
This commit is contained in:
Jack Ye
2026-11-21 15:04:34 -08:00
committed by GitHub
parent e3e55844bc
commit 2b1b2a29dd
50 changed files with 2110 additions and 946 deletions
+29 -58
View File
@@ -998,7 +998,7 @@ describe("remote connection", () => {
publicationIntervalRows: 60,
maxConcurrency: 3,
gpuClass: "a10g",
gpuCount: 2,
totalGpuCount: 2,
errorPolicy: "skip",
maxFailedFraction: 0.01,
maxFailedRows: 50,
@@ -1021,10 +1021,8 @@ describe("remote connection", () => {
});
}
await table.refreshColumnAsync("embedding", {
resourceBudget: {
cpuMillis: 8_000,
memoryBytes: 16 * 1024 ** 3,
},
totalCpuMillis: 8_000,
totalMemoryBytes: 16 * 1024 ** 3,
});
await expect(
table.refreshColumnAsync("embedding", {
@@ -1069,75 +1067,53 @@ describe("remote connection", () => {
[{ maxConcurrency: Number.NaN }, "maxConcurrency"],
[{ maxConcurrency: Number.POSITIVE_INFINITY }, "maxConcurrency"],
[{ numWorkers: 0 }, "num_workers"],
[{ gpuCount: 0 }, "gpu_count"],
[
{
resourceBudget: {
cpuMillis: 1_000,
memoryBytes: 1_024,
},
gpuCount: 1,
totalCpuMillis: 0,
totalMemoryBytes: 1_024,
},
"gpu_count cannot be combined with resource_budget",
"totalCpuMillis",
],
[
{
resourceBudget: {
cpuMillis: 0,
memoryBytes: 1_024,
},
totalCpuMillis: 1_000,
totalMemoryBytes: 1_024,
totalGpuCount: 1.5,
},
"resourceBudget.cpuMillis",
"totalGpuCount",
],
[
{
resourceBudget: {
cpuMillis: 1_000,
memoryBytes: 1_024,
gpuCount: 1.5,
},
totalCpuMillis: 1_000,
totalMemoryBytes: 1_024,
totalGpuCount: -1,
},
"resourceBudget.gpuCount",
"totalGpuCount",
],
[
{
resourceBudget: {
cpuMillis: 1_000,
memoryBytes: 1_024,
gpuCount: -1,
},
totalCpuMillis: 1_000,
totalMemoryBytes: 1_024,
totalGpuCount: 2 ** 32,
},
"resourceBudget.gpuCount",
"totalGpuCount",
],
[
{
resourceBudget: {
cpuMillis: 1_000,
memoryBytes: 1_024,
gpuCount: 2 ** 32,
},
totalCpuMillis: 1_000,
totalMemoryBytes: 1_024,
totalGpuCount: Number.NaN,
},
"resourceBudget.gpuCount",
"totalGpuCount",
],
[
{
resourceBudget: {
cpuMillis: 1_000,
memoryBytes: 1_024,
gpuCount: Number.NaN,
},
totalCpuMillis: 1_000,
totalMemoryBytes: 1_024,
totalGpuCount: Number.POSITIVE_INFINITY,
},
"resourceBudget.gpuCount",
],
[
{
resourceBudget: {
cpuMillis: 1_000,
memoryBytes: 1_024,
gpuCount: Number.POSITIVE_INFINITY,
},
},
"resourceBudget.gpuCount",
"totalGpuCount",
],
[
{
@@ -1186,7 +1162,7 @@ describe("remote connection", () => {
JSON.parse(
`{"column": "embedding", "where": "id % 2 = 0", "batch_size": 16,
"publication_interval_rows": 60,
"max_concurrency": 3, "gpu_class": "a10g", "gpu_count": 2,
"max_concurrency": 3, "gpu_class": "a10g", "total_gpu_count": 2,
"error_policy": "skip",
"max_failed_fraction": 0.01, "max_failed_rows": 50,
"row_timeout_seconds": 30, "init_timeout_seconds": 120,
@@ -1202,12 +1178,7 @@ describe("remote connection", () => {
'{"column": "embedding", "publication_interval_rows": 9007199254740991}',
),
JSON.parse(
`{"column": "embedding",
"resource_budget": {
"cpu_millis": 8000,
"memory_bytes": 17179869184,
"gpu_count": 0
}}`,
'{"column":"embedding","total_cpu_millis":8000,"total_memory_bytes":17179869184}',
),
]);
});