Repository navigation
use case spiking transformers
A fully scoped production use case. Extends the reference slice in
use_case_streaming_timeseries.md; consumes the shared enablers fromproduction_toolkit_plan.md; listed in the umbrellaproduction_use_cases.md.
One-line summary. Model long sequences with spiking attention, benchmark the efficiency case against a dense baseline on GPU, and define a contract for an exportable spiking attention primitive — with no neuromorphic chip.
What it demonstrates. The research frontier: spiking attention today is
sequence_attn — simulation-only, with export refused via a typed
UnsupportedStageError (stages_unmappable.py).
This use case turns that honest boundary into an explicit, testable contract and a
long-sequence efficiency benchmark.
Design/spec only. Every claim about current code is grounded in a file/line reference so a Code-mode agent can execute this file-by-file. No implementation starts in this document.
What. Train and serve long-sequence spiking models (including
sequence_attn) on GPU, measure quality and efficiency against a dense baseline,
and specify the conditions under which an attention stage becomes NIR-exportable
(and therefore deployable through the standard bundle path).
Users. Sequence-modeling researchers; teams evaluating SNNs for very long sequences; maintainers who need the export boundary to be explicit rather than implicit.
Why SNN here. Potential efficiency at long sequence lengths from sparse, event-driven updates; this is a research use case where the honest question is "where does it win, and where can it not yet be exported?"
Success criteria (SLAs).
- Quality: task metric (accuracy/perplexity) within a configured margin (e.g. ≤ 5% relative) of a matched dense baseline on the chosen long-sequence task, or an honest statement that it does not match.
- Efficiency: throughput and peak memory at long sequence length reported vs the dense baseline; a win is claimed only where measured.
- Boundary: every non-exportable stage raises the typed
UnsupportedStageErrornaming the stage; the exportable attention contract is specified and enforced by a test. - Zero hardware: GPU training/serving only; energy stays
estimate: true.
flowchart LR
A[Long-sequence data] --> B[Tokenize and window]
B --> C[Encoding contract]
C --> D[Spiking sequence model session]
D --> E[Sequence head]
E --> F[spikeforge-serve predict and stream]
D --> G[DeploymentBundle if exportable]
G --> D
D --> H[NIR export gate]
H --> I[Typed refusal for unmappable stages]
F --> J[spikeforge-clients SDK]
F --> K[Throughput and memory metrics]
L[Offline training] --> G
-
Sources: a long-sequence benchmark task (e.g. a character/word-level
sequence corpus or a long time-series set) plus a deterministic synthetic
long-sequence generator for CI (paralleling
sequence_source.py). -
Contract: tokenization/windowing and normalization frozen in
preprocessing.jsonin the bundle; sequence lengthTis a first-class, reported parameter.
-
Primary coding:
rateover the token window as the robust baseline, withdeltaas the streaming alternative; frozenEncodeSpec. -
Input shape:
[T, B, D](or[T, B, L, D]), matching the sequence presets (sequence_presets.py) and the attention stages (attention.py,multihead_attention.py).
-
Topology:
sequence_attn(simulation-only) as the primary research model;sequence_mlpas the exportable control. Declared once as aTopologySpec. - Head: sequence classifier or next-token head.
-
Reuse:
TrainingEngine, surrogate gradients, AMP/BPTT scale-ups, checkpointing (checkpoint_mixin.py). -
Export contract (new deliverable): define the primitive set an attention
stage must use to be NIR-mappable, so
stages_unmappable.pyrefuses only what is genuinely unmappable and the contract is documented and tested.
- Quality vs the dense baseline at matched parameter count / compute.
-
Efficiency: throughput (tokens/s) and peak memory at increasing
T. -
Export gate: the control
sequence_mlpexports and validates; thesequence_attnmodel raises a typedUnsupportedStageErrornaming the stage — both asserted by test. - Validation: NIR drift (
within_tolerance) where applicable and determinism (determinism.py); manifest per run (manifest.py).
-
model.spkfwithmanifest.json,weights.pt,encode_config.json,preprocessing.json,graph.nir.jsononly when the model is exportable, checksums/signature. A non-exportable model yields a typed refusal, not a broken bundle. - Anchors:
bundle.py,bundle_manifest.py.
- For exportable models:
InferenceSession.load(bundle),.reset(),.step(frame),.run_stream(frames); state viaStateTree. - For simulation-only attention models: the closed-loop simulator path remains the reference; the session is available but the export gate is explicit.
-
spikeforge-serve:POST /v1/predict,POST /v1/reset,GET|WS /v1/stream,GET /health,GET /metrics,GET /v1/bundle— serving the exportable control model; the research-only model is served via the in-process simulator path (app.py,service.py).
-
spikeforge-clientsSDKs drive the served control model (client.py);spikeforge-iosupplies windowing for long sequences (windowing.py).
- Prometheus over the registry (
registry.py): latency histogram, throughput, peak memory, spike sparsity per stage. - Serving benchmark p50/p99 + throughput at long
T, wired into the regression gate (compare.py).
- Pruning (
pruning.py) plus weight-only quantization (quantize.py) to test whether the efficiency case survives compression; drift recorded.
- Test-deploy the exportable control (
sequence_mlp) onreferenceandnorse(andlava_loihi2where it lowers) with a parity report (test_deploy.py). The attention model is not a test-deploy row; it reports a typed refusal and the upstream NIR primitive gap is named as not-ours.
| Phase | Deliverable | Depends on | Acceptance |
|---|---|---|---|
| P0 | Long-sequence data adapter + synthetic generator + windowing spec | — | long-T windows reproducible |
| P1 |
sequence_attn + sequence_mlp trained at matched size; metrics |
P0 | quality vs dense baseline reported honestly |
| P2 | Efficiency harness (throughput/memory vs T) |
W1 | numbers reproducible on GPU and CPU |
| P3 | Exportable attention contract + NIR gate tests | W1 | contract spec'd; typed refusal asserted |
| P4 |
DeploymentBundle for the exportable control + parity |
W1, W2 | fresh-process rebuild exact; tamper refused |
| P5 |
spikeforge-serve control path + /metrics + benchmark |
W3, W6 | parity with in-process; p99 within budget |
| P6 | Container, promotion/rollback, benchmark publication | W7 | results published with environment and caveats |
MVP = P0–P4. That is the smallest end-to-end slice that demonstrates the long-sequence research story and makes the export boundary explicit.
Depends on: PT-W1 (released spikeforge/serving/); W2 (frozen
EncodeSpec); PT-W6 observability/benchmarks;
PT-W3 for the served control path. Tracked by umbrella issue #12; reference
implementation UC-1 (released in spikeforge 0.3.0).
Out of scope: a full temporal SNN in ONNX (ONNX has no temporal spiking
semantics); NIR primitive gaps that are upstream of this project (attention
lowering may require upstream changes — named, not promised); measured power
(estimate: true); large-scale distributed training.
| Risk | Mitigation |
|---|---|
| Efficiency win does not materialize | report honestly; scope claims to where measured; keep sequence_mlp as the exportable control |
| Export contract drifts from the NIR gate | one contract spec plus a test asserting the typed refusal and the exportable case |
| Benchmark irreproducibility across GPUs | record environment, seeds, and determinism report with every number |
| Upstream NIR gap blocks deployment | kept explicitly out of scope; the refusal stays typed and named |
-
Title:
[UC-8] Efficient sequence models / spiking transformers -
Labels:
enhancement,architecture -
Body: see
plans/use_case_spiking_transformers.md— goal, reference architecture (encode → spiking sequence session → head →spikeforge-servecontrol → clients → throughput/memory/metrics; NIR export gate), rate/delta coding,sequence_attn(simulation-only) +sequence_mlpcontrol, acceptance (quality within 5% of dense baseline or honest statement; throughput/memory reported; typedUnsupportedStageError), MVP phases P0–P4, dependencies PT-W1/W2/W3/W6.
- Home
- Architecture
- Backend Execution
- Benchmarks
- Dashboard
- Development
- Event Datasets
- Event Runtime And Energy
- Features
- Implications And Boundaries
- Interop Foldins
- Interpreter Spine
- Introspection
- Model Deployment
- Model Hub
- Notes
- Operational Maturity
- Production Workflows
- Project Layout
- Quickstart
- Requirements
- Sequence Primitives
- Streaming Timeseries
- Targets And Interop
- Usage
- Arch 0001 Adr Repo Topology
- Arch 0001 Core Boundary
- Arch 0001 Decision Metrics
- Arch 0001 Migration Plan
- Arch 0001 Packaging Versioning
- Arch 0001 Protocol Contract
- Arch 0001 Risk Register
- Arch 0001 Target Topology
- Backend Execution Plan
- Ecosystem Listings
- Ecosystem Roadmap
- Event Runtime Plan
- Hub Expansion Plan
- Plans
- Interop Foldins Plan
- Interpreter Spine Plan
- Memory System Research
- Model Hub Plan
- Operations Plan
- Production Toolkit Plan
- Production Use Cases
- Professional Roadmap
- Repo Topology Plan
- Sequence Primitives Plan
- Use Case Audio Keyword Spotting
- Use Case Biosignal Medical Monitoring
- Use Case Computational Neuroscience
- Use Case Edge Power Budgets
- Use Case Event Camera Vision
- Use Case Intrusion Anomaly Detection
- Use Case Low Latency Sensor Stream
- Use Case Rl Control Robotics
- Use Case Spiking Transformers
- Use Case Streaming Timeseries