mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +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:
@@ -196,10 +196,20 @@ it can be queried, indexed and searched, and it appears in `tableNames`.
|
||||
|
||||
* **options?**
|
||||
|
||||
* **options.gpuClass?**: `string`
|
||||
|
||||
* **options.gpuCount?**: `number`
|
||||
|
||||
* **options.limit?**: `number`
|
||||
|
||||
* **options.select?**: [`MaterializedViewSelect`](../type-aliases/MaterializedViewSelect.md)
|
||||
|
||||
* **options.totalCpuMillis?**: `number`
|
||||
|
||||
* **options.totalGpuCount?**: `number`
|
||||
|
||||
* **options.totalMemoryBytes?**: `number`
|
||||
|
||||
* **options.where?**: `string`
|
||||
|
||||
* **options.withNoData?**: `boolean`
|
||||
|
||||
@@ -78,8 +78,18 @@ source-version pinning. Their results leave `mode`, `rowsWritten`, and
|
||||
|
||||
* **options.full?**: `boolean`
|
||||
|
||||
* **options.gpuClass?**: `string`
|
||||
|
||||
* **options.gpuCount?**: `number`
|
||||
|
||||
* **options.sourceVersion?**: `number`
|
||||
|
||||
* **options.totalCpuMillis?**: `number`
|
||||
|
||||
* **options.totalGpuCount?**: `number`
|
||||
|
||||
* **options.totalMemoryBytes?**: `number`
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`RefreshMaterializedViewResult`](../interfaces/RefreshMaterializedViewResult.md)>
|
||||
|
||||
@@ -1480,26 +1480,18 @@ LanceDB Enterprise it is the server's backfill job.
|
||||
`REFRESH COLUMN ... WHERE ... WITH (...)` form: `where` narrows the rows,
|
||||
`errorPolicy`, `maxFailedFraction`, `maxFailedRows`, `rowTimeoutSeconds`
|
||||
and `initTimeoutSeconds` govern failing rows. `batchSize`, `gpuClass`,
|
||||
`maxConcurrency`, `resourceBudget`, `supervisorResources`,
|
||||
`maxConcurrency`, `totalCpuMillis`, `totalMemoryBytes`, `supervisorResources`,
|
||||
`planningWorkers` and `maxExecutorProcessesPerWorker` size registered
|
||||
Function refreshes. `retryPolicy` overrides user-code retries only when
|
||||
repeating partial work is safe; set `maxAttempts: 1` to disable retries.
|
||||
`maxConcurrency` overrides the registered default for this logical
|
||||
execution only and is a positive integer; it is not an account-wide
|
||||
quota. A `resourceBudget` requires `cpuMillis` and
|
||||
`memoryBytes`; its `gpuCount` defaults to zero for a CPU-only Function.
|
||||
`supervisorResources` and each `planningWorkers.resources` entry require
|
||||
positive `cpuMillis`, `memoryBytes` and `ephemeralStorageBytes`.
|
||||
`planningWorkers` also requires positive `maxWorkers`,
|
||||
`rowsPerWorker` and `fragmentsPerWorker`.
|
||||
The budget applies only to this explicit refresh and does not configure
|
||||
a later automatic refresh.
|
||||
`gpuCount` at the top level is the shorthand that preserves the
|
||||
deployment defaults for CPU and memory, and cannot be combined with
|
||||
`resourceBudget`. `numWorkers` applies only to expression columns; use
|
||||
`resourceBudget` for registered Functions. All are LanceDB Enterprise
|
||||
only; a LanceDB Embedded refresh rejects every option other than
|
||||
`batchSize`, `gpuClass` and `gpuCount`.
|
||||
quota. `totalCpuMillis`, `totalMemoryBytes`, and `totalGpuCount` override
|
||||
their corresponding execution-wide resource limits independently. Unset
|
||||
values inherit column defaults, then Function defaults, then deployment
|
||||
defaults. A zero GPU limit is valid for CPU-only Functions.
|
||||
`supervisorResources` and `planningWorkers.resources` are per-pod sizes.
|
||||
`numWorkers` applies only to expression columns.
|
||||
`publicationIntervalRows` opts into publishing completed Function split
|
||||
ranges once their accumulated unpublished rows reach the threshold.
|
||||
It must be a positive safe integer and requires non-Blob Function outputs.
|
||||
@@ -1515,10 +1507,8 @@ LanceDB Enterprise it is the server's backfill job.
|
||||
```ts
|
||||
const job = await table.refreshColumnAsync("embedding", {
|
||||
where: "published_at > '2026-01-01'",
|
||||
resourceBudget: {
|
||||
cpuMillis: 8000,
|
||||
memoryBytes: 16 * 1024 ** 3,
|
||||
},
|
||||
totalCpuMillis: 8000,
|
||||
totalMemoryBytes: 16 * 1024 ** 3,
|
||||
maxConcurrency: 4,
|
||||
publicationIntervalRows: 10000,
|
||||
errorPolicy: "skip",
|
||||
|
||||
@@ -115,7 +115,6 @@
|
||||
- [FunctionRefreshPlanningConfig](interfaces/FunctionRefreshPlanningConfig.md)
|
||||
- [FunctionRefreshPodResources](interfaces/FunctionRefreshPodResources.md)
|
||||
- [FunctionRetryPolicy](interfaces/FunctionRetryPolicy.md)
|
||||
- [FunctionWorkerResourceBudget](interfaces/FunctionWorkerResourceBudget.md)
|
||||
- [HnswPqOptions](interfaces/HnswPqOptions.md)
|
||||
- [HnswSqOptions](interfaces/HnswSqOptions.md)
|
||||
- [IndexConfig](interfaces/IndexConfig.md)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
||||
|
||||
***
|
||||
|
||||
[@lancedb/lancedb](../globals.md) / FunctionWorkerResourceBudget
|
||||
|
||||
# Interface: FunctionWorkerResourceBudget
|
||||
|
||||
Aggregate worker resources for one Enterprise Function refresh.
|
||||
|
||||
## Properties
|
||||
|
||||
### cpuMillis
|
||||
|
||||
```ts
|
||||
cpuMillis: number;
|
||||
```
|
||||
|
||||
Aggregate CPU budget in millicores; 1000 is one CPU.
|
||||
|
||||
***
|
||||
|
||||
### gpuCount?
|
||||
|
||||
```ts
|
||||
optional gpuCount: number;
|
||||
```
|
||||
|
||||
Aggregate GPU budget. Omitted means zero, a CPU-only refresh.
|
||||
|
||||
***
|
||||
|
||||
### memoryBytes
|
||||
|
||||
```ts
|
||||
memoryBytes: number;
|
||||
```
|
||||
|
||||
Aggregate memory budget in bytes.
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
Options for `Table.refreshColumn` and `Table.refreshColumnAsync`. Every
|
||||
option is LanceDB Enterprise only; a LanceDB Embedded refresh ignores
|
||||
`batchSize`, `gpuClass` and `gpuCount` and rejects the rest, including
|
||||
`resourceBudget`.
|
||||
`batchSize`, `gpuClass` and `totalGpuCount` and rejects the rest.
|
||||
|
||||
## Properties
|
||||
|
||||
@@ -50,7 +49,7 @@ GPU class for Function workers.
|
||||
optional gpuCount: number;
|
||||
```
|
||||
|
||||
Positive aggregate GPU budget for Function workers.
|
||||
Positive GPU count allocated to each Function worker.
|
||||
|
||||
***
|
||||
|
||||
@@ -140,17 +139,6 @@ Requires LanceDB Enterprise with non-Blob Function outputs.
|
||||
|
||||
***
|
||||
|
||||
### resourceBudget?
|
||||
|
||||
```ts
|
||||
optional resourceBudget: FunctionWorkerResourceBudget;
|
||||
```
|
||||
|
||||
Complete aggregate CPU and memory budget for a registered Function
|
||||
refresh. `gpuCount` inside the budget defaults to zero.
|
||||
|
||||
***
|
||||
|
||||
### retryPolicy?
|
||||
|
||||
```ts
|
||||
@@ -181,6 +169,36 @@ CPU, memory, and ephemeral-storage limits for the refresh supervisor.
|
||||
|
||||
***
|
||||
|
||||
### totalCpuMillis?
|
||||
|
||||
```ts
|
||||
optional totalCpuMillis: number;
|
||||
```
|
||||
|
||||
Override the total CPU budget in millicores for this refresh.
|
||||
|
||||
***
|
||||
|
||||
### totalGpuCount?
|
||||
|
||||
```ts
|
||||
optional totalGpuCount: number;
|
||||
```
|
||||
|
||||
Nonnegative total GPU budget for Function workers.
|
||||
|
||||
***
|
||||
|
||||
### totalMemoryBytes?
|
||||
|
||||
```ts
|
||||
optional totalMemoryBytes: number;
|
||||
```
|
||||
|
||||
Override the total memory budget in bytes for this refresh.
|
||||
|
||||
***
|
||||
|
||||
### where?
|
||||
|
||||
```ts
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -71,45 +71,46 @@ Both a Function application and a SQL expression accept
|
||||
`auto_refresh_enabled` and `auto_refresh_interval_seconds`, and both refresh
|
||||
and toggle the same way; see [Auto Refresh](/enterprise/auto-refresh).
|
||||
|
||||
Python and Rust Function declarations can also set
|
||||
`auto_refresh_resource_budget` to give their automatic refreshes an aggregate
|
||||
CPU, memory, and optional GPU budget. CPU and memory are required. The nested
|
||||
`gpu_count` defaults to zero, so omitting it requests CPU-only workers:
|
||||
Function declarations can set `total_cpu_millis`,
|
||||
`total_memory_bytes`, and `total_gpu_count`. Each optional
|
||||
value supplies a default for both manual and automatic refreshes. `gpu_class`
|
||||
and `gpu_count` similarly override the Function's per-worker GPU defaults.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
table.add_columns(
|
||||
{"caption": version(jpeg=col("jpeg"))},
|
||||
auto_refresh_resource_budget={
|
||||
"cpu_millis": 8000,
|
||||
"memory_bytes": 16 * 1024**3,
|
||||
},
|
||||
total_cpu_millis=8000,
|
||||
total_memory_bytes=16 * 1024**3,
|
||||
total_gpu_count=4,
|
||||
gpu_class="any",
|
||||
gpu_count=2,
|
||||
)
|
||||
```
|
||||
|
||||
```rust Rust icon="rust"
|
||||
use lancedb::table::computed_columns::ComputedColumnOptions;
|
||||
|
||||
table
|
||||
.add_columns()
|
||||
.function(function_application)
|
||||
.computed_options(ComputedColumnOptions {
|
||||
auto_refresh_enabled: true,
|
||||
auto_refresh_interval_seconds: None,
|
||||
auto_refresh_resource_budget: Some(
|
||||
FunctionWorkerResourceBudget::new(8000, 17_179_869_184),
|
||||
),
|
||||
total_cpu_millis: Some(8000),
|
||||
total_memory_bytes: Some(16 * 1024_u64.pow(3)),
|
||||
total_gpu_count: Some(4),
|
||||
gpu_class: Some("any".into()),
|
||||
gpu_count: Some(2),
|
||||
..Default::default()
|
||||
})
|
||||
.execute()
|
||||
.await?;
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
This setting applies to every output in the Function binding. SQL-expression
|
||||
columns do not use Function workers, so they reject
|
||||
`auto_refresh_resource_budget` instead of accepting an option that has no
|
||||
effect. The separate `resource_budget` refresh option configures one explicit
|
||||
refresh and does not change this automatic-refresh declaration. The Node.js
|
||||
SDK does not currently expose a Function declaration through `addColumns`, so
|
||||
this option is not added to an unsupported surface.
|
||||
Refresh values with the same names override these column defaults. Unspecified column
|
||||
values inherit the pinned Function's `total_*` settings, then the
|
||||
deployment defaults. The GPU budget must fit one Function worker. These
|
||||
settings apply to registered Function columns in LanceDB Enterprise.
|
||||
|
||||
## Fill a column with a SQL expression {#expressions}
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ too slow or too expensive:
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
REFRESH COLUMN embedding ON documents
|
||||
WITH (cpu_millis = 8000, memory_bytes = 17179869184, gpu_count = 2)
|
||||
WITH (total_cpu_millis = 8000, total_memory_bytes = 17179869184, total_gpu_count = 2)
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -342,75 +342,65 @@ up to 8 CPUs, 16 GiB of memory, and 2 GPUs across the fleet. They are not
|
||||
per-worker allocations or a guaranteed worker count. `num_workers` is only
|
||||
accepted for SQL-expression columns; registered Function columns reject it.
|
||||
|
||||
In particular, `gpu_count = 2` does not request two devices inside one Python
|
||||
In particular, `total_gpu_count = 2` does not request two devices inside one Python
|
||||
process or enable tensor parallelism. Inspect configured GPU classes and their
|
||||
per-worker limits with `db.list_gpu_classes()` or `SHOW GPU CLASSES`. Choose a
|
||||
model that fits the worker shape supported by your deployment; see
|
||||
[GPU placement and budgets](/enterprise/function-operations#gpu).
|
||||
|
||||
The SDKs accept the same nested budget. CPU and memory are required; the GPU
|
||||
count inside the budget defaults to zero, so a CPU-only Function can omit it:
|
||||
The SDKs expose the same independent total limits:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
job = table.refresh_column_async(
|
||||
"embedding",
|
||||
resource_budget={
|
||||
"cpu_millis": 8000,
|
||||
"memory_bytes": 16 * 1024**3,
|
||||
},
|
||||
total_cpu_millis=8000,
|
||||
total_memory_bytes=16 * 1024**3,
|
||||
total_gpu_count=2,
|
||||
)
|
||||
job.wait()
|
||||
```
|
||||
|
||||
```rust Rust icon="rust"
|
||||
use lancedb::table::{
|
||||
FunctionWorkerResourceBudget,
|
||||
RefreshColumnOptions,
|
||||
};
|
||||
use lancedb::table::RefreshColumnOptions;
|
||||
|
||||
let _job = table
|
||||
.refresh_column_async_with_options(
|
||||
"embedding",
|
||||
RefreshColumnOptions::default().resource_budget(
|
||||
FunctionWorkerResourceBudget::new(8000, 17_179_869_184),
|
||||
),
|
||||
RefreshColumnOptions::default()
|
||||
.total_cpu_millis(8000)
|
||||
.total_memory_bytes(17_179_869_184)
|
||||
.total_gpu_count(2),
|
||||
)
|
||||
.await?;
|
||||
```
|
||||
|
||||
```typescript TypeScript icon="typescript"
|
||||
const job = await table.refreshColumnAsync("embedding", {
|
||||
resourceBudget: {
|
||||
cpuMillis: 8000,
|
||||
memoryBytes: 16 * 1024 ** 3,
|
||||
},
|
||||
totalCpuMillis: 8000,
|
||||
totalMemoryBytes: 16 * 1024 ** 3,
|
||||
totalGpuCount: 2,
|
||||
});
|
||||
await job.wait();
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
On current SQL servers, the equivalent `REFRESH COLUMN ... WITH (...)` form
|
||||
still takes all three fields when CPU or memory is set; use `gpu_count = 0`
|
||||
for a CPU-only Function. The SDK normalizes an omitted nested GPU count to a
|
||||
numeric zero before sending the request.
|
||||
|
||||
The existing top-level `gpu_count` / `gpuCount` option remains the shorthand
|
||||
for changing only the aggregate GPU budget. It cannot be combined with the
|
||||
complete resource budget. Omitting both preserves the server's existing
|
||||
defaults.
|
||||
Each supplied `total_*` value overrides that resource for this refresh.
|
||||
Unspecified values inherit the column's `total_*` settings, then the
|
||||
pinned Function's defaults, then the deployment defaults. `total_gpu_count=0`
|
||||
limits the refresh to CPU workers and cannot run a GPU Function.
|
||||
|
||||
{/*
|
||||
Draft for the Function refresh control-plane resource release.
|
||||
|
||||
`resource_budget` above sizes the Function workers. Two independent options
|
||||
`total_cpu_millis`, `total_memory_bytes`, and `total_gpu_count` above sizes the Function workers. Two independent options
|
||||
size the refresh control plane for a registered Function.
|
||||
`supervisor_resources` sets the CPU, memory and ephemeral-storage limits of
|
||||
the supervisor pod. `planning_workers` sets the resources of one planning
|
||||
worker and the sizing of the CPU-only planning fleet: `max_workers`,
|
||||
`rows_per_worker` and `fragments_per_worker`. Every field is required and
|
||||
must be positive. Omitting either option leaves the server's configured
|
||||
defaults unchanged, and either can be combined with `resource_budget`.
|
||||
defaults unchanged, and either can be combined with `total_cpu_millis`, `total_memory_bytes`, and `total_gpu_count`.
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
@@ -495,11 +485,11 @@ The SDK validates the shape and sends these values only with this explicit
|
||||
refresh request. A supporting LanceDB Enterprise server is required.
|
||||
*/}
|
||||
|
||||
These examples configure only the explicit refresh shown. A registered
|
||||
Function declaration can separately set `auto_refresh_resource_budget` on
|
||||
`add_columns`; that declaration controls the budget for its automatic
|
||||
refreshes. SQL-expression columns reject the automatic resource-budget option
|
||||
because they do not use Function workers.
|
||||
A Function column may set `total_cpu_millis`,
|
||||
`total_memory_bytes`, and `total_gpu_count` on `add_columns`.
|
||||
These override the Function defaults for both manual and automatic refreshes.
|
||||
The settings apply to registered Function columns; SQL-expression columns use
|
||||
`num_workers` instead.
|
||||
|
||||
To override the registered Function's call concurrency for this logical
|
||||
execution only:
|
||||
@@ -531,7 +521,7 @@ await job.wait();
|
||||
|
||||
`max_concurrency` caps user-code calls in flight for one Function within one
|
||||
logical execution. It is not an account-wide quota and does not resize or
|
||||
rewrite `resource_budget`. Omitting it uses the registration default; a
|
||||
rewrite `total_cpu_millis`, `total_memory_bytes`, and `total_gpu_count`. Omitting it uses the registration default; a
|
||||
refresh value overrides that default for this execution only.
|
||||
|
||||
`batch_size` caps rows in one Function call; LanceDB adapts actual call and
|
||||
@@ -613,7 +603,7 @@ gpu_class = next(gpu.name for gpu in classes if gpu.gpu_model == "NVIDIA H100")
|
||||
job = table.refresh_column_async(
|
||||
"embedding",
|
||||
gpu_class=gpu_class,
|
||||
gpu_count=4,
|
||||
total_gpu_count=4,
|
||||
batch_size=32,
|
||||
)
|
||||
```
|
||||
@@ -637,7 +627,7 @@ async fn refresh(
|
||||
"embedding",
|
||||
RefreshColumnOptions::default()
|
||||
.gpu_class(gpu_class)
|
||||
.gpu_count(4)
|
||||
.total_gpu_count(4)
|
||||
.batch_size(32),
|
||||
)
|
||||
.await?;
|
||||
@@ -646,19 +636,21 @@ async fn refresh(
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
`gpu_count` is the aggregate GPU budget for the refresh's Function workers,
|
||||
not a request for that many GPUs per worker. It must be positive and preserves
|
||||
the deployment's CPU and memory defaults.
|
||||
`total_gpu_count` is the aggregate GPU budget for the refresh's Function workers,
|
||||
and `gpu_count` is the positive number of devices allocated together to each
|
||||
worker. The total budget must fit at least one worker. Omitted CPU and memory
|
||||
values inherit column settings, then Function settings, then deployment defaults.
|
||||
`gpu_class` must name a class returned by `list_gpu_classes()`; class names
|
||||
are lowercase DNS labels. Omit either option to use the Function's registered
|
||||
class or the server's configured budget. `list_gpu_classes()` requires System
|
||||
are lowercase DNS labels; `"any"` accepts any eligible configured class. Each
|
||||
omitted setting inherits the column's setting, then the Function's setting.
|
||||
If no layer specifies a GPU class, omission is equivalent to `"any"`. `list_gpu_classes()` requires System
|
||||
Usage permission, and raises `NotImplementedError` when the server predates
|
||||
GPU class discovery.
|
||||
|
||||
<Note>
|
||||
The Rust GPU discovery and refresh controls are not in the latest Rust
|
||||
release. TypeScript does not expose GPU class discovery; pass `gpuClass`
|
||||
and `gpuCount` in the `refreshColumnAsync` options.
|
||||
and `totalGpuCount` in the `refreshColumnAsync` options.
|
||||
</Note>
|
||||
|
||||
Completed Function outputs publish with their fragment by default. To opt into
|
||||
@@ -750,8 +742,8 @@ The SDK rejects a blank `where`, a `max_failed_fraction` outside 0 to 1, a
|
||||
timeout that is not a positive number and a zero worker or process count
|
||||
before sending the request; the server validates everything else. A LanceDB
|
||||
Embedded refresh rejects every option other than `batch_size`, `gpu_class`
|
||||
and `gpu_count`; in particular, it rejects `resource_budget` rather than
|
||||
silently ignoring it.
|
||||
and `total_gpu_count`; in particular, it rejects `total_cpu_millis` and
|
||||
`total_memory_bytes` rather than silently ignoring them.
|
||||
|
||||
## When a refresh fails {#failures}
|
||||
|
||||
|
||||
@@ -60,20 +60,20 @@ LanceDB Embedded it always matches `rows_written` from the most recent
|
||||
refresh.
|
||||
|
||||
{/*
|
||||
Draft: publish this section after the Python/Rust resource-budget SDK support
|
||||
is released. TypeScript parity is tracked separately in issue #4903.
|
||||
Draft: publish this section after the resource-control SDK support is released.
|
||||
|
||||
## Resource budgets {#resources}
|
||||
|
||||
For training-data curation, bound the resources used to recompute a view:
|
||||
Bound the resources used to recompute a view:
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
job = view.refresh_async(
|
||||
cpu_millis=8000,
|
||||
memory_bytes=16 * 1024**3,
|
||||
gpu_count=2,
|
||||
total_cpu_millis=8000,
|
||||
total_memory_bytes=16 * 1024**3,
|
||||
total_gpu_count=4,
|
||||
gpu_class="h100",
|
||||
gpu_count=2,
|
||||
)
|
||||
job.wait()
|
||||
```
|
||||
@@ -84,38 +84,45 @@ use lancedb::materialized_view::MaterializedView;
|
||||
async fn refresh(view: &MaterializedView) -> lancedb::Result<()> {
|
||||
let job = view
|
||||
.refresh()
|
||||
.cpu_millis(8000)
|
||||
.memory_bytes(16_u64 << 30)
|
||||
.gpu_count(2)
|
||||
.total_cpu_millis(8000)
|
||||
.total_memory_bytes(16_u64 << 30)
|
||||
.total_gpu_count(4)
|
||||
.gpu_class("h100")
|
||||
.gpu_count(2)
|
||||
.execute_async()
|
||||
.await?;
|
||||
job.wait().await?;
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
```typescript TypeScript icon="js"
|
||||
await view.refresh({
|
||||
totalCpuMillis: 8000,
|
||||
totalMemoryBytes: 16 * 1024 ** 3,
|
||||
totalGpuCount: 4,
|
||||
gpuClass: "h100",
|
||||
gpuCount: 2,
|
||||
});
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
The same options are available on `refresh`, asynchronous Python connections,
|
||||
and the Rust refresh builder (`cpu_millis`, `memory_bytes`, `gpu_count`, and
|
||||
`gpu_class`). CPU is in millicores (8000 means eight cores), memory is bytes,
|
||||
and GPU count is an aggregate concurrent cap. CPU or memory requires all three
|
||||
budget fields. Use zero GPUs for a CPU-only view, or specify a GPU cap alone.
|
||||
CPU is in millicores (8000 means eight cores), memory is in bytes, and
|
||||
`total_gpu_count` is the aggregate concurrent GPU cap. `gpu_count` allocates
|
||||
that many devices together to each worker; the total cap must fit at least
|
||||
one worker. Use `total_gpu_count=0` for a CPU-only view.
|
||||
|
||||
The cap covers the refresh execution and its Function processes together.
|
||||
It does not allocate that budget separately to each Function. A GPU class
|
||||
selects placement for this execution; discover configured classes with
|
||||
`db.list_gpu_classes()`. A cap does not promise more parallelism: current MV
|
||||
refreshes use at most one GPU. Omitted settings keep existing defaults.
|
||||
Each omitted setting inherits the view's creation setting, then the Function
|
||||
setting. Total budgets across distinct pinned Function versions are summed;
|
||||
the per-worker count uses their largest default. Remaining total budgets use
|
||||
deployment defaults. An unresolved GPU class is equivalent to `"any"`, and
|
||||
an explicit `gpu_class="any"` overrides a concrete creation or Function class.
|
||||
Discover configured classes with `db.list_gpu_classes()`.
|
||||
|
||||
These controls require an Enterprise server with an isolated backend that can
|
||||
enforce them; Embedded and unsupported execution backends reject them. Earlier
|
||||
Enterprise servers reject the new SQL options. See the
|
||||
These controls require LanceDB Enterprise with an isolated backend that can
|
||||
enforce them; Embedded and unsupported execution backends reject them. See the
|
||||
[SQL resource options](/sql/dml/refresh-materialized-view#resources).
|
||||
|
||||
TypeScript does not expose these options yet; SDK parity is tracked in
|
||||
[issue #4903](https://github.com/lancedb/lancedb/issues/4903).
|
||||
|
||||
*/}
|
||||
|
||||
## Automatic refresh {#auto-refresh}
|
||||
|
||||
@@ -635,7 +635,9 @@ dependencies are part of its definition:
|
||||
| `conda`, `conda_channels` | conda packages instead of pip; channels in priority order |
|
||||
| `env` | environment variables |
|
||||
| `python_version` | Python major/minor for the execution environment, defaulting to yours |
|
||||
| `gpu` | whether every execution requires a GPU |
|
||||
| `gpu` | Enable GPU execution with `True` (Python) or `true` (SQL); defaults to CPU execution |
|
||||
| `gpu_class` | Operator-configured GPU class, such as `h100`; requires GPU execution |
|
||||
| `gpu_count` | GPUs allocated together per Function worker; positive integer, defaults to one; requires GPU execution |
|
||||
|
||||
<CodeGroup>
|
||||
```python Python icon="python"
|
||||
|
||||
@@ -63,8 +63,9 @@ version is unaffected.
|
||||
| `apt` | OS packages to install in the worker environment |
|
||||
| `image` | a specific container image to run the worker in, such as `'host/repo@sha256:...'` |
|
||||
| `python_version` | worker Python version; `3.12` when omitted, whatever Python you send the statement from |
|
||||
| `gpu` | `'true'` when every execution needs a GPU |
|
||||
| `gpu_class` | which configured GPU class to run on, when `gpu = 'true'` |
|
||||
| `gpu` | Enable GPU execution with `True` (Python) or `true` (SQL); defaults to CPU execution |
|
||||
| `gpu_class` | Operator-configured GPU class, such as `h100`; requires GPU execution |
|
||||
| `gpu_count` | GPUs allocated together per Function worker; positive integer, defaults to one; requires GPU execution |
|
||||
| `result_stability` | `'input_and_context'` or `'per_call'` |
|
||||
| `batch_size` | maximum rows per Function call |
|
||||
| `row_timeout_seconds` | per-row (or per-batch, for a vectorized Function) execution timeout |
|
||||
@@ -76,7 +77,7 @@ version is unaffected.
|
||||
| `LANGUAGE` other than `python` | refused |
|
||||
| `pip` and `conda` together | refused (pick one) |
|
||||
| `conda_channels` without `conda` | refused |
|
||||
| `gpu` set to anything but `'true'` | refused |
|
||||
| An invalid GPU class, zero GPU count, or a count above the configured class limit | refused; use a configured `gpu_class` and a positive `gpu_count` |
|
||||
| An empty body | refused |
|
||||
| Any other option | refused, and the message lists what is supported |
|
||||
|
||||
|
||||
@@ -155,3 +155,23 @@ same underlying job as dropping any table, `drop_table` or `drop_object`.
|
||||
How a refresh works, in LanceDB Enterprise.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
|
||||
### Resource settings
|
||||
|
||||
Creation accepts `total_cpu_millis`, `total_memory_bytes`, and `total_gpu_count`
|
||||
as execution-wide defaults, plus `gpu_class` and positive `gpu_count` for each
|
||||
worker. Refresh accepts the same names and overrides each supplied field.
|
||||
Unspecified fields inherit creation settings, then Function settings, then
|
||||
deployment defaults. A materialized view sums total budgets across distinct
|
||||
pinned Function versions; per-worker counts use the largest Function default
|
||||
unless overridden.
|
||||
|
||||
```sql
|
||||
CREATE MATERIALIZED VIEW embeddings
|
||||
WITH (gpu_class = 'any', gpu_count = 2, total_gpu_count = 8)
|
||||
AS SELECT embed(text) AS embedding FROM documents;
|
||||
|
||||
REFRESH MATERIALIZED VIEW embeddings
|
||||
WITH (gpu_class = 'h100', gpu_count = 4, total_gpu_count = 8);
|
||||
```
|
||||
|
||||
@@ -52,10 +52,11 @@ to let LanceDB track which outputs need updating.
|
||||
| Option | Meaning |
|
||||
| --- | --- |
|
||||
| `num_workers` | fixed worker count for SQL-expression columns; rejected for registered Function columns |
|
||||
| `cpu_millis` | aggregate CPU ceiling across the refresh's Function workers, in thousandths of a CPU |
|
||||
| `memory_bytes` | aggregate memory ceiling across the refresh's Function workers, in bytes |
|
||||
| `gpu_count` | aggregate GPU budget across the refresh's workers. Function columns only |
|
||||
| `gpu_class` | GPU class name for the refresh's workers. Function columns only |
|
||||
| `total_cpu_millis` | aggregate CPU ceiling across the refresh's Function workers, in thousandths of a CPU |
|
||||
| `total_memory_bytes` | aggregate memory ceiling across the refresh's Function workers, in bytes |
|
||||
| `total_gpu_count` | aggregate GPU budget across the refresh's workers. Function columns only |
|
||||
| `gpu_class` | GPU class name for the refresh's workers; `any` accepts any eligible pool. Function columns only |
|
||||
| `gpu_count` | positive number of GPUs allocated together to each worker. Function columns only |
|
||||
| `batch_size` | maximum rows passed to one Function call; actual calls can be smaller. Function columns only |
|
||||
| `max_executor_processes_per_worker` | cap on executor processes per worker. Function columns only |
|
||||
| `row_timeout_seconds` | deadline for one Function call. Function columns only |
|
||||
@@ -66,14 +67,15 @@ to let LanceDB track which outputs need updating.
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
REFRESH COLUMN embedding ON documents
|
||||
WITH (cpu_millis = 8000, memory_bytes = 17179869184, gpu_count = 2)
|
||||
WITH (total_cpu_millis = 8000, total_memory_bytes = 17179869184, total_gpu_count = 2)
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
The example allows up to 8 CPUs, 16 GiB of memory, and 2 GPUs across the
|
||||
Function workers together. It does not reserve those resources per worker or
|
||||
guarantee a worker count. When setting CPU or memory, provide all three budget
|
||||
fields. A complete CPU-only budget uses `gpu_count = 0`.
|
||||
guarantee a worker count. Set each resource independently; omitted values inherit
|
||||
column `total_*` settings, then Function defaults, then deployment defaults.
|
||||
A CPU-only GPU budget uses `total_gpu_count = 0`.
|
||||
|
||||
Set `error_policy` on the refresh, not on the Function definition. With `skip`,
|
||||
inspect failures with `SHOW ERRORS` or `table.function_errors()` and retry the
|
||||
|
||||
@@ -14,8 +14,8 @@ A LanceDB extension with no DataFusion equivalent.
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
REFRESH MATERIALIZED VIEW <name>
|
||||
[WITH (full = <boolean>, cpu_millis = <integer>, memory_bytes = <integer>,
|
||||
gpu_count = <integer>, gpu_class = '<class>')]
|
||||
[WITH (full = <boolean>, total_cpu_millis = <integer>, total_memory_bytes = <integer>,
|
||||
total_gpu_count = <integer>, gpu_class = '<class>')]
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
@@ -43,20 +43,20 @@ Set budgets for one refresh execution:
|
||||
|
||||
```sql
|
||||
REFRESH MATERIALIZED VIEW curated_training_set WITH (
|
||||
cpu_millis = 8000,
|
||||
memory_bytes = 17179869184,
|
||||
gpu_count = 2,
|
||||
total_cpu_millis = 8000,
|
||||
total_memory_bytes = 17179869184,
|
||||
total_gpu_count = 2,
|
||||
gpu_class = 'h100'
|
||||
);
|
||||
```
|
||||
|
||||
`cpu_millis` is CPU capacity in millicores (1000 = one core), not CPU time.
|
||||
`memory_bytes` caps memory in bytes. `gpu_count` caps concurrent GPUs for the
|
||||
`total_cpu_millis` is CPU capacity in millicores (1000 = one core), not CPU time.
|
||||
`total_memory_bytes` caps memory in bytes. `total_gpu_count` caps concurrent GPUs for the
|
||||
refresh. These are aggregate caps across its SQL execution and Function
|
||||
processes; they are not multiplied by the number of Functions in the query.
|
||||
|
||||
CPU or memory requires all three budget fields. CPU and memory must be positive;
|
||||
`gpu_count = 0` is allowed for CPU-only views. A GPU budget alone is also accepted.
|
||||
Each resource may be overridden independently. CPU and memory must be positive;
|
||||
`total_gpu_count = 0` is allowed for CPU-only views. A GPU budget alone is also accepted.
|
||||
A cap does not reserve all of its GPUs or increase refresh parallelism. Current
|
||||
MV refreshes use at most one GPU, shared by their GPU Function calls.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user