network-api
Build, link, run, inspect, and debug NuPIC legacy Network API pipelines and custom PyRegion regions.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- network-api
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Build, link, run, inspect, and debug NuPIC legacy Network API pipelines and custom PyRegion regions.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/custom-region.md7.6 KB
- 参考文档references/network-workflows.md11.7 KB
- 参考文档references/troubleshooting.md8.3 KB
- 脚本scripts/network_smoke.py6.7 KB
03 SKILL.md 正文
NuPIC Legacy Network API
Use this sub-skill when the user asks to build a NuPIC Network, add/link regions, initialize/run a Network API pipeline, read region outputs, debug link names, or create a custom Python region. NuPIC legacy is a Python 2.7-era package; Network API workflows normally require nupic.bindings, numpy 1.12.x-compatible runtime packages, and working Cap'n Proto/pycapnp support for some serialization paths.
Do not use this sub-skill for every prediction task. If the user wants the higher-level OPF model workflow, route to ../opf-prediction/. If the task is about CSV headers, FileRecordStream, or model parameter files, route to ../data-and-configuration/. If the task is about encoder, SP, TM, or classifier parameter semantics outside a Network graph, route to ../htm-algorithms/. For package installation/import failures, use the root troubleshooting guide at ../../references/troubleshooting.md first.
Fast path
- Confirm that the legacy runtime can import and construct an empty Network:
python scripts/network_smoke.py - Build the graph in this order:
Network()->addRegion(...)-> attachRecordSensor.encoderandRecordSensor.dataSource-> setSPRegioninputWidth->link(...)-> setpredictedField/modes ->initialize()->run(n). - Use region type strings exactly:
py.RecordSensor,py.SPRegion,py.TMRegion, andpy.SDRClassifierRegionunless a custom region has been registered. - Use explicit link endpoint names when debugging:
srcOutput="dataOut",destInput="bottomUpIn",srcOutput="bottomUpOut",destInput="bottomUpIn", and sensor-to-classifierbucketIdxOut,actValueOut,categoryOutlinks. - Query outputs with
network.regions["name"].getOutputData("outputName"); classifier predictions come fromactualValuesand flattenedprobabilitiesarrays.
Bundled runtime resources
references/network-workflows.md: read this for the complete sensor -> SP -> TM -> classifier construction recipe, link table, output shapes, validation checks, and safe serialization notes.references/custom-region.md: read this when the user needs a customPyRegionskeleton, registration steps,getSpec()contract, or dynamic output width handling.references/troubleshooting.md: read this when Network imports, region type strings, link endpoint names, initialization, typed parameters, classifier outputs, or bundle loading/saving fail.scripts/network_smoke.py: run this deterministic helper to importnupic.engine.Network, construct an empty network by default, optionally inspect built-in region specs, and print a safe next-step pipeline template without requiring source data files.
Minimal Network API shape
import json
from nupic.engine import Network
network = Network()
network.addRegion("sensor", "py.RecordSensor", "{}")
# Attach a MultiEncoder and FileRecordStream to network.regions["sensor"].getSelf().
network.addRegion("SP", "py.SPRegion", json.dumps(spParams))
network.addRegion("TM", "py.TMRegion", json.dumps(tmParams))
network.addRegion("classifier", "py.SDRClassifierRegion", json.dumps(clParams))
network.link("sensor", "SP", "UniformLink", "", srcOutput="dataOut", destInput="bottomUpIn")
network.link("SP", "TM", "UniformLink", "", srcOutput="bottomUpOut", destInput="bottomUpIn")
network.link("TM", "classifier", "UniformLink", "", srcOutput="bottomUpOut", destInput="bottomUpIn")
network.link("sensor", "classifier", "UniformLink", "", srcOutput="bucketIdxOut", destInput="bucketIdxIn")
network.link("sensor", "classifier", "UniformLink", "", srcOutput="actValueOut", destInput="actValueIn")
network.link("sensor", "classifier", "UniformLink", "", srcOutput="categoryOut", destInput="categoryIn")
network.regions["sensor"].setParameter("predictedField", "consumption")
for name in ("SP", "TM", "classifier"):
network.regions[name].setParameter("learningMode", 1)
network.regions[name].setParameter("inferenceMode", 1)
network.initialize()
network.run(1)
Keep generated or copied user examples self-contained. Do not require future agents to open the original repository docs, tests, scripts, examples, notebooks, or local checkout paths.
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).