read-datasets
Routes Petastorm dataset-reading workflows, including plain Python iteration, TensorFlow and PyTorch adapters, Spark RDD reads, row-group selection, NGrams, and throughput benchmarking.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- read-datasets
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Routes Petastorm dataset-reading workflows, including plain Python iteration, TensorFlow and PyTorch adapters, Spark RDD reads, row-group selection, NGrams, and throughput benchmarking.
- disable-model-invocation
- true
02 资源文件 8
- 参考文档references/api-reference.md5.2 KB
- 参考文档references/cli-reference.md1.6 KB
- 参考文档references/troubleshooting.md2.9 KB
- 参考文档references/workflows.md4.2 KB
- 脚本scripts/smoke_read_minimal_dataset.py3.3 KB
- 脚本scripts/smoke_read_plain_parquet.py2.2 KB
- 脚本scripts/smoke_read_tensorflow.py4.6 KB
- 脚本scripts/smoke_read_torch.py3.8 KB
03 SKILL.md 正文
Read Datasets
Use this route when the user wants to open an existing Petastorm dataset or plain Parquet store and read samples back in Python, TensorFlow, PyTorch, or Spark. This route also owns predicates, sharding, row-group selectors, NGrams, shuffling, caching, and throughput measurement.
Typical triggers
- "How do I read this Petastorm dataset?"
- "How do I use
make_readerormake_batch_reader?" - "How do I select row groups or filter rows?"
- "How do I get TensorFlow tensors or a PyTorch DataLoader?"
- "How do I benchmark reader throughput?"
What belongs here
make_readermake_batch_readerReader- row predicates and selectors
- sharding and epoch control
NGramWeightedSamplingReadertf_tensorsmake_petastorm_datasetDataLoader,BatchedDataLoader, andInMemBatchedDataLoaderdataset_as_rddpetastorm-throughput.py- cache and cleanup behavior for reads
What does not belong here
- dataset writing and schema construction
- metadata repair
- copy and filter workflows
- Spark DataFrame conversion into cached datasets
Use sub-skills/create-datasets/ for those tasks.
Use sub-skills/spark-converter/ when the starting point is a Spark DataFrame cache.
Read this first
references/workflows.mdfor end-to-end read recipesreferences/api-reference.mdfor verified signatures and semanticsreferences/cli-reference.mdfor the throughput CLIreferences/troubleshooting.mdfor import-order, metadata, and adapter failuresscripts/smoke_read_minimal_dataset.pyfor a tiny read-back smoke testscripts/smoke_read_plain_parquet.pyfor the plain Parquet batch-reader pathscripts/smoke_read_tensorflow.pywhen TensorFlow support needs a quick checkscripts/smoke_read_torch.pywhen PyTorch support needs a quick check
How to choose a reading path
- Petastorm dataset or plain Parquet?
- Use
make_readerfor Petastorm datasets. - Use
make_batch_readerfor plain Parquet stores or when batch output is acceptable.
- Use
- Need row-level logic?
- Use
predicate,rowgroup_selector,shuffle_rows,shuffle_row_groups, ortransform_spec.
- Use
- Need framework integration?
- Use
tf_tensorsormake_petastorm_datasetfor TensorFlow. - Use
DataLoader,BatchedDataLoader, orInMemBatchedDataLoaderfor PyTorch.
- Use
- Need aggregation or mixed sampling?
- Use
NGramorWeightedSamplingReader.
- Use
- Need Spark RDD access or timing?
- Use
dataset_as_rddor the throughput CLI.
- Use
Boundary reminders
make_readerexpects a Petastorm dataset and will warn if the store lacks Petastorm metadata.make_batch_readeris the route for non-Petastorm Parquet data.DataLoaderandBatchedDataLoaderare not interchangeable: the batched variant is optimized for tensorable fields and the in-memory variant is single-use.- PyTorch users should import
pyarrowbefore importingtorch. - TensorFlow dataset repetition should usually be controlled through the reader's
num_epochs, not by repeating the dataset blindly.
Common tasks
Read a Petastorm dataset in plain Python
- Call
make_reader(dataset_url, ...). - Use
reader_pool_type='dummy'for the smallest deterministic smoke checks. - Iterate rows and close the reader with a context manager.
Read a non-Petastorm Parquet store
- Call
make_batch_reader(dataset_url_or_urls, ...). - Limit
schema_fieldsto the columns you actually need. - Treat returned objects as batches rather than single rows.
Connect to TensorFlow
- Build a reader.
- Call
tf_tensors(reader)ormake_petastorm_dataset(reader). - Consume the tensors inside a
tf.Session()style loop.
Connect to PyTorch
- Import
pyarrowbeforetorch. - Wrap the reader in
DataLoader,BatchedDataLoader, orInMemBatchedDataLoader. - Avoid nullable or string-heavy fields when you want tensor-only batches.
Measure throughput
- Use
petastorm-throughput.pywith a real dataset URL. - Start with the dummy or thread pool on a tiny dataset.
- Increase cycles only after the basic path is working.
When to stop and switch routes
- If the problem is schema creation, field encoding, or dataset layout, switch to
create-datasets. - If the problem is converting a Spark DataFrame cache into a loader, switch to
spark-converter. - If the problem is a URL or filesystem resolution issue, read the root filesystem reference first.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).