Skip to main content

Cadence: recursive settling populations with local state, readback and repair

Cadence

Website · Examples · Paper · PyPI · Documentation

PyPI CI Python License: MIT

Build Deep Recursive Settlement Networks: processing populations and their observers, learning and settling together.

Cadence explores a simple idea: a brain can be a persistent system of local relations that repairs its state as experience arrives. An observer reads what other patches are doing and influences them while remaining part of the same equilibrium. Another observer can read that enlarged system in turn.

Cadence implements this population architecture in pure Python, using only the standard library. Every processing and observer patch uses one local prediction relation. The compiled brain supports joint settlement, supervised witness learning, diagnostics and continuation.

In the bootstrapping phase, guided experience teaches the brain its basic abilities. In the live phase, that same brain acts in its environment and can continue learning from actual new witnesses. Both phases use the same patch rule and retained world model.

Three pillars

  • Minimalism: one patch rule, a small public API, no runtime dependencies. Focused modules keep each responsibility easy to find.
  • User-friendliness: explicit layouts, sensible defaults and runnable examples.
  • Agent-friendliness: exact contracts, inspectable state and explicit refusal.

Every core change is reviewed against all three. The contributor instructions define the checks.

Install

Python 3.11 or later; no runtime dependencies:

python -m pip install --upgrade "cadence-net>=0.46.0"

If your package index has not listed a new release yet, its wheel is also available from GitHub Releases.

Declare the brain

from cadence import Cortex

cortex = Cortex(seed=7)
eyes = cortex.input("eyes", shape=(8, 8))
ears = cortex.input("ears", shape=(2, 16))
body = cortex.input("sensory_nerves", shape=(8,))
senses = (eyes, ears, body)

c1 = cortex.column("perception", patches=16, inputs=senses)
c2 = cortex.observer(
    "integration", patches=8, inputs=senses, observes=(c1,),
)
c3 = cortex.observer(
    "reflection", patches=8, inputs=senses, observes=(c1, c2),
)
cortex.output("motor_nerves", shape=(8,), reads=c3)
brain = cortex.build()

assert brain.inspect()["patches"] == 32
assert brain.inspect()["sensor_coverage"] == 104

inputs supplies sensory or represented data. observes adds readback of live patch states and exact current prediction errors. Observer constraints feed back into the observed states through the same energy and repair process. They are not a separate decision made after the lower system finishes.

Population size counts processing patches. Sensor shape counts input samples; a larger camera shape does not supply learned visual understanding. The eight outputs expose eight settled patch values, without a separate policy network. The guide also shows parallel sensory branches and inspection of actual wiring. Every patch reads all coordinates of its declared sources by default; explicit fan_in opts into sparse sampling. This is a layout example, not a pretrained vision/audio model. For a first learning task, start smaller using the bootstrapping guide. Inspection also reports sensor coverage for each output coordinate, so you can check the decision's connections before bootstrapping.

Bootstrapping phase

This inexpensive example bootstraps a small brain's signed input/output relation. It uses the same population primitive, with fewer patches for a quick run.

from cadence import bootstrap

bootstrap_layout = Cortex(seed=2)
signal = bootstrap_layout.input("signal", shape=(1,))
base = bootstrap_layout.column("base", patches=4, inputs=signal)
reflection = bootstrap_layout.observer(
    "reflection", patches=2, inputs=signal, observes=base,
)
bootstrap_layout.output("answer", shape=(1,), reads=reflection)
learner = bootstrap_layout.build()

examples = [({"signal": [x]}, {"answer": [x]}) for x in (-0.8, 0.8)]
checks = [({"signal": [x]}, {"answer": [x]}) for x in (-0.4, 0.4)]
report = bootstrap(learner, examples, checks=checks, max_error=0.2)
assert report["passed"], report

# Fresh amplitudes, with no output targets supplied to the brain.
assert learner.predict({"signal": [-0.4]})["answer"][0] < -0.2
assert learner.predict({"signal": [0.4]})["answer"][0] > 0.2

Actual witnesses clamp the supplied outputs and allow joint repair of live state and retained relation parameters. Only qualified proposals are committed. Queries hold learned parameters fixed; hypothetical clamps never become experience. Learning is evaluated on later unclamped predictions, as above. This example establishes a small acquired relation, not a benefit from depth.

Live phase

activity = learner.step({"signal": [0.3]})
assert activity["accepted"]
print(activity["outputs"]["answer"])

# When an actual teaching signal arrives, the same brain can keep learning.
assert learner.observe({"signal": [0.3]}, {"answer": [0.3]})["accepted"]

bootstrap supplies reproducible replay and unclamped readiness checks. Applications supply sensory acquisition, witnesses, actuator interpretation and environment-specific behavior checks. The guide explains calibration and staged bootstrapping for perception and body control.

Scope

The reference engine repairs a nonlinear residual energy using analytic derivatives and a bounded descent procedure. Every participating population is included in the final constrained-stationarity check. Prediction errors can remain nonzero at a qualified compromise; different starting states can reach different stationary points. A solver can refuse when its budget is exhausted.

Performance evaluations and comparisons remain ongoing. Tests cover layouts, derivatives through recursive error readback, reciprocal interventions, actual acquisition, refusal and checkpoint custody. The goal is a reusable learner across perception, memory, reasoning and embodied action. Reward-driven temporal credit, broader capability and advantages from recursive depth require further controlled experiments. Follow the DRSN completion epic.

Documentation Scope
DRSN guide Population layouts, equations, learning, all configuration, diagnostics and checkpoints
Quickstart Inputs, settlement, learning and saved continuation
Bootstrapping and live phases Calibration, guided experience, small starting layouts and readiness checks
API reference Every public class, method and configuration parameter
Mathematical specification Guarantees, qualification and evidence boundaries

MIT license.

Metadata

Release files for cadence-net 0.46.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cadence-net 0.46.0
File Size Uploaded
cadence_net-0.46.0.tar.gz 1.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for cadence-net 0.46.0
File Interpreter ABI Platform
cadence_net-0.46.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.3 MB

Release files / cadence_net-0.46.0.tar.gz

Download URL cadence_net-0.46.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
170ef89c78d44ee83b795dd2165a6c69e5d5c7b6a08ea8b0f74ec2f8aedc0daa
BLAKE2b-256 checksum
How to use checksums
928777f4060bfb9e95e1af72bec0fbe97f14ad51ddae2fcabf1468dfa36f6919
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.46.0-py3-none-any.whl

Download URL cadence_net-0.46.0-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ece51bb3fa6bf0bab36eccdd43bc20ee59cee29d174fca134ad00093759dfde4
BLAKE2b-256 checksum
How to use checksums
834277fa2baa2afa102ecf7cc55ba9ec6b7d8ab2f0aa4f409ac1b36642f93c23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release history Release notifications | RSS feed

0.83.0

2 release files

0.82.0

2 release files

0.81.0

2 release files

0.50.0

2 release files

0.49.0

2 release files

0.48.0

2 release files

0.47.0

2 release files

This release

0.46.0 This release

2 release files

0.45.0

2 release files

0.44.0

2 release files

0.43.0

2 release files

0.42.0

2 release files

0.20.1

2 release files

0.19.0

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page