AGENT SKILL

dataflow

Use Tensorpack DataFlow, datasets, augmentors, serializers, input sources, and performance-tuning utilities.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
dataflow
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use Tensorpack DataFlow, datasets, augmentors, serializers, input sources, and performance-tuning utilities.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Tensorpack DataFlow Skill

Use this sub-skill when the user needs Tensorpack data loading, preprocessing, serialization, image augmentation, TensorFlow input-source bridging, or data pipeline performance diagnosis. Keep answers self-contained: rely on the bundled references and script here instead of reopening the original repository.

Read first

  1. For exact API signatures, component roles, optional dependencies, and gotchas, read references/api-reference.md.
  2. For concrete construction recipes and decision trees, read references/workflows.md.
  3. For symptom-to-recovery guidance, read references/troubleshooting.md.
  4. For a safe serializer availability/roundtrip check, use scripts/dataflow_serializer_smoke.py.

Use this when

  • The task mentions tensorpack.dataflow, DataFlow, datapoints, components, reset_state(), __iter__(), BatchData, MapData, MapDataComponent, FakeData, DataFromList, DataFromGenerator, RepeatedData, or PrintData.
  • The user asks how to choose between parallel runners and parallel mappers, or between threads, processes, and ZeroMQ data pipes.
  • The task involves LMDBSerializer, NumpySerializer, TFRecordSerializer, HDF5Serializer, optional serializer imports, or a data serialization roundtrip.
  • The task involves tensorpack.dataflow.imgaug, AugmentorList, deterministic image transforms, coordinate transforms, Flip, Resize, CenterCrop, GoogleNetRandomCropAndResize, dtype conversions, contrast, or brightness.
  • The task asks how a DataFlow feeds Tensorpack trainers through FeedInput, QueueInput, StagingInput, TFDatasetInput, TensorInput, or ZMQInput.
  • The task involves Tensorpack dataset loaders such as Mnist, Cifar10, SVHNDigit, ILSVRC12, or ILSVRC12Files.
  • The task is about queue size, TestDataSpeed, random disk reads, CPU-bound augmentation, network/IPC bottlenecks, or slow input pipelines.

Route elsewhere

Operating model

Tensorpack DataFlow is a pure-Python iterator system. A source DataFlow yields one datapoint at a time; wrappers transform, filter, batch, shuffle, prefetch, or serialize those datapoints. A datapoint is normally a list of components, but some DataFlow utilities also support dict datapoints. Tensorpack trainers do not usually consume DataFlow directly; an InputSource turns a DataFlow or another input producer into tensors in the TensorFlow graph.

Default answer pattern:

  1. Identify whether the user needs a source, wrapper, parallelization, serialization, augmentation, dataset loader, InputSource, or performance diagnosis.
  2. State the DataFlow contract: implement __iter__(), call reset_state() in the process that will iterate, treat __len__() as optional/rough unless the downstream consumer needs exact size, and avoid concurrent iteration of one non-reentrant instance.
  3. Choose the smallest composition that preserves correctness before optimizing speed.
  4. For training, allow distribution-preserving duplication/reordering only when it is acceptable for stochastic training. For validation/inference, preserve exact membership and usually exact ordering.
  5. Use PrintData and TestDataSpeed before guessing. If a trainer queue is close to empty, diagnose the input pipeline; if it is full, route graph or trainer speed questions to training.

Quick decisions

  • New custom data format: write a source DataFlow or wrap a generator with DataFromGenerator; then compose maps, augmentors, batches, and prefetching.
  • In-memory toy or deterministic tests: use FakeData or DataFromList.
  • Map one component: use MapDataComponent(ds, func, index=...); map/filter a full datapoint: use MapData(ds, func), returning None to drop it.
  • Batch same-shaped components: use BatchData(ds, batch_size); use use_list=True when components have variable shapes such as raw images.
  • Training prefetch with independent stochastic workers: use MultiProcessRunnerZMQ or MultiThreadRunner only when duplicated/reordered i.i.d. samples are acceptable.
  • Preserve set membership while parallelizing expensive transforms: use MultiThreadMapData or MultiProcessMapData/MultiProcessMapDataZMQ; use strict=True for finite validation-style passes, remembering order is still not preserved.
  • Random-read ImageNet-like data on slow disks: consider serializing encoded bytes to LMDB, then sequentially read, locally shuffle, decode, augment, and batch.
  • Feed a Tensorpack trainer: prefer QueueInput(dataflow) for most DataFlow training; wrap with StagingInput when GPU staging is useful; use TFDatasetInput or TensorInput for TensorFlow-native input pipelines.

Reference tasks

Safe checks

Use the bundled script for serializer availability, optional dependency messages, and tiny deterministic roundtrips:

python sub-skills/dataflow/scripts/dataflow_serializer_smoke.py --help
python sub-skills/dataflow/scripts/dataflow_serializer_smoke.py \
  --workdir <scratch-dir> --formats numpy
python sub-skills/dataflow/scripts/dataflow_serializer_smoke.py \
  --workdir <scratch-dir> --formats all

The script writes only under --workdir, uses tiny synthetic datapoints, avoids network and downloads, and does not require original Tensorpack source files.

Hard boundaries

  • Do not recommend running original example or test files as part of answering a user question. Use the distilled recipes and bundled helper instead.
  • Do not claim GPU or multi-node performance verification from this skill; the DataFlow references document CPU/IPC/disk/network reasoning and route trainer scaling to training.
  • Do not expose machine-specific environment or filesystem locations in user-facing answers.
  • Do not use runner-style parallelism for validation unless the user explicitly accepts potential duplication and reordering; use mapper-style strict passes or a single runner process for exact validation-style data.

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