Agent Skills › Eventual-Inc/Daft

Eventual-Inc/Daft

GitHub

指导将 Daft 工作流扩展至分布式 Ray 集群,通过 Shuffle(repartition)处理轻量数据或 Streaming(into_batches)处理重负载数据,优化性能并避免 OOM。

3 skills 5,603

Install All Skills

npx skills add Eventual-Inc/Daft --all -g -y
More Options

List skills in collection

npx skills add Eventual-Inc/Daft --list

Skills in Collection (3)

指导将 Daft 工作流扩展至分布式 Ray 集群,通过 Shuffle(repartition)处理轻量数据或 Streaming(into_batches)处理重负载数据,优化性能并避免 OOM。
优化 Daft 工作流性能 处理大规模数据任务 需要将单节点流程扩展至分布式环境
.claude/skills/daft-distributed-scaling/SKILL.md
npx skills add Eventual-Inc/Daft --skill daft-distributed-scaling -g -y
SKILL.md
Frontmatter
{
    "name": "daft-distributed-scaling",
    "description": "Scale Daft workflows to distributed Ray clusters. Invoke when optimizing performance or handling large data."
}

Daft Distributed Scaling

Scale single-node workflows to distributed execution.

Core Strategies

Strategy API Use Case Pros/Cons
Shuffle repartition(N) Light data (e.g. file paths), Joins Global balance. High memory usage (materializes data).
Streaming into_batches(N) Heavy data (images, tensors) Low memory (streaming). High scheduling overhead if batches too small.

Quick Recipes

1. Light Data: Repartitioning

Best for distributing file paths before heavy reads.

# Create enough partitions to saturate workers
df = daft.read_parquet("s3://metadata").repartition(100)
df = df.with_column("data", read_heavy_data(df["path"]))

2. Heavy Data: Streaming Batches

Best for processing large partitions without OOM.

# Stream 1GB partition in 64-row chunks to control memory
df = df.read_parquet("heavy_data").into_batches(64)
df = df.with_column("embed", model.predict(df["img"]))

Advanced Tuning

Target: Keep all actors busy without OOM or scheduling bottlenecks.

Formula 1: Repartitioning (Light Data / Paths)

Calculate the Max Partition Count to ensure each task has enough data to feed local actors.

  1. Min Rows Per Partition = Batch Size * (Total Concurrency / Nodes)
  2. Max Partitions = Total Rows / Min Rows Per Partition

Example:

  • 1M rows, 4 nodes, 16 total concurrency, Batch Size 64.
  • Min Rows: 64 * (16/4) = 256.
  • Max Partitions: 1,000,000 / 256 ≈ 3906.
  • Recommendation: Use ~1000 partitions to run multiple batches per task.
df = df.repartition(1000) # Balanced fan-out

Formula 2: Streaming (Heavy Data / Images)

Avoid creating tiny partitions. Use into_batches to stream data within larger partitions.

Strategy: Keep partitions large (e.g. 1GB+), use into_batches(Batch Size) to control memory.

# Stream batches to control memory usage per actor
df = df.into_batches(64).with_column("preds", model(max_concurrency=16).predict(df["img"]))
用于导航Daft文档,回答关于API、概念或示例的通用问题,并支持搜索文档内容。
用户询问Daft API用法 用户想了解Daft核心概念 用户需要查找代码示例 用户希望搜索文档内容
.claude/skills/daft-docs-navigation/SKILL.md
npx skills add Eventual-Inc/Daft --skill daft-docs-navigation -g -y
SKILL.md
Frontmatter
{
    "name": "daft-docs-navigation",
    "description": "Navigate Daft documentation. Invoke when user asks general questions about APIs, concepts, or examples, or wants to search the docs."
}

Daft Docs Navigation

Navigate Daft's documentation for APIs, concepts, and examples.

Documentation Structure

  1. Live Site: https://docs.daft.ai (Primary source, searchable).
  2. Source Repo: docs/ directory in the repository.
    • If docs/ is missing or empty, clone the repo: git clone https://github.com/Eventual-Inc/Daft.git

Key Locations in docs/

  • API Reference: api/ (e.g., api/io.md for reading/writing).
  • Optimization: optimization/ (e.g., optimization/partitioning.md).
  • Distributed: distributed/ (e.g., distributed/ray.md).
  • UDFs: custom-code/ (e.g., func.md, cls.md).
  • Connectors: connectors/ (e.g., S3, Lance).
  • Table of Contents: docs/SUMMARY.md.

Usage

Search for API Usage:

grep_search(pattern='from_glob', path='docs/')

Browse Topics:

read(file_path='docs/SUMMARY.md')
优化 Daft UDF 性能。适用于 GPU 推理、处理慢速 UDF 或询问异步/批处理场景。支持无状态、有状态及批量 UDF,提供并发、GPU 分配及分批调优策略。
用户需要 GPU 推理 遇到 UDF 执行缓慢 询问异步或批处理方法
.claude/skills/daft-udf-tuning/SKILL.md
npx skills add Eventual-Inc/Daft --skill daft-udf-tuning -g -y
SKILL.md
Frontmatter
{
    "name": "daft-udf-tuning",
    "description": "Optimize Daft UDF performance. Invoke when user needs GPU inference, encounters slow UDFs, or asks about async\/batch processing."
}

Daft UDF Tuning

Optimize User-Defined Functions for performance.

UDF Types

Type Decorator Use Case
Stateless @daft.func Simple transforms. Use async for I/O-bound tasks.
Stateful @daft.cls Expensive init (e.g., loading models). Supports gpus=N.
Batch @daft.func.batch Vectorized 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.

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-08 19:14
浙ICP备14020137号-1 $Гость$