mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 20:44:00 +00:00
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:
@@ -194,8 +194,9 @@ and remote-API Functions both build on below.
|
||||
`db.list_gpu_classes()` lists the GPU classes configured for the deployment.
|
||||
Each record reports the operator's hardware description and limits; it does
|
||||
not mean a GPU is currently free. Listing requires the System Usage
|
||||
permission. Pass a returned class name to `gpu_class` to fix that placement
|
||||
in the Function version. `gpu=True` remains required:
|
||||
permission. Pass a returned class name to `gpu_class`, such as `gpu=True, gpu_class="a10g", gpu_count=2`,
|
||||
to select a pool; `gpu_count` controls the GPUs allocated together to each worker.
|
||||
`gpu_count` defaults to one. Omitting `gpu` uses CPU workers:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
@@ -242,9 +243,29 @@ longest observed call. The 600 seconds above is one working GPU example, not a
|
||||
universal recommendation.
|
||||
|
||||
Older servers that do not implement `GET /v1/gpu/classes` raise
|
||||
`NotImplementedError`. Without `gpu_class`, the deployment's default GPU
|
||||
class is used. The class is immutable with the Function version; set a
|
||||
per-refresh class or aggregate GPU budget through
|
||||
`NotImplementedError`. With `gpu=True`, omitting `gpu_class` accepts any
|
||||
eligible configured class, equivalent to `gpu_class="any"`. Use
|
||||
`gpu_class="default"` to request the default pool explicitly. Class names
|
||||
must be lowercase. Counts
|
||||
must be positive integers; the deployment must have a node that can supply
|
||||
that many devices together. `max_gpu_count_per_worker` in the class inventory
|
||||
is the operator's cap; an unset cap does not promise unlimited hardware.
|
||||
Use `gpu=True, gpu_class="any", gpu_count=2` when any configured GPU class is acceptable, but each
|
||||
worker needs two devices together. `gpu=True, gpu_class="any"` requests one GPU. The server
|
||||
selects a class that fits the request using operator-configured limits,
|
||||
preferring known multi-GPU limits over unspecified limits. The selected
|
||||
class is fixed for the worker cohort; selection does not reserve capacity
|
||||
until the worker is scheduled. `gpu=True, gpu_count=2` makes the same request
|
||||
as `gpu=True, gpu_class="any", gpu_count=2`. A Function with an `any` request
|
||||
can share a SQL job with a
|
||||
Function pinned to a class; that job uses the pinned class.
|
||||
|
||||
The request is immutable with the Function version. Configure tensor
|
||||
parallelism in the model separately, for example vLLM's
|
||||
`tensor_parallel_size=2` for `gpu=True, gpu_class="a10g", gpu_count=2`.
|
||||
|
||||
The refresh `total_gpu_count` is a separate aggregate budget across workers and
|
||||
must be at least the Function's per-worker count. Set it through
|
||||
[`refresh_column_async`](/feature-engineering/refresh-column#resources).
|
||||
|
||||
The model loads once per worker instance, in `__init__`; `__call__` only
|
||||
@@ -480,3 +501,62 @@ as `bytes`; this feature does not add streamed outputs.
|
||||
Filling the column a Function is bound to, and re-filling it as inputs change.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
## Default execution budgets
|
||||
|
||||
`total_cpu_millis`, `total_memory_bytes`, and
|
||||
`total_gpu_count` supply execution-wide defaults. CPU is in millicores
|
||||
(1000 = one core), memory is in bytes, and GPU count is a total across workers.
|
||||
All five resource settings use the same names at registration, creation, and
|
||||
refresh. Each resolves independently in this order:
|
||||
|
||||
1. The refresh's value.
|
||||
2. The column or materialized view's value.
|
||||
3. The registered Function's value.
|
||||
4. The deployment default for total budgets and device count; any eligible
|
||||
configured GPU class when no layer specifies one.
|
||||
|
||||
For a materialized view using multiple Functions, the third layer adds the
|
||||
`total_*` budgets across distinct pinned Function versions. Its per-worker GPU
|
||||
count uses the largest Function default, and GPU classes must be compatible
|
||||
unless the declaration or refresh overrides the class. Calling the same version
|
||||
more than once counts it once. Column and view defaults also apply when the
|
||||
service schedules a refresh automatically. Integer overflow or a budget that
|
||||
cannot fit a required worker is rejected.
|
||||
|
||||
```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("embedding", gpu_class="h100", gpu_count=4, total_gpu_count=8)
|
||||
|
||||
db.create_materialized_view(
|
||||
"embeddings", query="SELECT embed(text) AS embedding FROM documents",
|
||||
total_cpu_millis=16000,
|
||||
gpu_class="any",
|
||||
gpu_count=2,
|
||||
total_gpu_count=8,
|
||||
)
|
||||
```
|
||||
|
||||
`gpu_class` selects the GPU pool and `gpu_count` selects the positive number
|
||||
of devices allocated together to each worker. Both can be overridden at
|
||||
column/MV creation and refresh. An explicit `gpu_class="any"` replaces a
|
||||
registered class with any eligible configured pool. These settings require a
|
||||
GPU Function for computed columns. The `total_*` values are ceilings for the
|
||||
whole worker fleet. CPU and memory can limit the fleet before it reaches its GPU ceiling.
|
||||
|
||||
Reference in New Issue
Block a user