beam-and-performance
Scale TensorFlow Datasets generation and reading with Beam, storage, sharding, GCS, and performance controls.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- beam-and-performance
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Scale TensorFlow Datasets generation and reading with Beam, storage, sharding, GCS, and performance controls.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/beam-workflows.md7.6 KB
- 参考文档references/performance-and-storage.md7.8 KB
- 参考文档references/troubleshooting.md8.3 KB
- 脚本scripts/beam_options_helper.py16.0 KB
03 SKILL.md 正文
Beam And Performance
Use this sub-skill when the task is to scale TensorFlow Datasets (TFDS) dataset
preparation or reading with Apache Beam, cloud runners, file formats, sharding,
GCS data directories, or tf.data performance controls.
Route other work away:
- Generic
tfds.load, split syntax, metadata inspection, NumPy/DataFrame, and non-Beam loading recipes ->data-loading. - Full
tfdsCLI syntax outside Beam/file-format/sharding flags ->cli-workflows. - Creating ordinary
GeneratorBasedBuilderdatasets,_info, features, checksums, dummy data, andDatasetBuilderTestCase->dataset-authoring. - Folder datasets, external TFRecord layouts, HuggingFace/Croissant/community
catalogs, and dataset collections ->
formats-and-community.
Evidence-backed API surface
The TFDS code and environment verification for this skill established these runtime facts:
- Beam generation is configured through
tfds.download.DownloadConfigfields includingbeam_runner,beam_options,max_examples_per_split,num_shards,min_shard_size,max_shard_size, andnondeterministic_order. tfds build --beam_pipeline_options=...stores a comma-separated options string; TFDS turns eachkey=valuesegment into a BeamPipelineOptionsflag without launching Beam during parsing.- Supported prepared-file format names are
tfrecord,array_record,riegeli, andparquet; TFRecord is the default. Some formats require extra reader/writer dependencies or different reading APIs. tfds.core.BeamBasedBuilderstill exists but is deprecated; current Beam authoring should normally useGeneratorBasedBuilderwhose_generate_examplesreturns a BeamPTransform/PCollection.tfds.beam.ReadFromTFDSreads an already prepared TFDS dataset inside a Beam pipeline, parallelizing over dataset shards.- Dataflow, Flink, private GCS, and service-account credentials are external services; do not run or mutate them without explicit user approval, budget, and credential boundaries.
Fast workflow chooser
| User intent | Use |
|---|---|
| "Build this huge TFDS dataset locally just to test the builder" | Direct/local Beam runner plus a tiny --max_examples_per_split or programmatic DownloadConfig(max_examples_per_split=...); warn that full local builds can exceed RAM/disk/time. |
| "Run TFDS generation on Dataflow" | Build a GCS-backed data_dir, staging_location, temp_location, requirements_file, and runner=DataflowRunner; verify project/bucket/credentials before launch. |
| "Use Flink" | Pass runner=FlinkRunner plus Flink version/config-dir options; verify Beam/Flink version compatibility externally. |
| "Use TFDS as source inside Beam" | Use tfds.beam.ReadFromTFDS(builder, split=...) only after the dataset is prepared; respect subsplit/batch limitations. |
| "Improve reading throughput/RAM" | Tune ReadConfig, shuffling, cache/batch/prefetch order, decode/skipped features, file format, and GCS locality. |
| "Change shard count/size or file format" | Use generation flags or DownloadConfig/download_and_prepare(file_format=...); validate reader compatibility before rebuilding. |
Standard playbooks
- Confirm the generation target. For multi-config builders, require the exact dataset/config/version. Avoid accidental "all configs" builds.
- Choose runner and storage. Direct runner is for tiny local tests. Use a
distributed runner for terabyte-scale datasets. Dataflow jobs should usually
write TFDS data to a
gs://.../tensorflow_datasetsroot and use a GCS temp and staging area. - Build pipeline options safely. Use
scripts/beam_options_helper.pyto create or validate--beam_pipeline_optionsstrings and get warnings without launching Beam. - Pass options through TFDS. See
references/beam-workflows.mdfor CLI and programmatic examples. - Set deterministic-order policy. Default Beam writing preserves TFDS's
deterministic ordering contract. Use
nondeterministic_order=Trueor--nondeterministic_orderonly when faster unordered output is acceptable and downstream code never depends on example order. - Control storage format and shards. See
references/performance-and-storage.mdfor--file_format,--num_shards,--max_shard_size_mb, andDownloadConfigequivalents. - Tune readers after generation. Prefer
shuffle_files=Truefor large training datasets, tuneReadConfigfor distributed workers and memory, skip unused or expensive features, and benchmark the final pipeline. - Triage failures before rerunning expensive jobs. Use
references/troubleshooting.mdfor Beam, GCS, sharding, determinism, and performance symptoms.
Safe command skeletons
Local smoke only:
tfds build DATASET[/CONFIG] \
--max_examples_per_split=10 \
--data_dir=/tmp/tfds-smoke
Dataflow option construction without launching a job:
python scripts/beam_options_helper.py \
--runner DataflowRunner \
--dataset DATASET \
--project GCP_PROJECT \
--gcs-bucket gs://BUCKET \
--requirements-file /tmp/beam_requirements.txt \
--print-build-command
Programmatic generation:
import apache_beam as beam
import tensorflow_datasets as tfds
flags = [
"--runner=DataflowRunner",
"--project=GCP_PROJECT",
"--staging_location=gs://BUCKET/binaries",
"--temp_location=gs://BUCKET/temp",
"--requirements_file=/tmp/beam_requirements.txt",
]
download_config = tfds.download.DownloadConfig(
beam_options=beam.options.pipeline_options.PipelineOptions(flags=flags),
# Only set when unordered output is acceptable:
# nondeterministic_order=True,
)
builder = tfds.builder("DATASET/CONFIG", data_dir="gs://BUCKET/tensorflow_datasets")
builder.download_and_prepare(download_config=download_config)
Verification expectations
For this sub-skill, safe verification should avoid full downloads and cloud job launches unless the user explicitly grants budget and credentials. Prefer:
python scripts/beam_options_helper.py --helpand representative option construction checks.- Import/signature checks for
tfds.download.DownloadConfig,tfds.ReadConfig, andtfds.beam.ReadFromTFDSin an environment that has the required optional packages. - Tiny local Beam/dummy-data checks only when Apache Beam and TensorFlow are already installed.
- Documentation of skipped Dataflow/Flink/private-GCS checks as external-service gaps, not failures of local validation.
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).