AGENT SKILL

forecasting-models

Select, instantiate, train, checkpoint, predict, and interpret PyTorch Forecasting v1 model families from TimeSeriesDataSet datasets.

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

01 前言 Front Matter

name
forecasting-models
license
MIT
metadata
{ "disco-role": "operating" }
description
Select, instantiate, train, checkpoint, predict, and interpret PyTorch Forecasting v1 model families from TimeSeriesDataSet datasets.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Forecasting Models Sub-skill

Use this sub-skill when a PyTorch Forecasting 1.8.0 task already has, or is ready to build, v1 TimeSeriesDataSet train/validation/prediction objects and needs to choose a model family, instantiate it with .from_dataset(), run Lightning training, load a checkpoint, call predict(), or interpret model outputs.

Route here for

  • Choosing among Baseline, TemporalFusionTransformer, NBeats, NBeatsKAN, NHiTS, DeepAR, RecurrentNetwork, DecoderMLP, TiDEModel, TimeXer, and xLSTMTime for a concrete forecasting task.
  • Using .from_dataset(training_dataset, ...) to transfer TimeSeriesDataSet metadata into a v1 model.
  • Creating lightning.pytorch.Trainer objects with early stopping, learning-rate monitoring, CPU/GPU settings, debugging batch limits, checkpointing, and fast prediction.
  • Calling BaseModel.predict() or DeepAR.predict() with return_index, return_decoder_lengths, return_x, return_y, mode, mode_kwargs, n_samples, and trainer_kwargs.
  • Loading trained models with ModelClass.load_from_checkpoint() and using model-specific interpretation or plotting helpers when optional plotting packages are available.

Route away

  • Data schema design, TimeSeriesDataSet construction, encoders, normalizers, missing timesteps, dataloaders, and dataset serialization belong in ../data-pipeline/SKILL.md.
  • Loss choice, metric semantics, quantile/distribution details, Optuna tuning, and full learning-rate finder strategy belong in ../metrics-and-tuning/SKILL.md.
  • Experimental v2 package/data-module workflows, including the v2-only SOFTS layer, belong in ../api-v2-workflows/SKILL.md.

Bundled references and scripts

Minimal operating pattern

import lightning.pytorch as pl
from lightning.pytorch.callbacks import EarlyStopping, LearningRateMonitor
from pytorch_forecasting import TemporalFusionTransformer
from pytorch_forecasting.metrics import QuantileLoss

# `training`, `validation`, `train_loader`, and `val_loader` come from the data-pipeline sub-skill.
model = TemporalFusionTransformer.from_dataset(
    training,
    learning_rate=0.03,
    hidden_size=16,
    attention_head_size=1,
    dropout=0.1,
    hidden_continuous_size=8,
    output_size=7,               # 7 default quantiles for QuantileLoss()
    loss=QuantileLoss(),
    log_interval=-1,             # avoid plotting/logging overhead while debugging
    reduce_on_plateau_patience=4,
)

callbacks = [
    EarlyStopping(monitor="val_loss", min_delta=1e-4, patience=5, mode="min"),
    LearningRateMonitor(),
]
trainer = pl.Trainer(
    max_epochs=20,
    accelerator="auto",
    devices="auto",
    gradient_clip_val=0.1,
    callbacks=callbacks,
    enable_checkpointing=True,
)
trainer.fit(model, train_dataloaders=train_loader, val_dataloaders=val_loader)

best_path = trainer.checkpoint_callback.best_model_path
loaded = TemporalFusionTransformer.load_from_checkpoint(best_path)
preds = loaded.predict(
    val_loader,
    return_index=True,
    return_decoder_lengths=True,
    return_x=True,
    return_y=True,
    trainer_kwargs={"accelerator": "cpu"},
)

Safety and verification checklist

  1. Confirm the dataset shape and column roles in ../data-pipeline/SKILL.md before blaming the model.
  2. Start with Baseline().predict(...) or the bundled smoke script to prove the installed package, dataloader, Lightning, pandas, torch, and CPU path work.
  3. For neural models, instantiate with .from_dataset() instead of manually copying feature-cardinality metadata.
  4. Keep num_workers=0, accelerator="cpu", limit_train_batches=1, limit_val_batches=1, and tiny model sizes while debugging.
  5. Use model.size() before training; unexpectedly huge parameter counts usually indicate an oversized architecture or too many high-cardinality categorical embeddings.
  6. Treat v2-only or package-layer APIs as out of scope for this v1 model workflow unless the task explicitly routes to ../api-v2-workflows/SKILL.md.

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