Litdata 标志

Litdata

组织
Lightning-AI
litdata

Expert use of the LitData library and work on its codebase. Use when writing or reviewing code that calls litdata (StreamingDataset, StreamingDataLoader, StreamingRawDataset, optimize, map, CombinedStreamingDataset, ParallelStreamingDataset, TokensLoader, serializers, typed media wrappers Text/Audio/Video/Image/Jpeg/File/Tensor/Graph/…, list_media_folder, litdata_collate, train_test_split, complete_dataset, merge_datasets, index_parquet_dataset, index_hf_dataset), answering how-to questions, choosing raw vs optimize vs parquet/HF/MDS, keyed lookup (`key_fn`, `build_keys_index`, `dataset_update`, `get_by_key`), elastic mid-epoch resume, tuning cache/prefetch/shuffle/seed, resolving paths (s3/gs/r2/azure/hf/local:/teamspace via resolver.py), documenting or debugging optimize/map I/O (shared queue, async Downloader download/upload, LITDATA_OPTIMIZE_*), FsProvider vs Downloader, FUSE s3_connections/s3_folders, multi-node DATA_OPTIMIZER_* / num_nodes jobs, POSIX-fast mmap, litsim simulator, or when navigating/editing src/litdata, tests, CI, examples/modality, or debugging streaming / optimize / map. Also use for enable_tracer / Litracer / Perfetto, and multi-worker s3:// FileNotFoundError or obstore-after-fork / Studio R2 data_connection_id Session TypeError.

概览

发布者Lightning-AI
代码仓库litData
技能名称litdata
星标数
616
复刻数
110
附带文件
16
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 16 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 Lightning-AI 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Litdata AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/Lightning-AI/litData/tree/main/.claude/skills/litdata
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Lightning-AI/litData.git /tmp/litData
mkdir -p .claude/skills
cp -r /tmp/litData/.claude/skills/litdata .claude/skills/litdata
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Litdata,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Litdata。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Litdata 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

LitData

LitData (import litdata) preprocesses and streams datasets for PyTorch training:

  • Write (optimize / map) → chunked chunk-*.bin + index.json → src/litdata/processing/
  • Read (StreamingDataset + StreamingDataLoader) → cache → decode → batch → src/litdata/streaming/
  • Raw (StreamingRawDataset) → stream original files without optimize → src/litdata/raw/

To use the library expertly: always load reference/using-litdata.md first. Narrative source: repo README.md.

Install this skill

From any project (Cursor, Claude Code, and other agents supported by the skills CLI):

bash
npx skills add Lightning-AI/litData

Useful options: -g (user-global), -a cursor (Cursor only), -y (non-interactive). In this repo the skill already lives at .claude/skills/litdata/.

Expert usage (load using-litdata.md)

Before writing examples or answering how-tos, read the cookbook. Highlights:

TopicRemember
Raw filesStreamingRawDataset + torch DataLoader — #stream-raw / §10. Prefer cloud URL / connection path over FUSE. Defaults: max_concurrent_downloads=None (adaptive Stage 1), max_prefetch=16 (worker-aware ~64 aggregate), hedge_delay=0, download_timeout=120 (batch-level), range_parallel_threshold=0. Explicit int concurrency = exact permits.
Images / mediaAlways wrap so a caption is not a path: Text / Image / Audio / Video / File / … (types.py). Class folders: list_media_folder(root, kind=…). Recipes: examples/modality/. README #modality (#media-types). Bare PIL.Image / fromarray → huge PIL RAW. litdata_collate only special-cases graphs — Audio/Video need a custom collate_fn.
Train streamOptimized: StreamingDataLoader + shuffle=True, drop_last=True, seed=…
Optimizeif __name__ == "__main__"; exactly one of chunk_bytes | chunk_size. Default 64MB; multi‑MB samples → consider 256–512MB. Shuffle the sample list before optimize() when source order matters — README #faq-chunk-shuffle
Ordered dataChunk/item shuffle ≠ file-level shuffle. Shuffle before optimize, or use StreamingRawDataset + DataLoader(shuffle=True). LitData does distributed + within-chunk bucket sampling automatically
CachePeak disk ≈ num_workers × max_pre_download × chunk_size; default max_cache_size=None (75% of free disk, leave ≥50GB). "100G" or 0.90 of free.
POSIX-fastLocal/Vast/NFS: mmap in place, no cache copy. WindowShuffle only on parallel FS (or LITDATA_POSIX_FAST=1). Cap workers / skip WILLNEED from MemAvailable. LITDATA_POSIX_FAST=0 disables.
PathsStudio /teamspace/s3_connections & co are FUSE (convenience only — slow, can crash under load). LitData resolves them and talks directly to S3/GCS/R2. Never read the mount by hand. reference/resolver.md + reference/data-movement.md
Optimize I/ODefault keep_data_ordered=False: per-node shared queue; download/upload/remove are node-level threads. Remote I/O uses the streaming Downloader (adownload_file / aupload_file). FsProvider is the fallback / index path. Tune LITDATA_OPTIMIZE_* / LITDATA_PREFETCH_BYTES. Load reference/data-movement.md.
Multi-nodenum_nodes= = Lightning Studio job (_execute), not torchrun/SLURM. Shard by DATA_OPTIMIZER_*; all ranks upload chunks; last node merges {node}-index.json → index.json. Load reference/multi-node.md.
ThroughputRough ImageNet Studio order-of-magnitude (not guarantees): FUSE ~600/s · Raw (right tuning) ~6–7k/s · Optimized 64MB chunks ~11k/s — using-litdata.md FAQ. Raw benches: medians + provenance SHAs; never cite short-window n=1 against Stage 0 medians.
Tracingfrom litdata.debugger import enable_tracer then enable_tracer(level="chunk") (or categories=["download","read","delete"]). Convert with Lightning-AI/litracer: litracer --quiet --validate -o trace.json.gz litdata_debug.log. One line per event; crashes go to stderr + ph: I. Full spec: reference/debugging.md.
S3 workersindex.json is boto3 (no parent tokio). Workers lazy-init obstore; boto3 fallback if parent already started it. Do not pass data_connection_id / endpoint_url into boto3.Session — build obstore from S3Client/R2Client. FileNotFoundError after 120s with num_workers>0 only → debugging.md failure modes.
Keyed lookupoptimize(..., key_fn=...) writes keys/. Read ds["id"] / get_by_key. Patch locally with dataset_update. Needs polars. keyed-lookup.md.
Parquet / HFOne-liner: StreamingDataset("hf://datasets/org/name/data") (auto-index + ParquetLoader). Index persists at {cache}/hf-index/<hash>/index.json (no re-scan). Default prefetches whole parquet then local to_pylist(). Do not default range_read=True (lost to HF on Hub). spawn with workers. Token: HF_TOKEN. using-litdata.md §10.

Reference map

TaskRead
Use the library (raw, optimize/stream, modality, parquet/HF, serializers)reference/using-litdata.md
Paths / URLs / Studio mounts / Dir / time templatesreference/resolver.md (+ README #resolve-paths)
Downloaders / uploaders / removers / FUSE→cloud / optimize I/Oreference/data-movement.md (+ processing.md)
Multi-node optimize/map (num_nodes, DATA_OPTIMIZER_*, index merge)reference/multi-node.md (+ processing.md)
Read path, shuffle math, item loaders, Combined/Parallelreference/streaming.md
Cache / BinaryWriter / BinaryReader / index.json / FsProvider / samplerreference/storage-format.md
Cache / prefetch / eviction / shared-chunk deletionreference/cache-and-chunk-lifecycle.md
Env vars (async prefetch, cache, debug, DATA_OPTIMIZER_*, Studio)reference/env-vars.md
Fair streaming benchmarks (benchmarks/ suite)reference/benchmarking.md
Offline streaming what-if (litsim)repo simulator/README.md
Raw adaptive concurrency / look-ahead stages (clients own rate)repo benchmarks/ADAPTIVE_CONCURRENCY.md
Lightning Studio env, credentials, free-threadingreference/lightning-studio.md
Write path orchestration; raw internals; pointers to I/O + multi-nodereference/processing.md
Dev env, PR/CI stylereference/contributing.md
Tests & fixturesreference/testing.md
Tracing (enable_tracer, Litracer, Perfetto), breakpoints, env knobsreference/debugging.md
Keyed lookup / dataset_update / key_fnreference/keyed-lookup.md

Public API (src/litdata/__init__.py)

SymbolPurpose
StreamingDataset / StreamingDataLoaderOptimized stream + resumable loader
CombinedStreamingDataset / ParallelStreamingDatasetMix or zip streams
StreamingRawDatasetRaw file stream
TokensLoaderToken windows for LLMs
optimize / map / merge_datasets / walk / complete_datasetWrite / transform / merge / finish index
list_media_folder / iter_webdataset_tarClass-folder / WebDataset ingest lists
Audio Video Image Jpeg JpegArray Pil Tiff File Mesh Pdf Nifti Tensor Text GraphTyped media leaves for optimize
litdata_collateLoader default; PyG Batch only for graphs
dataset_update / build_keys_indexKeyed in-place patch / backfill sidecar
train_test_splitSplit by chunk ROIs
index_parquet_dataset / index_hf_dataset / optimize_hfIndex parquet / convert Hub parquet → chunks
breakpointMultiprocessing-safe pdb
enable_tracer (litdata.debugger)Pipeline log → Litracer / Perfetto

Defined under streaming/, processing/, raw/, utilities/ — see cookbook §6–9 for constructor args.

Package map

  • streaming/ — read · processing/ — write · raw/ — raw stream · types.py — media wrappers · cli/ — litdata cache path|clear
  • utilities/ — env, encryption, subsample, split, parquet, HF
  • constants.py — optional-dep flags, env knobs, default chunk 64 MB
  • Registries: downloaders, fs providers, serializers, compressors; resolver.py → Dir

Shared concepts

  • Chunk: [num_items][offsets][data]; index.json holds chunks + config (data_format, item_loader, …) — storage-format.md.
  • Item loaders own layout + intervals (PyTreeLoader, TokensLoader, ParquetLoader).
  • Training downloads = Downloader. Optimize remote I/O prefers the same Downloader (adownload_file / aupload_file); FsProvider remains for index merge and fallback. See data-movement.md. Sampler ChunkedIndex is read-path; CacheBatchSampler is CacheDataLoader only.
  • Ranks from env (_DistributedEnv / DATA_OPTIMIZER_*), not a custom network.
  • Shuffle deterministic from seed+epoch+chunk → resumable (shuffle.py, not sampler.py). Local POSIX-fast keeps FullShuffle unless the mount is Vast/NFS/Lustre/GPFS (or LITDATA_POSIX_FAST=1 → WindowShuffle).
  • Design: one less thing to remember; pure PyTorch; backward compatible; test-driven.

Traps (do not “fix” by guessing)

  • FileNotFoundError / ChunkWaitTimeoutError after ~120s on chunks with num_workers>0 is usually prefetch-thread death or wait timeout — not a missing object. Check stderr + tracer crash.
  • mode="append" vs use_checkpoint=True: append continues chunk indices; checkpoint resumes input slices. Combining them is unsafe; checkpoint filenames / done_till_index are known-fragile (writer.save_checkpoint vs data_processor load).
  • Azure/HF resolve for read; optimize write providers are s3/gs/r2 only (_SUPPORTED_PROVIDERS).
  • dataset_update: local dirs only; ds[int] is positional.
  • Empty Tensor() is not tokens. Only 1-D Tensor(array=…) (or path= / bytes= + dtype=) uses the TokensLoader layout. Empty Text() / JpegArray() fail on write.
  • Bare .txt / .npy / .bin path strings pickle the path. Wrap with Text / File / load the array. Bare *.jpg / *.png / *.wav paths are claimed as media.
  • litdata_collate only batches graphs. A dict with AudioDecoder / video decoder + a stackable field needs a custom collate_fn (see examples/modality/audio.py).

Quick commands

bash
make setup
pre-commit run --all-files
mypy
pytest tests/path/test_x.py::test_name -v --capture=no
litdata cache path
litdata cache clear

Examples: examples/ (modality recipes: examples/modality/). Version: src/litdata/__about__.py.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Litdata AI 技能有什么作用?

Expert use of the LitData library and work on its codebase. Use when writing or reviewing code that calls litdata (StreamingDataset, StreamingDataLoader, StreamingRawDataset, optimize, map, CombinedStreamingDataset, ParallelStreamingDataset, TokensLoader, serializers, typed media wrappers Text/Audio/Video/Image/Jpeg/File/Tensor/Graph/…, list_media_folder, litdata_collate, train_test_split, complete_dataset, merge_datasets, index_parquet_dataset, index_hf_dataset), answering how-to questions, choosing raw vs optimize vs parquet/HF/MDS, keyed lookup (`key_fn`, `build_keys_index`, `dataset_upd...

为什么在 TypingMind 中使用 Litdata?

因为您只需安装一次,就能搭配任何模型使用。Litdata 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Litdata?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/Lightning-AI/litData/tree/main/.claude/skills/litdata。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Litdata?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Litdata 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Litdata 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Litdata AI 技能免费吗?

是的。Lightning-AI 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇