AGENT SKILL

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

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_converter
  • SparkDatasetConverter
  • make_tf_dataset
  • make_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_reader and make_batch_reader workflows
  • 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.md for converter setup and adapter recipes
  • references/api-reference.md for verified signatures and cache behavior
  • references/troubleshooting.md for Spark, DBFS, cache, and optional backend failures
  • scripts/smoke_spark_converter.py for a tiny end-to-end conversion check

How to choose a converter path

  1. Starting from a Spark DataFrame?
    • Use make_spark_converter(df, ...).
  2. Need TensorFlow input?
    • Call converter.make_tf_dataset(...).
  3. Need PyTorch input?
    • Call converter.make_torch_dataloader(...).
  4. Need to clean up cache files?
    • Call converter.delete() or register a custom delete handler if the filesystem needs special treatment.

Boundary reminders

  • SparkDatasetConverter.PARENT_CACHE_DIR_URL_CONF must 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_dataset and make_torch_dataloader are 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

  1. Set petastorm.spark.converter.parentCacheDirUrl on the Spark session.
  2. Call make_spark_converter(df).
  3. Reuse the converter for one or more loaders.

Build a TensorFlow dataset

  1. Call converter.make_tf_dataset(...).
  2. Choose batch_size, num_epochs, and shuffling_queue_capacity as needed.
  3. Train or evaluate inside the returned context manager.

Build a PyTorch dataloader

  1. Call converter.make_torch_dataloader(...).
  2. Choose batch_size, num_epochs, and shuffling_queue_capacity as needed.
  3. Use the resulting loader in your model code.

Delete the cache

  1. Call converter.delete() after the loader is no longer needed.
  2. 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

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351