agentsclimarketplace

Daft udf tuning

Skill Eventual-Inc/Daft/.claude/skills/daft-udf-tuning

Optimize Daft UDF performance. Invoke when user needs GPU inference, encounters slow UDFs, or asks about async/batch processing.From its SKILL.md

Install
npx -y skills add Eventual-Inc/Daft --skill daft-udf-tuning

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.4 KB, as published. Nobody here has run it

Daft UDF Tuning

Optimize User-Defined Functions for performance.

UDF Types

TypeDecoratorUse Case
Stateless@daft.funcSimple transforms. Use async for I/O-bound tasks.
Stateful@daft.clsExpensive init (e.g., loading models). Supports gpus=N.
Batch@daft.func.batchVectorized CPU/GPU ops (NumPy/PyTorch). Faster.

Quick Recipes

1. Async I/O (Web APIs)

@daft.func
async def fetch(url: str):
    async with aiohttp.ClientSession() as s:
        return await s.get(url).text()

2. GPU Batch Inference (PyTorch/Models)

@daft.cls(gpus=1)
class Classifier:
    def __init__(self):
        self.model = load_model().cuda() # Run once per worker

    @daft.method.batch(batch_size=32)
    def predict(self, images):
        return self.model(images.to_pylist())

# Run with concurrency
df.with_column("preds", Classifier(max_concurrency=4).predict(df["img"]))

Tuning Keys

  • max_concurrency: Total parallel UDF instances.
  • gpus=N: GPU request per instance.
  • batch_size: Rows per call. Too small = overhead; too big = OOM.
  • into_batches(N): Pre-slice partitions if memory is tight.

Keep looking

Skills are one crate of 613,373. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.