opf-prediction
Use NuPIC legacy Online Prediction Framework models, experiment directories, prediction outputs, and checkpoints.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- opf-prediction
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use NuPIC legacy Online Prediction Framework models, experiment directories, prediction outputs, and checkpoints.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md8.7 KB
- 参考文档references/opf-workflows.md9.3 KB
- 参考文档references/troubleshooting.md8.5 KB
- 脚本scripts/opf_experiment_help.py6.1 KB
- 脚本scripts/opf_prediction_smoke.py9.5 KB
03 SKILL.md 正文
OPF Prediction
Use this sub-skill when the task mentions NuPIC legacy OPF, ModelFactory, HTMPredictionModel, model.run, result.inferences, multiStepBestPredictions, run_opf_experiment, experiment description.py directories, or OPF checkpoints.
Route first
- For CSV header rows, field type conversion rules, stream sources, and model parameter YAML/JSON structure, read
../data-and-configuration/before changing OPF code. - For encoder, Spatial Pooler, Temporal Memory, classifier, anomaly-score, or SDR internals below OPF, read
../htm-algorithms/. - For models generated by a swarm, read
../swarming/first, then return here to run the generated best OPF model. - For package installation, Python 2.7,
nupic.bindings,numpy,pycapnp, or capnproto failures, start with root troubleshooting at../../references/troubleshooting.mdand then use the OPF-specific troubleshooting below.
NuPIC legacy OPF is a Python 2.7-era API. Expect environments to need the legacy nupic package, compiled nupic.bindings, numpy 1.12.x-era compatibility, and pycapnp/capnproto for some serialization paths.
Fast workflow map
- Create and run a model from CSV: load model params, call
ModelFactory.create(modelConfig, logLevel=40), callmodel.enableInference({'predictedField': '<field>'}), convert each CSV value to the declared Python type, callmodel.run(record), and readresult.inferences. Full recipe:references/opf-workflows.md. - Extract one- or multi-step predictions: read
result.inferences['multiStepBestPredictions'][step]and confidence fromresult.inferences['multiStepPredictions'][step][predictedValue], allowing warm-upNone/empty predictions. Shapes and API keys:references/api-reference.md. - Run an OPF experiment directory: use the installed experiment runner against an experiment directory containing
description.py; list tasks/checkpoints before long runs. Command patterns and checkpoint layout:references/opf-workflows.md. - Checkpoint or reload a model: direct API uses
model.save(saveModelDir)andModelFactory.loadFromCheckpoint(saveModelDir); experiment runs usesavedmodels/<label>.ntaunder the experiment directory. Details:references/api-reference.md. - Debug failures: predicted-field mismatches, malformed model params, unconverted raw strings, missing inference keys, runner usage errors, checkpoint directory shape, missing bindings/capnp, and Python 2 print syntax are covered in
references/troubleshooting.md.
Bundled scripts
- Run
scripts/opf_prediction_smoke.pyas a deterministic import/API smoke check; with--params,--csv, and--predicted-fieldit can run a tiny bounded OPF CSV pass without depending on the original repository checkout. - Run
scripts/opf_experiment_help.pyto print self-contained OPF experiment runner command patterns, or use--runner-help/--check-importinside an installed NuPIC legacy environment.
Minimal direct API skeleton
from nupic.frameworks.opf.model_factory import ModelFactory
model = ModelFactory.create(modelConfig, logLevel=40)
model.enableInference({'predictedField': 'consumption'})
record = {'timestamp': timestamp_datetime, 'consumption': 21.2}
result = model.run(record)
best = result.inferences['multiStepBestPredictions']
all_predictions = result.inferences['multiStepPredictions']
if best.get(1) is not None:
one_step = best[1]
confidence = all_predictions[1][one_step]
Keep OPF records typed before model.run; raw CSV strings are a common source of misleading failures.
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).