Enterprise only
Function registration, query execution and column refresh have different
lifecycles. Match your SDK and Enterprise server release before relying on
optional GPU discovery, progress fields or warm-worker reuse. The examples
use the public @function decorator; see
authoring guidance and
Function signatures.
Query-time cold starts
A query that invokes a Python Function can pay for admission, worker placement, image preparation, Python startup, dependency import, model download and model initialization before producing its first row. These are separate kinds of warmth:
Use a class Function to initialize expensive state once per instance and reuse
it across that instance’s rows and batches. Each instance owns its own model copy.
Some Enterprise releases can reuse initialized refresh instances across jobs,
carrying mutable instance state into the next refresh. With live output capture,
a worker adopted by another refresh can reuse its pod, image layers and cached
model files. It starts a fresh Python child and runs initialization again for
that refresh. Loading a large model into CPU or GPU memory can still delay the
first batch. Query-time SQL execution has its own worker and instance lifetimes.
Measure time to first row separately from steady-state batch throughput, and
record server/SDK versions, GPU class, model/dependencies and whether image,
model files and initialized instances were retained. Do not extrapolate a
single warm measurement to an independently submitted query or cold worker.
Latency-sensitive query embeddings
Keep document embeddings in a stored Function column and refresh them during ingestion or backfill. Compute each interactive query vector in an already initialized application model or a separately operated embedding service, then send the numeric vector to LanceDB. For example, with a long-lived SentenceTransformer instance in the application:encoder once at application startup. Use the same model revision,
dimension, pooling and normalization as the stored document embeddings. A
separate service needs its own capacity, authentication and timeout management;
a thin HTTP Function does not make that service’s GPU part of LanceDB’s budget.
SQL Function calls remain useful for batch transformations, exploratory
queries and workloads that can tolerate startup. Precomputing document
embeddings does not remove a query-time model cold start if each search still
calls a remote GPU Function to embed the query string.
GPU placement and budgets
Discover the configured classes with Pythondb.list_gpu_classes(), SQL
SHOW GPU CLASSES, or REST GET /v1/gpu/classes. These require supporting
SDK/server versions and System Usage permission. The response describes the
operator’s configured GPU resource name, optional model and memory per device,
per-worker device ceiling and worker resources. It is configuration, not live
inventory or a guarantee of currently available capacity. Missing metadata is
unknown; a missing per-worker limit leaves that class cap unspecified. The
refresh’s aggregate budget and available worker shapes still apply.
The deployment operator configures available classes and their per-worker
limits. Choose a class supported by your deployment and a model that fits its
worker shape.
On supporting SDK/server releases, choose a returned class and a per-worker
device count when registering a Function with
@function(gpu=True, gpu_class="h100", gpu_count=2).
Use gpu=True, gpu_count=2 to permit any eligible configured class that can
provide two devices together. Omitting gpu_class is equivalent to
gpu_class="any". Set gpu_class="default" to select the default pool
explicitly. gpu_count defaults to one.
Column and materialized view creation, manual refresh, and automatic refresh
use the same per-worker gpu_class and gpu_count settings. Each setting
resolves independently: refresh > column/MV creation > Function annotation.
If no layer specifies a class, any eligible configured class is acceptable.
An explicit gpu_class="any" overrides a concrete class set on the Function
or at creation.
total_gpu_count caps the
worker fleet at four devices. The aggregate budget must fit at least one
worker. Adaptive scaling keeps the per-worker count fixed while adjusting
CPU, memory and worker count. Set the model library’s tensor parallelism
separately.
See allocating multiple GPUs to one Function worker
for class selection and per-worker limits. gpus_per_worker is runtime metadata;
the Function annotation exposes the count through gpu_count.
Inspect the Function environment report
for observed devices and libraries. Configured memory is per device; it does
not establish that one model can allocate the sum of every device’s memory.
Set row_timeout_seconds on the Function definition or the refresh for GPU
work whose longest call can exceed the per-call default. Current builds use
300 seconds for both CPU and GPU Functions. Enterprise 1.13.0 through 1.14.1,
and 1.15.0 builds before the shared default was restored, reject a GPU refresh
unless the definition or the refresh request sets a positive value;
registration still succeeds. A refresh value overrides the definition. Choose
the value from the longest observed call; 600 seconds is one working example,
not a universal recommendation.
Refresh admission and concurrency
Submission creates a job, then source preparation, dispatcher admission and worker startup happen separately. Poor table layout can require compaction before a refresh;WHERE does not promise to limit that prerequisite to only
the selected rows. An earlier column refresh can also block a later one.
Dispatcher concurrency, cluster worker capacity and automatic-refresh admission
are deployment-level limits. They are separate from a refresh’s aggregate
total_cpu_millis, total_memory_bytes, total_gpu_count budget and a Function’s call-level
max_concurrency. Ask your deployment operator about effective limits; defaults
do not guarantee available capacity or a universal supervisor cap. GPU quotas,
placement constraints and model startup can add waits after admission.
Distinguish waiting from execution
Use the Console’s job detail andSHOW JOBS. On matching
SDK/server versions, job.progress() exposes optional phase, queue_reason
and row/worker counters; see the detailed
refresh progress reference. Older deployments
can report only lifecycle running while work has not begun.
Missing counters and timestamps are unknown.
creation_ms is registry
creation time, while supervisor_started_at_millis is execution start. In a
finished job’s summary, their difference includes admission/queue time, not
only Python startup. DESCRIBE JOB includes live state and reported progress;
its timing measurements come from the retained profile when available and do
not predict queue completion. Sampled worker readiness does not mean a model
has initialized.
Request cancellation with job.cancel() or
CANCEL JOB, then observe the terminal state. Cancellation
also applies while waiting; it does not roll back outputs already committed.
A timeout in the client does not cancel the server job. Avoid cancelling and
resubmitting merely to get a new ID; the replacement encounters the same
admission constraints.
Read live refresh output
CallPOST /v1/jobs/logs with the computed column refresh’s job ID. The
same handle follows the refresh through retries and supervisor handovers.
For example, use an authenticated HTTP session for the target database.
attempt_job_id, worker_id, or split_id in the request to filter entries.
The first physical attempt can be selected by setting attempt_job_id to the
original job ID. Sequence bounds and loss counters cover the full tail even when
you filter entries.
The tail combines Python stdout and stderr from import and initialization, apply,
and close, including logging handlers using those streams. Raw file-descriptor
writes and background output stay private. A collector retains up to 64 KiB of
serialized output and attribution per refresh. Loss fields report queue drops,
omissions, evictions, and gaps of unknown size. coverage is pending while a
log-capable supervisor is waiting for the adapter handshake, supported once
capture is confirmed, and partial when a fleet or lineage has gaps in capture.
unsupported indicates that capture has not been observed. expired appears
24 hours after logical completion while the job record is still available. A
storage error returns HTTP 503 and the poll can be retried.
Every current reader of the target table can read this output, including readers
who did not submit the job. The job author has the same requirements. Each poll
checks database and namespace USAGE and table SELECT on the original target
table. Revoking access or dropping or replacing the table takes effect on the
next poll. An unknown job, a different database, or a caller without access
receives the same 404 response.
A Function may print data it read outside the target table, and any target-table
reader can see that output. Secret redaction covers only known bound values.
Print only information that all of those readers may see. Display logs as plain
text.
Profile a refresh worker
On supporting Enterprise releases, operators with System Operate permission can capture a profile from one initialized Python session of a running Function refresh job. The API requires the job ID, worker ID and session slot. Query-time SQL and materialized-view job workers are not supported by these endpoints. Capture requests are checked on a 10-second cadence, so they can remainpending before sampling starts.
In the Console, open the Function refresh job’s Overview and find
Function worker profiling. Select the worker, profile kind, duration and
Python session slot (0 is the first session), then choose Capture profile.
The panel follows capture status and displays any failure reported by the
server. Completed CPU captures show a per-thread flame graph and hottest-frame
table; GPU captures show CUDA kernel and transfer timings with an interactive
timeline; memory captures show retained allocations and their tracebacks. Choose
Download profile JSON for the full artifact. Copy the profile ID to retrieve
it later with Existing profile ID and Load profile, including after the
job finishes, while the artifact remains available.
- Submit
POST /v1/jobs/profile/capturewith the target and a duration from 1 to 30 seconds (1 to 5 seconds for GPU). A successful request returns HTTP202and aprofile_id. - Poll
POST /v1/jobs/profile/statuswithjob_idandprofile_id. Status ispending,capturing,completeorfailed; a failure includeserror. - When complete, use the same IDs with
POST /v1/jobs/profile/artifactto download the JSON artifact identified byartifact_id.
kind: "cpu" for speedscope JSON containing CPU-weighted Python stack
samples, or kind: "memory" for lancedb.tracemalloc.v1 allocation metadata.
Memory profiles describe Python allocations made during capture and retained
at its end. Native frames and native allocations are excluded. Existing
Function-owned tracemalloc tracing must be stopped before a memory capture.
Use kind: "gpu" for a lancedb.cuda.v1 Chrome trace of CUDA kernels,
transfers and available CUDA host API activities in the selected Python process.
The Function must already have imported PyTorch and initialized CUDA, and its
PyTorch installation must support CUPTI activities. Unsupported sessions and
captures without GPU activities fail explicitly. GPU capture lasts 1–5 seconds;
shape, Python stack and allocation tracing are disabled to reduce overhead.
GPU traces do not provide Python operator attribution, GPU allocation stacks or
hardware counters. Do not run another CUDA profiler in the same session during
a capture. CUDA tracing can increase runtime and memory consumption; validate
its overhead with your workload before using it on latency-sensitive jobs.
The preview sums retained kernel and transfer durations, which can overlap
across streams and are not wall time or GPU utilization. It bounds the trace to
4,096 activities and 128 lanes, marking omitted activities as truncated. A raw
trace exceeding 16 MiB fails instead of being returned. The JSON download is
compatible with Chrome trace viewers; the Console embeds a private timeline.
See worker deployment modes. A blocked
Python interpreter, unavailable session or worker, or exceeded capture budget
can cause a capture to fail. Only one capture per job and worker can be active,
and artifacts are capped at 2 MiB. Captures are bound to the worker assignment
and execution epoch; release or execution changes can invalidate an unfinished
capture.
Completed artifacts survive worker termination. Downloads are available for
at most one hour and the eight most recent captures per job, until normal job
scratch reclamation or archival. Save needed artifacts before that retention
ends. Capture, status and download all require System Operate permission.