spark-converter
Routes Spark DataFrame conversion workflows that materialize cached parquet datasets and expose TensorFlow or PyTorch loaders through Petastorm.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- spark-converter
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Routes Spark DataFrame conversion workflows that materialize cached parquet datasets and expose TensorFlow or PyTorch loaders through Petastorm.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md2.4 KB
- 参考文档references/troubleshooting.md2.2 KB
- 参考文档references/workflows.md2.8 KB
- 脚本scripts/smoke_spark_converter.py3.4 KB
03 SKILL.md 正文
Spark Converter
Use this route when the starting point is a Spark DataFrame that should be materialized once and reused many times as a TensorFlow dataset
or a PyTorch DataLoader.
This route owns the converter cache, cache cleanup, filesystem normalization, and the Spark-side API surface around
make_spark_converter.
Typical triggers
- "How do I convert a Spark DataFrame into a TF dataset?"
- "How do I convert a Spark DataFrame into a PyTorch DataLoader?"
- "How do I set the converter cache directory?"
- "How do I delete converter cache files?"
- "Why does Spark converter cache cleanup or Horovod compatibility fail?"
What belongs here
make_spark_converterSparkDatasetConvertermake_tf_datasetmake_torch_dataloader- converter cleanup and delete behavior
- parent cache directory configuration
- DBFS and filesystem normalization rules
- file availability waits for the converter cache
- Horovod rank/size compatibility checks
What does not belong here
- raw dataset writing
- metadata repair
- reader-side
make_readerandmake_batch_readerworkflows - general Spark SQL or ML training that does not use the converter
Use sub-skills/create-datasets/ for writing new datasets.
Use sub-skills/read-datasets/ for consuming existing datasets directly.
Read this first
references/workflows.mdfor converter setup and adapter recipesreferences/api-reference.mdfor verified signatures and cache behaviorreferences/troubleshooting.mdfor Spark, DBFS, cache, and optional backend failuresscripts/smoke_spark_converter.pyfor a tiny end-to-end conversion check
How to choose a converter path
- Starting from a Spark DataFrame?
- Use
make_spark_converter(df, ...).
- Use
- Need TensorFlow input?
- Call
converter.make_tf_dataset(...).
- Call
- Need PyTorch input?
- Call
converter.make_torch_dataloader(...).
- Call
- Need to clean up cache files?
- Call
converter.delete()or register a custom delete handler if the filesystem needs special treatment.
- Call
Boundary reminders
SparkDatasetConverter.PARENT_CACHE_DIR_URL_CONFmust be set before creating a converter.- The converter caches a materialized parquet version of the DataFrame.
- The cache is reusable across TF or Torch loaders once the converter is created.
make_tf_datasetandmake_torch_dataloaderare context managers that close their readers when the context exits.- The converter can be used from remote Spark workers only when its cached files are available there too.
Common tasks
Create a converter
- Set
petastorm.spark.converter.parentCacheDirUrlon the Spark session. - Call
make_spark_converter(df). - Reuse the converter for one or more loaders.
Build a TensorFlow dataset
- Call
converter.make_tf_dataset(...). - Choose
batch_size,num_epochs, andshuffling_queue_capacityas needed. - Train or evaluate inside the returned context manager.
Build a PyTorch dataloader
- Call
converter.make_torch_dataloader(...). - Choose
batch_size,num_epochs, andshuffling_queue_capacityas needed. - Use the resulting loader in your model code.
Delete the cache
- Call
converter.delete()after the loader is no longer needed. - If the filesystem needs a custom delete implementation, register it first.
When to stop and switch routes
- If the starting point is raw rows or a schema definition, switch to
create-datasets. - If the starting point is an existing dataset instead of a Spark DataFrame, switch to
read-datasets.
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).