skills/latchbio-integration/references/resource-configuration.md
This reference targets latch==2.76.8. Resource shapes are operational
configuration and can change independently of examples. Inspect the installed
SDK before making cost or capacity guarantees.
custom_task for CPU-only shapes not represented by a named decorator.custom_task does not accept gpu or
gpu_type arguments.from latch.resources.tasks import large_task, medium_task, small_task
@small_task
def parse_manifest():
...
@medium_task
def align_reads():
...
@large_task
def assemble_genome():
...
SDK 2.76.8 configures these scheduler requests:
| Decorator | CPU | RAM | Ephemeral storage |
|---|---|---|---|
small_task | 2 | 4 GiB | 100 GiB |
medium_task | 30 | 100 GiB | 1500 GiB |
large_task | 90 | 170 GiB | 4500 GiB |
The public guide may display nominal instance capacities rather than the schedulable requests encoded in the package. The installed package determines what registration serializes.
Generic GPU shapes:
from latch.resources.tasks import large_gpu_task, small_gpu_task
| Decorator | CPU | RAM | GPU |
|---|---|---|---|
small_gpu_task | 7 | 30 GiB | 1× T4-class |
large_gpu_task | 63 | 245 GiB | 1× A10G-class |
V100 shapes:
from latch.resources.tasks import (
v100_x1_task,
v100_x4_task,
v100_x8_task,
)
L40S shapes:
from latch.resources.tasks import (
g6e_xlarge_task,
g6e_2xlarge_task,
g6e_4xlarge_task,
g6e_8xlarge_task,
g6e_12xlarge_task,
g6e_16xlarge_task,
g6e_24xlarge_task,
g6e_48xlarge_task,
)
Current L40S scheduler requests and limits:
| Decorator | Request CPU | Request RAM | Limit CPU | Limit RAM | GPUs |
|---|---|---|---|---|---|
g6e_xlarge_task | 2 | 28 GiB | 4 | 32 GiB | 1 |
g6e_2xlarge_task | 6 | 57 GiB | 8 | 64 GiB | 1 |
g6e_4xlarge_task | 14 | 115 GiB | 16 | 128 GiB | 1 |
g6e_8xlarge_task | 30 | 230 GiB | 32 | 256 GiB | 1 |
g6e_12xlarge_task | 46 | 345 GiB | 48 | 384 GiB | 4 |
g6e_16xlarge_task | 62 | 460 GiB | 64 | 512 GiB | 1 |
g6e_24xlarge_task | 94 | 691 GiB | 96 | 768 GiB | 4 |
g6e_48xlarge_task | 190 | 1382 GiB | 192 | 1536 GiB | 8 |
GPU availability, quotas, and platform mapping can change. Confirm in the current docs or with Latch support before promising a specific model to users.
Exact stable signature:
custom_task(
cpu,
memory,
*,
storage_gib=500,
timeout=0,
**task_options,
)
Example:
from datetime import timedelta
from latch import custom_task
@custom_task(
cpu=12,
memory=48,
storage_gib=750,
timeout=timedelta(hours=6),
retries=1,
)
def call_variants():
...
In SDK 2.76.8, custom_task accepts up to 126 CPU cores, 975 GiB RAM, and
4949 GiB ephemeral storage. Not every arbitrary combination fits a schedulable
node group; the decorator selects the smallest configured group that satisfies
all three requests.
custom_memory_optimized_task is deprecated. Use custom_task.
Each cpu, memory, or storage_gib argument may be a function of task
inputs. The resource function's annotated parameters must exist in the task
with exactly matching annotations.
from latch import custom_task
from latch.types import LatchFile
def allocate_cpu(files: list[LatchFile]) -> int:
return min(32, max(2, len(files) * 2))
def allocate_storage(files: list[LatchFile]) -> int:
sizes = [file.size() for file in files]
if any(size is None for size in sizes):
raise ValueError("unable to determine every input size")
total_bytes = sum(int(size) for size in sizes)
estimated_gib = total_bytes / (1024**3)
return max(100, int(estimated_gib * 2) + 1)
@custom_task(
cpu=allocate_cpu,
memory=64,
storage_gib=allocate_storage,
)
def merge_files(files: list[LatchFile]) -> LatchFile:
...
Dynamic functions execute at runtime before the task launches.
Guardrails:
Named decorators and non-dynamic custom_task accept Flyte task options:
@medium_task(
cache=True,
cache_version="aligner-2.1-reference-v4",
retries=2,
timeout=7200,
)
def align_reads():
...
cache_version.datetime.timedelta.Ephemeral task storage is deleted with the task environment. Use it for:
Return a LatchFile or LatchDir, or upload through LPath, for persistent
outputs. Never assume /tmp or /root survives task completion.
Estimate storage from peak simultaneous intermediates, not final output size:
requested storage
>= staged inputs
+ decompressed expansion
+ peak tool intermediates
+ final outputs
+ safety margin
storage_gib based on peak use.