Loading...
Loading...
Optimize Daft UDF performance. Invoke when user needs GPU inference, encounters slow UDFs, or asks about async/batch processing.
npx skill4agent add eventual-inc/daft daft-udf-tuning| Type | Decorator | Use Case |
|---|---|---|
| Stateless | | Simple transforms. Use |
| Stateful | | Expensive init (e.g., loading models). Supports |
| Batch | | Vectorized CPU/GPU ops (NumPy/PyTorch). Faster. |
@daft.func
async def fetch(url: str):
async with aiohttp.ClientSession() as s:
return await s.get(url).text()@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"]))max_concurrencygpus=Nbatch_sizeinto_batches(N)