Cadence
Machine learning by patch-net settlement: owner-local repair, held-out tests, receipts.
A patch net is a set of owners, each holding one patch of state, joined by declared overlaps. Nothing is computed globally. Every owner repairs its own patch from what arrives over its overlaps, and the state the net comes to rest in is the answer. Cadence is the library for building, settling, testing, and certifying such nets, from a six-owner ring to a 161,827-owner nervous system read from a connectome.
import cadence as cd
wiring = cd.Wiring.from_edges(4, pre=[0, 1, 2, 3], post=[1, 2, 3, 0], count=[120] * 4)
engine = cd.Settlement(wiring, cd.GradedRule(gain=0.03))
engine.settle(clamp={0: 1.0}, steps=60).activation.round(2)
# array([1., 1., 1., 1.])
What is in the box
| layer | what it gives you |
|---|---|
Wiring |
owners and overlaps as sorted arrays, named sets, digests; built from edge lists |
GradedRule, Adaptation |
the owner rule: a graded potential with a rectified sigmoid that emits nothing at rest, and an optional adaptation variable that turns fixed points into rhythm |
Settlement |
the engine, on NumPy float64 ("cpu") or torch ("torch": CUDA, Apple silicon, or CPU) |
conformance, settle_owner_by_owner, Ledger |
an owner-by-owner reference engine with a message ledger, to certify that a fast backend computes nothing the owners could not |
Protocol, Row, shuffled, select_gain |
declared stimuli, readouts, and held-out facts with preconditions; the shuffled-wiring control; gain selection under a sparsity cap |
Receipt, source_manifest |
canonical JSON bound to code and data by digest, verified by recomputing every pass flag |
Source, fetch |
pinned public data, downloaded once, verified always |
Install
pip install cadence-net # NumPy only; the import is `cadence`
pip install "cadence-net[accel]" # adds torch for CUDA and Apple silicon
Python 3.11 or newer. On an M-series Mac the torch backend runs on MPS in float32; on CUDA it runs in float64. The CPU backend is always float64 and is the one receipts are made on.
Sixty seconds
A wiring is n owners plus directed overlaps with a contact count and a sign. Build it
from edge lists; parallel overlaps merge, autapses drop, and you can name sets of owners.
w = cd.Wiring.from_edges(
3, pre=[0, 0, 1], post=[1, 2, 2], count=[80, 20, 80], sign=[1, 1, -1],
sets={"input": [0], "output": [2]},
)
A rule says what an owner does with its inbox. GradedRule is the one every
connectome lane uses. Add Adaptation when you want rhythm.
rule = cd.GradedRule(gain=0.02, adaptation=cd.Adaptation(tau_steps=40, strength=1.0))
Settle from rest under a clamp. A clamp is a list of owners at full amplitude, a
{owner: level} map, or a dense drive vector. Ask for the trajectory when you want to watch.
engine = cd.Settlement(w, rule, backend="torch") # or "cpu"
state = engine.settle(w.members("input"), steps=100, trajectory=True)
state.activation, state.trajectory.shape
Declare a protocol and score it. Rows are held-out facts with predicates that carry their preconditions. The shuffled control keeps every count, sign, and set.
protocol = cd.Protocol(
stimuli={"rest": (), "drive": ("input",)},
training=[("drive", "output", "active")],
rows=[cd.Row("R1", "rest", "output", "inactive", "nothing in, nothing out")],
)
protocol.score(engine)["passed"], protocol.score(cd.Settlement(cd.shuffled(w, 0), rule))["passed"]
Certify the backend and write a receipt.
cd.conformance(engine, w.members("input"))["max_abs_deviation"]
receipt = cd.Receipt.build("my-lane/v1", {"score": protocol.score(engine)}, sources=[("lane.py", Path("lane.py"))])
receipt.write(Path("receipt.json"))
cd.Receipt.verify(Path("receipt.json"), sources=[("lane.py", Path("lane.py"))])
The quickstart walks through a connectome; concepts explains why the library is shaped this way; backends covers devices and precision; receipts covers what a verified result means.
Discipline
Three rules the library enforces rather than recommends:
- Owner-local or nothing. The reference engine reads one owner and its inbox at a
time and ledgers every delivery.
conformancecompares any backend against it. - Held out means held out. A protocol names the few facts a model may be shown. Gains are selected on those alone, and only while the net stays sparse, because runaway activity lights every readout and proves nothing about the wiring.
- A result is a receipt. Canonical JSON, a digest, the digests of the code and data, and every pass flag recomputable from the stored readings. A receipt that fails to verify is not a result.
Where it comes from
Cadence consolidates the lanes of the observer patch net programme: a C. elegans connectome scored against classical ablation phenotypes, the FlyWire Drosophila brain and the MANC nerve cord joined by their descending neurons and scored against held-out taste, grooming, escape, olfaction, and motor facts, and that nervous system driving a biomechanical fly in MuJoCo. Every one of those lanes is a wiring, a rule, a protocol, a control, and a receipt; the library is what they had in common.
Status
Version 0.1.0 is the core: wiring, rule, engine, reference, protocol, receipts, custody. On the roadmap: the owner-local free/nudged learning rule, closure sub-nets for in-browser settlement, environment adapters for embodiment, and connectome loaders.
MIT licensed.
Metadata
Release files for cadence-net 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cadence_net-0.1.0.tar.gz | 24.1 kB | Without provenance | Details for cadence_net-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cadence_net-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cadence_net-0.1.0-py3-none-any.whl |
Total release size: 44.3 kB
Release files / cadence_net-0.1.0.tar.gz
| Download URL | cadence_net-0.1.0.tar.gz |
|---|---|
| Size | 24.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f4aec9ff0d4e407c5a952725df23b0cb440abb07bffd28e958632d7ef049237
|
|
BLAKE2b-256 checksum How to use checksums |
9c54095d23a9ee85dfe93e92a4d42e9c9c41c6694ec1bbb61e90be87f66e3df7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0
|
Release files / cadence_net-0.1.0-py3-none-any.whl
| Download URL | cadence_net-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7099d032fdb95bb4a207d99de3e769969e05eaa8a9ba0f384eaaa741f8b74cca
|
|
BLAKE2b-256 checksum How to use checksums |
b8924b192e62767f9bf80bf647e7b4014df551adab72d54af52738cf51426771
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.0
|
Security for cadence-net 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.