AGENT SKILL

training

Use Tensorpack ModelDesc, TrainConfig, trainers, callbacks, summaries, layers, and example training recipes.

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

01 前言 Front Matter

name
training
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use Tensorpack ModelDesc, TrainConfig, trainers, callbacks, summaries, layers, and example training recipes.
disable-model-invocation
true

02 资源文件 5

03 SKILL.md 正文

Tensorpack training sub-skill

Use this sub-skill when a task needs Tensorpack graph training: defining a ModelDesc, choosing a trainer, configuring TrainConfig, composing callbacks and monitors, using Tensorpack symbolic layers, adapting known training recipes, or debugging TF1-compatible tower training.

Start here

  1. If the user needs a training script skeleton, read references/workflows.md and consider the bundled smoke helper scripts/minimal_training_smoke.py.
  2. If the user asks for an API name, signature, or role, read references/api-reference.md.
  3. If the user asks how to adapt an example family such as MNIST, ResNet, Faster/Mask R-CNN, GAN, Atari RL, TIMIT, Char-RNN, PTB, or Keras, read references/example-recipes.md.
  4. If the user reports an error, wrong metric, checkpoint/resume issue, GPU scaling surprise, Keras incompatibility, or TF2/eager-mode failure, read references/troubleshooting.md.
  5. For deeper patterns, use references/workflows.md before proposing code.

Route to this sub-skill when

  • The task mentions ModelDesc, ModelDescBase, inputs(), build_graph(), optimizer(), TrainConfig, AutoResumeTrainConfig, or launch_train_with_config.
  • The task asks how Tensorpack follows the define-then-run paradigm, how an epoch/step loop works, or how callbacks fit around training iterations.
  • The task asks which trainer to use: SimpleTrainer, SyncMultiGPUTrainer, SyncMultiGPUTrainerReplicated, SyncMultiGPUTrainerParameterServer, AsyncMultiGPUTrainer, distributed parameter-server/replicated trainers, HorovodTrainer, or BytePS-style distributed trainers.
  • The task involves tower-function rules: variable scopes, variable reuse, collections, train/inference towers, TowerContext, or multiple calls to the same tower function.
  • The task involves callbacks/monitors such as ModelSaver, InferenceRunner, ScalarStats, ClassificationError, ScheduledHyperParamSetter, MaxSaver, MinSaver, MergeAllSummaries, TensorBoard event files, JSON histories, scalar printing, progress bars, or update ops.
  • The task involves training summaries: tf.summary.*, summary.add_moving_summary, summary.add_param_summary, moving averages, default monitors, or logging into TensorBoard/JSON/stdout.
  • The task involves Tensorpack symbolic layers such as Conv2D, FullyConnected, BatchNorm, argscope, LinearWrap, regularize_cost, BNReLU, pooling layers, dropout, or caveats around tf.layers/Keras.
  • The task asks how to adapt a Tensorpack example family for training, while preserving data, dependency, and backend caveats.

Route elsewhere

  • For DataFlow construction, dataset layout, serializers, augmentors, input performance, queue stalls, or MultiProcessRunnerZMQ, route to ../dataflow/SKILL.md.
  • For offline prediction, PredictConfig, OfflinePredictor, checkpoint variable inspection, .npz model-zoo files, Serving export, compact frozen graphs, or Caffe conversion, route to ../inference-export/SKILL.md.
  • For full benchmark/performance reproduction, ask for the actual hardware, exact dataset, cached weights, and dependency versions. Without those, only provide implementation guidance and verification limits.

Operating checklist

  1. Normalize the objective. Identify whether the user wants a new training script, a trainer choice, a callback/monitor setup, an example adaptation, or a debugging plan.
  2. Select the model interface. Prefer ModelDesc + TrainConfig for single-cost gradient training. Use the raw trainer interface when callbacks must be constructed after graph setup or the iteration is not single-cost.
  3. Define inputs explicitly. inputs() should return a list of tf.TensorSpec or placeholders created inside inputs(). The order and names must match the datapoints yielded by the input source.
  4. Build a tower-safe graph. build_graph() is a tower function: it may be called once per GPU and again for inference. Use tf.get_variable, respect the enclosing variable scope, avoid global-state mutation, and return the final cost for ModelDesc training.
  5. Create the optimizer once. optimizer() must return a tf.train.Optimizer. If using scheduled learning rates, create a named, non-trainable variable such as learning_rate and target it from callbacks.
  6. Choose the trainer by topology. Start with SimpleTrainer for CPU or one local GPU. Use synchronized multi-GPU trainers for data-parallel SGD, async trainers for intentionally asynchronous updates, and Horovod/BytePS only when the launcher, dependency, and log-directory behavior are controlled.
  7. Set steps_per_epoch deliberately. Tensorpack epochs mainly schedule callbacks. If input size is not known, set TrainConfig(steps_per_epoch=...). For multi-GPU, remember each GPU consumes one input batch, so total batch size is per-tower batch times the number of towers.
  8. Add callbacks and monitors. Defaults already include moving summaries, progress, merged summaries, update ops, TensorBoard event writing, JSON history, and scalar printing. Add model saving, validation inference, hyperparameter schedules, best-checkpoint savers, or custom callbacks as needed.
  9. Respect initialization/resume ownership. Put checkpoint or .npz loading in TrainConfig(session_init=...) or AutoResumeTrainConfig; route variable inspection/export details to inference-export.
  10. Bound verification. For a quick Tensorpack sanity check, run the bundled helper with fake data and a temporary log directory. Do not claim benchmark reproduction from the smoke helper.

Bundled smoke helper

The helper scripts/minimal_training_smoke.py is a safe, fake-data training script adapted for the generated skill tree. It has no network or dataset dependency and is intended for parser/help checks or a very short one-epoch run:

python scripts/minimal_training_smoke.py --workdir /tmp/tensorpack-smoke --steps-per-epoch 2 --max-epoch 1

Use it to demonstrate the shape of a Tensorpack ModelDesc, TrainConfig, callbacks, summaries, and trainer launch. Do not use it as evidence that a real dataset, GPU backend, Horovod, or paper benchmark is reproducible.

Quick answer patterns

Known limits

  • This sub-skill documents GPU and distributed trainers from API/source evidence but the generated Tensorpack skill pass used CPU verification as the required backend. Treat GPU, Horovod, BytePS, and large-dataset recipes as documented but not smoke-verified unless the user supplies matching hardware and data.
  • Tensorpack is TF1-graph-oriented even when installed with a TF2 package. Use tensorpack.tfv1 / tf.compat.v1 style graph code and disable eager execution before graph construction when needed.
  • Example-family commands are catalogs for adaptation. They are not bundled as runnable dependencies and they require the stated datasets/backends.

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