Functional plans and tensor packets#

These APIs expose lowering, preparation, and individual simulation phases. Most applications can use the runner lifecycle in Functional execution. Preparation materializes raw sources; stepping consumes prepared values and explicit state without mutating the native model.

Population and Network plans#

make_functional(population, *, dt, extra=None, pending_capacity=None)[source]#

Lower an initialized Population or Network into explicit tensor execution.

Parameters:
  • population (Population or Network) – Initialized compatible source model. Unsupported hooks/configurations raise FunctionalizationError; lowering does not initialize or advance the source.

  • dt (float) – Positive solver timestep in ms. A Network must already use that timestep.

  • extra (stimulation specification or mapping, optional) – Extracellular field/waveform pair or contact sequence; Networks use Population-name mappings. Stimulation Tensor identities and aliases are retained in the returned source mappings.

  • pending_capacity (int or mapping, optional) – Network event-calendar capacities. Overflow raises during host execution; retry from the input boundary with a larger-capacity plan.

Returns:

  • functional (FunctionalPopulation or FunctionalNetwork) – Immutable model plan accepting explicit sources and state.

  • tensors (PopulationTensors or NetworkTensors) – Raw parameters, constants, runtime state and model-specific initialization inputs. Population raw parameters retain native Tensor references; Network extraction owns detached snapshots preserving aliases.

Return type:

tuple[FunctionalPopulation, PopulationTensors] | tuple[FunctionalNetwork, NetworkTensors]

Notes

Use tensors.independent_parameters(...) for independent optimization leaves. Bind raw sources with functional.bind(tensors) and execute with run(), or use combined preparation/transition methods inside tensor transforms. make_functional_network() is the Network-specific entry point using its initialized timestep without a separate dt argument.

make_functional_network(network, *, extra=None, pending_capacity=None)[source]#

Lower an initialized Network to a pure plan and independent Tensor snapshots.

Parameters:
  • network (Network) – Initialized single-device Network. Its initialized timestep is retained.

  • extra (mapping, optional) – Population names mapped to (field, Waveform) pairs or sequences of contacts. Omitted Populations have no bound extracellular stimulation.

  • pending_capacity (int or mapping, optional) – Positive calendar capacity, either shared across event connections or mapped by connection name. Defaults accommodate existing queued events and use at least twice each connection’s edge count where required.

Returns:

  • functional (FunctionalNetwork) – Immutable configuration plan using shared native numerical/event policies.

  • tensors (NetworkTensors) – Independent detached state, raw parameter and constant snapshots. Shared Tensor aliases are preserved across components.

Notes

Intrinsic-only packed connections without pending traffic need no calendar allocation. Calendar overflow raises at host execution boundaries; retry from the pre-call native boundary after lowering with a larger capacity. Calendar tensor shapes are fixed by each plan.

class FunctionalPopulation(population, *, dt, extra=None)[source]#

Explicit-state execution plan for a compatible initialized Population.

Create with make_functional(). The plan fixes model structure, tensor schemas and a nominal timestep; parameters, constants and evolving state are explicit arguments. Supported models include point, cable, tree and packed Populations, with deterministic or declared stochastic mechanisms.

extract() reads native sources, bind() creates a raw binding, and run() schedules it. Use prepare_and_step() or prepare_and_rollout() to keep preparation inside a compiled or transformed tensor function. Execution never redirects or advances the native Population. Unsupported model hooks or configurations raise FunctionalizationError when lowered or validated.

property shape: tuple[int, ...]#

The immutable state payload shape accepted by this plan.

property dt: float#

The default timestep used when this plan was lowered.

property dtype: dtype#

The immutable tensor dtype accepted by this plan.

property device: device#

The immutable tensor device accepted by this plan.

property intra: FunctionalIntra#

The immutable plan for registered intracellular Waveforms.

property extra: FunctionalExtra#

The immutable plan for an extra= spec bound while lowering.

prewarm_structured_rollout(*, ve=False, intra=False)[source]#

Prewarm bounded-graph inference for one optional-drive signature.

This is only needed when wrapping prepare_and_rollout() directly in a user-authored torch.compile boundary. The higher-level compile_rollout_chunk() wrapper prewarms its signature lazily. Capture failure is non-fatal and returns False; compilation then uses the semantically equivalent unrolled rollout.

make_extra(extra)[source]#

Lower the ordinary Population extra= form without mutating it.

make_callbacks(callbacks)[source]#

Bind a named mapping of callback configurations to this plan.

Accepts supported built-in Dendra callbacks and pure FunctionalCallback implementations. Returns FunctionalCallbacks for native/functional execution on compatible models. Live callback carry belongs to the returned collection; use callback export/restore to transfer carry between independently prepared collections.

extract(population=None)[source]#

Read explicit sources and state from a compatible initialized Population.

population defaults to the source used during lowering. Raw parameter Tensors retain their native identities; constants, runtime state and initialization values are snapshots. Registered stimulation leaves are included in the source mappings. Use tensors.independent_parameters(...) for owned optimization leaves, or capture_continuation() for an owned detached snapshot of the complete execution boundary.

Returns:

Parameter, constant, state and initialization-input mappings accepted by this plan. Extraction does not initialize or advance the native model.

Return type:

PopulationTensors

prepare(parameters, constants)[source]#

Materialize reusable coefficients from raw parameters and constants.

Returns an opaque plan-bound prepared value for step() and rollout(). Input identities and mutation versions are checked when it is used; changing its sources requires preparing again. Inference tensors without version counters are not accepted as preparation inputs.

Preparation records gradients under the caller’s gradient mode. Recreate it for independent training forwards. For automatic per-invocation ownership use bind(parameters, constants=constants). Inside torch.compile use prepare_and_step() or prepare_and_rollout() instead of transporting an opaque prepared value across the compiled boundary.

initialize(parameters, constants, inputs, *, state=None, random_draw=None, draws=None)[source]#

Purely initialize from declared defaults or a bound steady-state cache.

Without an owned cache, registered pure pre/post transforms consume inputs.transforms in native registration order. Network-owned plans also return their differentiable per-Population materializations in the constant frame. A bound inputs.cache restores detached saved state and materializations, skips fresh initialization hooks, and returns effective parameters and constants. Both paths reset the Population clock and duration remainder. RAND declarations consume an explicit random_draw or inputs.random_draw packet. Their retained samples and provenance accompany the returned constants; state supplies previous samples for declarations which do not resample and previous mechanism State for pre-transform reads. Without state, those reads use the State captured at lowering. inputs.states supplies insertion-time values applied after the complete pre phase. draws supplies one explicit initialization packet instead of the legacy stochastic fields. Missing families are not sampled implicitly.

sample_initialization_draw(parameters, state)[source]#

Sample owned initialization draws without changing the source or carry.

sample_stimulation_initialization_draw(state)[source]#

Sample Poisson draws for native fresh-initialization current evaluation.

sample_runtime_draws(state, *, steps=None)[source]#

Sample one canonical runtime packet without changing source or carry.

Omit steps for one accepted step, or supply a non-negative count for a time-leading tape. Named draw families share one physical RNG frame authority; initialization draws retain their separate API.

sample_stimulation_draw(state)[source]#

Sample one Poisson invocation packet from explicit generator carry.

sample_stimulation_draw_tape(state, steps)[source]#

Sample a time-first Poisson draw and generator-state tape.

sample_noise_draw(state)[source]#

Sample NOISE/SDE draws without changing the source or carry.

sample_noise_draw_tape(state, steps)[source]#

Sample a bounded time-first draw and RNG tape from an explicit carry.

initialize_host(parameters, constants, inputs, *, state=None, draws=None)[source]#

Sample missing draws at a cold boundary, or replay an explicit packet.

reset_continuous_inputs(state)[source]#

Reset every continuous receiver once and return fresh per-step scratch.

x and x_old remain ordinary Population CARRY. Scratch contains only Boolean first-delivery masks, is reset at the network step boundary, and is deliberately separate from checkpoint carry. Preserve it when pausing between deliveries within the same timestep.

rollout(parameters, prepared, state, inputs=None, *, steps=None, extra=None, callbacks=None, callback_state=None, draws=None)[source]#

Advance explicit state using a prepared Population and time-leading inputs.

parameters and prepared must match the identities/versions used by prepare(). steps selects the accepted count; supplied input/draw tapes must have that leading length. Omitted inputs retain registered stimulation. Stochastic values are explicit through draws=RuntimeDraws(...).

Returns (state, auxiliary) without mutating its inputs or native model. Named callbacks produce auxiliary["callbacks"]; pass their returned state as callback_state to continue without another initial sample. This is the explicit prepared form for eager execution and supported torch.func transforms. Use run() for duration scheduling and automatic host sampling.

prepare_and_rollout(parameters, constants, state, inputs=None, *, steps=None, extra=None, callbacks=None, callback_state=None, draws=None)[source]#

Prepare raw sources and execute an explicit Population rollout in one call.

Arguments and results follow rollout(), with raw constants replacing the opaque prepared value. Preparation belongs to this invocation, preserving its source gradients. This combined tensor operation can be used inside torch.compile or supported torch.func transforms. Draws must be explicit; use run() for host-side automatic sampling and duration scheduling.

step(parameters, prepared, state, inputs=None, *, extra=None, callbacks=None, callback_state=None, draws=None)[source]#

Advance one timestep from explicit state and one input/draw frame.

Uses the parameters and opaque value returned by prepare(). inputs is one Inputs frame; draws is one RuntimeDraws frame. Returns (state, auxiliary) using the same callback contract as rollout(), without changing native model state or supplied tensor values.

prepare_and_step(parameters, constants, state, inputs=None, *, extra=None, callbacks=None, callback_state=None, draws=None)[source]#

Prepare raw sources and advance one pure Population timestep.

This is step() with raw constants in place of an opaque prepared value. It returns (state, auxiliary) and preserves gradients through both preparation and execution. Use this combined form inside torch.compile or supported torch.func transforms; supply stochastic draws explicitly.

receive(parameters, prepared, state, *, target, payload)[source]#

Apply one ordered event, including zero payloads, without stepping.

prepare_and_receive(parameters, constants, state, *, target, payload)[source]#

Derive coefficients and apply one event atomically under compilation.

continuous_receive(parameters, prepared, state, scratch, *, target, payload, input=None, reduce='sum', mask=None)[source]#

Apply one ordered analog delivery without advancing the Population.

mask distinguishes absent scatter slots from actual zero deliveries. Return the new Population carry and scratch for the next delivery in native connection order. Reset once before the first delivery, including timesteps with no active connections.

prepare_and_continuous_receive(parameters, constants, state, scratch, *, target, payload, input=None, reduce='sum', mask=None)[source]#

Prepare coefficients and apply an analog delivery under compilation.

bind(parameters, prepared=..., *, constants=...)[source]#

Bind one eager step to raw constants or explicit preparation.

bind(parameters, constants=constants) snapshots raw mapping containers and retains live tensor leaves. Each complete forward or host run owns its preparation graph, with safe inference reuse. bind(parameters, prepared) retains an explicit prepared value; prepare and bind again for independent backward graphs in that form.

bind(tensors) or bind(continuation) selects both raw source frames from an exact matching bundle or Continuation. Packet forms cannot be combined with prepared or constants, including None. State and callback carry remain explicit operands of run.

compile_rollout_chunk(steps, *, execution='default', **compile_options)[source]#

Create a fixed-width compiled Population kernel.

Parameters:
  • steps (int) – Positive number of accepted steps in each direct kernel invocation.

  • execution ({"default", "scan", "unrolled", "while"}, default "default") – Scan supports first-order training; while is inference-only. Unrolled execution expands the fixed-width recurrence. Default selects inference looping when supported and otherwise retains the differentiable recurrence.

  • **compile_options – Options for torch.compile, including backend, fullgraph and disable.

Returns:

Bind raw sources with kernel.bind(tensors_or_continuation) and call run() for arbitrary horizons, cached shorter tails and callbacks.

Return type:

CompiledPopulationChunk

Notes

Population while kernels of at least four steps require capturable inference loops; smaller widths/tails use bounded unrolled execution. Transform and forward-AD calls use eager fallback. Higher-order reverse-mode differentiation through compiled scan/while is unsupported. Inspect execution_report() after execution to see the actual dispatch.

commit_state_(population, state)[source]#

Explicitly commit validated functional carry into a compatible model.

class FunctionalNetwork(network, *, extra=None, pending_capacity=None)[source]#

Explicit-state execution plan for a compatible initialized Network.

Create with make_functional(). The plan preserves native ordering for NetStim, continuous delivery, event delivery and Population solves. Structure, timestep, training mode and source routing are fixed; parameters, constants, delivery histories and RNG state remain explicit execution inputs.

extract() creates detached snapshots preserving shared parameter aliases. Use bind() and run() for host scheduling, or prepare_and_step()/prepare_and_rollout() for combined tensor operations. None of these advances the native Network. A compatible single-device Network supports event and continuous connections, declared stochastic mechanisms, schedules and the selected Population solvers.

extra maps Population names to extracellular field/waveform bindings. Explicit Inputs.ve cannot drive the same Population as bound extra. pending_capacity sets event-calendar capacities; overflow raises before publishing a result. Change fixed model configuration by lowering again.

Use commit_continuation_() to transfer detached sources and runtime state to a native model. The lower-level commit_state_() transfers state only and requires the native sources to match separately.

property initialization_inputs#

Independent initialization-only defaults with editable Tensor leaves.

initialize(parameters, constants, state, inputs, *, netstim_draw=None, draws=None)[source]#

Initialize current explicit parameters and carry in native order.

Population inputs and the starting clock are explicit. Existing carry supplies NetStim RNG/seeder/calendar positions; delivery and detector carry is reset. Supply an explicit NetStim initialization draw when present. A bound Network-wide cache restores detached Population materializations and connection history. Without that cache, each Population restores its own bound cache or runs fresh initialization in authored order. Shared raw writes reach later owners, while each Population retains the effective buffers and solver workspaces prepared at its own boundary. Resulting parameters and constants accompany state in NetworkTensors; keep all three for explicit continuation. draws supplies a complete InitializationDraws packet for replay instead of the legacy draw fields in inputs.

sample_initialization_draw(parameters, state, *, constants=None)[source]#

Sample one initialization packet from independent explicit RNG carry.

Supply constants when a renewal transform reads registered config buffers, including values restored by Population initialization caches.

sample_population_initialization_draws(parameters, state)[source]#

Draw Population initialization packets without changing the carry.

Assign each returned packet to its Population’s InitializationInput.random_draw before calling initialize(). Network-wide cache restoration consumes no Population draws. NetStim has its separate sample_initialization_draw() packet.

sample_population_stimulation_initialization_draws(parameters, state)[source]#

Draw replayable Population waveform-initialization packets.

Assign each packet to InitializationInput.stimulation. When model randomness shares a generator with a waveform, obtain the matching random_draw packets with sample_population_initialization_draws() from the same incoming state.

extract(network=None)[source]#

Snapshot sources and complete-boundary state from a compatible Network.

network defaults to the native source used during lowering. The returned NetworkTensors owns detached parameter, constant and state snapshots; genuine source aliases remain shared within that packet. Extraction performs no fresh initialization or accepted timestep. Use capture_continuation() when a native boundary should be returned directly as a Continuation.

prepare(parameters, constants)[source]#

Prepare reusable Population, connection, and NetStim values.

sample_step_draw(state)[source]#

Sample a replayable packet from an independent explicit RNG copy.

sample_connection_initialization_draw(parameters, constants, state, *, reinit_weights=True, reinit_delays=True)[source]#

Draw connection initialization inputs from independent explicit RNG.

The returned packet follows native connection/block order. Sampling consumes no global Torch RNG and changes none of the supplied tensors. Population/cache writes that affect distribution parameters are applied before sampling by the runner’s fresh-initialization host adapter.

make_callbacks(callbacks)[source]#

Bind qualified Network recordings or pure custom callbacks.

sample_runtime_draws(state, *, steps=None)[source]#

Sample one canonical runtime packet or time-leading draw/RNG tape.

sample_draw_tape(state, steps)[source]#

Sample replayable NetStim draw/RNG packets outside compiled code.

sample_population_noise_tapes(state, steps)[source]#

Sample per-Population NOISE draw/RNG tapes from independent carry.

Assign each returned packet to its Population’s RolloutInput.noise. NetStim has its separate sample_draw_tape() packet. Sampling follows the authored Population order and never changes the source Network or supplied state.

sample_population_stimulation_tapes(state, steps, provided=None)[source]#

Sample invocation-ordered Poisson tapes from explicit shared carry.

rollout(parameters, prepared, state, inputs=None, *, steps=None, callbacks=None, callback_state=None, draws=None)[source]#

Execute a pure horizon with per-Population inputs and explicit draws.

prepare_and_rollout(parameters, constants, state, inputs=None, *, steps=None, callbacks=None, callback_state=None, draws=None)[source]#

Derive coefficients and execute an explicit, differentiable horizon.

compile_rollout_chunk(steps, *, execution='scan', **compile_options)[source]#

Build a scan, unrolled, or inference-only shared while-loop chunk.

bind(parameters, constants=..., *, compiled_chunk=None)[source]#

Bind raw inputs for eager steps or canonical host scheduling.

Use bind(parameters, constants=constants) for the shared Population and Network binding contract. Positional constants are also supported. Tensor leaves stay live and differentiable. Network bindings retain raw constants, deriving fresh coefficients for every invocation instead of retaining graph-bearing materializations. Use chunk.bind for a compiled transition; both bindings work with dn.func.run.

bind(tensors) or bind(continuation) selects both raw source frames from an exact matching bundle or Continuation, without reading state or callback carry. Pass those explicitly to run. Packet forms cannot be combined with explicit constants, including None.

run(parameters, constants, state, inputs=None, *, steps=None, chunklength=64, checkpoint_every=None, callbacks=None, callback_state=None, draws=None, compiled_chunk=None)[source]#

Compatibility form of explicit bound Network host scheduling.

Use run(functional.bind(parameters, constants), state, ...) for the common scheduling contract. This adapter retains chunklength and its existing interaction with checkpoint_every. Returned state and aux['callbacks'].state can be passed directly to another call. Checkpoint replay retains gradients through all chunks.

step(parameters, prepared, state, *, netstim_draw=None, draws=None, inputs=None, extra=None, intra=None)[source]#

Advance one complete native-ordered timestep with reusable preparation.

prepare_and_step(parameters, constants, state, *, netstim_draw=None, draws=None, inputs=None, extra=None, intra=None)[source]#

Derive coefficients and execute one pure, fullgraph-compatible timestep.

check_overflow(state)[source]#

Reject incomplete pending calendars at an untransformed host boundary.

Compiled and transformed pure calls propagate sticky Tensor flags. Validate their returned carry here before consuming or committing it. Host rollout and compiled runners perform this check automatically.

commit_state_(network, state)[source]#

Stage and atomically publish complete runtime carry to a compatible graph.

Bindings and compiled chunks#

Bindings hold the parameter and constant sources used for execution. Compiled chunks execute a fixed step count and can be reused by the host scheduler.

class BoundPopulation(functional, parameters, prepared=..., *, constants=..., compiled_chunk=None)[source]#

A transition bound to explicit parameters and preparation inputs.

functional.bind(parameters, constants=constants) binds one eager step; the same keyword form on a compiled chunk binds its fixed-length rollout. Raw mapping containers are snapshotted while tensor identities, aliases, and autograd history remain live. Each complete invocation owns its preparation graph. Safe inference preparation can be reused while its parameter and constant bindings remain fresh.

bind(tensors) selects raw sources from an exact PopulationTensors bundle; bind(continuation) selects its effective sources. Packet forms cannot be combined with prepared or constants. They read only parameters/constants and retain no packet, state, initialization recipe or callback carry. Supply state or the continuation explicitly to run.

bind(parameters, prepared) retains explicit preparation for advanced use. Recreate that prepared binding for each independent backward graph; in-place preparation input changes retain their existing freshness errors. Replacing an entry in a caller mapping requires a new binding in either form. Reusable kernels retain neither bindings nor preparation graphs. Call run(bound, state, ...) to schedule arbitrary horizons.

Raw-bound host runs return auxiliary['continuation']. Resume with run(bound, packet, ...) when its sources match this binding’s Tensor objects. Different sources require a new raw binding. Prepared bindings and direct calls retain their explicit state/callback-carry contract.

Direct eager calls consume one Inputs frame; compiled calls consume exactly steps time-leading samples. Supply callbacks from functional.make_callbacks(...) to return results in auxiliary['callbacks']. Continue their carry with callback_state=auxiliary['callbacks'].state alongside the returned simulation state; continuation records only new samples.

property functional: FunctionalPopulation#

The lowered model plan that owns this binding.

property parameters: Mapping[str, Tensor]#

Read-only parameter mapping; its tensor leaves are not copied.

property constants#

Read-only raw constants, or None for an explicit prepared binding.

property prepared#

The explicitly supplied preparation, or None for raw bindings.

property compiled_chunk: CompiledPopulationChunk | None#

The bound fixed-width kernel, or None for an eager binding.

property steps: int#

Exact timestep count consumed by a direct invocation.

__call__(state, inputs=None, *, callbacks=None, callback_state=None, draws=None)[source]#
class BoundNetwork(functional, parameters, constants=..., *, compiled_chunk=None)[source]#

A Network transition bound to explicit parameters and raw constants.

Construct with functional.bind(parameters, constants=constants) for one step, or kernel.bind(parameters, constants=constants) for a fixed chunk. The positional bind(parameters, constants) form is also supported. Mapping containers are snapshotted; tensor leaves retain their identities, aliases, and autograd history. Replacing a caller mapping entry requires a new binding. In-place parameter changes remain live.

bind(tensors) accepts an exact NetworkTensors bundle and bind(continuation) selects its effective sources. Packet forms cannot be combined with explicit constants, including None. Only parameters and constants are read and snapshotted; state, callback carry and the packet itself remain caller-owned. Pass state or the continuation to run.

Network bindings retain raw constants rather than prepared coefficients. Each invocation derives fresh coefficients, preserving the graph lifetime of connection and NetStim parameter materialization. A reusable compiled chunk never retains the binding or its preparation graphs.

An eager direct call accepts Population-name mappings of one-step Inputs and a one-step draws= packet. Compiled bindings consume mappings with exactly steps time-leading samples. Legacy NetworkRolloutInput packets and inputs=None retain their tape convention; use inputs={} for a step with only draws. Host run(bound, state, ...) schedules arbitrary horizons and samples missing tapes in bounded spans. It returns auxiliary['continuation']; resume with run(bound, packet, ...) when the packet’s sources match this binding’s Tensor objects. Shared constant readers follow the Network’s canonical parameter sources. Different sources require an explicit new raw binding.

Direct calls accept callbacks from functional.make_callbacks(...) and return results in auxiliary['callbacks']. Supply its state as callback_state alongside the returned Network state to continue reducers and recording without repeating the boundary sample.

property functional: FunctionalNetwork#

The lowered model plan that owns this binding.

property parameters#

Read-only nested parameter mapping with live tensor leaves.

property constants#

Read-only nested raw constants with live tensor leaves.

property compiled_chunk: CompiledNetworkChunk | None#

The bound fixed-width kernel, or None for an eager binding.

property steps: int#

Exact timestep count consumed by a direct invocation.

__call__(state, inputs=None, *, callbacks=None, callback_state=None, draws=None)[source]#
class CompiledPopulationChunk(functional, *, steps, compile_options, execution='default')[source]#

Fixed-width compiled Population execution with explicit sources and state.

Construct with FunctionalPopulation.compile_rollout_chunk(). Direct calls consume exactly steps time-leading input/draw samples. Bind a tensor bundle or Continuation with kernel.bind(packet) and use run() to schedule other horizons while preserving the configured kernel width.

Scan supports first-order gradients; while is inference-only. Source schemas and prepared values are validated before execution. Kernels retain no live parameter bindings or preparation graphs. Explicit torch.func/forward-AD calls use the supported eager fallback. Use execution_report() to inspect the dispatch selected by the most recent completed call.

property steps: int#

The exact number of timesteps consumed by each invocation.

property capabilities: ExecutionCapabilities#

The immutable execution and differentiation contract for this kernel.

execution_report()[source]#

Return the last successful dispatch, including tails and replay.

Returns None before any call completes. The report covers one kernel invocation, not an entire run; checkpoint backward can replace it.

bind(parameters, prepared=..., *, constants=...)[source]#

Bind a matching tensor bundle, Continuation, or explicit raw/prepared sources.

Packet forms select only parameters/constants and cannot be combined with prepared or constants. State and callback carry remain explicit operands of dn.func.run.

__call__(parameters, prepared, state, inputs=None, *, callbacks=None, callback_state=None, draws=None)[source]#
class CompiledNetworkChunk(functional, *, steps, execution='scan', **compile_options)[source]#

Fixed-width compiled Network execution with explicit sources and state.

Construct with FunctionalNetwork.compile_rollout_chunk(). Scan supports first-order gradients, unrolled execution expands the fixed-width recurrence, and while selects inference-only looping. Direct calls consume steps time-leading samples. Bind raw sources or a tensor bundle/Continuation, then use run() for arbitrary horizons and shorter tails. Kernels retain no live input bindings or preparation graphs. execution_report() describes the most recent completed dispatch.

bind(parameters, constants=...)[source]#

Bind raw inputs with bind(parameters, constants=constants).

Positional constants remain supported. Each direct call prepares fresh values; host scheduling retains its per-span preparation boundaries. bind(tensors) or bind(continuation) selects both source frames, leaving state and callback carry explicit to run. Packet forms cannot be combined with explicit constants, including None.

property steps#

The fixed number of accepted timesteps consumed by a direct call.

property capabilities: ExecutionCapabilities#

The immutable execution and differentiation contract for this chunk.

execution_report()[source]#

Describe the latest successful dispatch, including tails and replay.

Reports contain scalar metadata only. An empty host run makes no dispatch, and checkpoint replay may replace the report during backward.

__call__(parameters, prepared, state, inputs=None, *, callbacks=None, callback_state=None, draws=None)[source]#

Tensor and input packets#

Inputs and RuntimeDraws are the common public runtime packets. The Population- and Network-specific packets below remain supported for explicit stepping and existing callers.

class PopulationTensors(parameters, constants, state, initialization)[source]#

Explicit parameter, constant, state and initialization inputs for a Population.

Native extraction retains raw parameter identities and snapshots state and constants. Fresh initialization can replace effective source entries while preserving their gradients. Use independent_parameters() to own separate optimization leaves, or inspect_sources() to inspect aliases and select deduplicated trainable leaves.

Create new instance of PopulationTensors(parameters, constants, state, initialization)

parameters: dict[str, Tensor]#

Alias for field number 0

constants: dict[str, Tensor]#

Alias for field number 1

state: dict[str, object]#

Alias for field number 2

initialization: InitializationInput#

Alias for field number 3

property trainable_parameters: dict[str, Tensor]#

Named parameter entries with live requires_grad=True flags.

Aliases and gradient-bearing nonleaf expressions remain visible. Use dn.func.inspect_sources(tensors).trainable_leaves for deduplicated leaf Tensors suitable for a PyTorch optimizer.

property model_parameters: dict[str, Tensor]#

Model-owned raw parameters, excluding stimulation leaves.

property intra_parameters: dict[str, Tensor]#

Replaceable leaves owned by registered intracellular stimulation.

property extra_parameters: dict[str, Tensor]#

Replaceable leaves owned by bound extracellular stimulation.

find_parameters(query, *, within='all')[source]#

Find parameters by substring, full-name glob, or regular expression.

Matching is case-sensitive and preserves canonical extraction order. Use re:expression or a compiled string regex for regex search. Use parameter_name() when exactly one match is required.

parameter_name(query, *, within='all')[source]#

Resolve one exact, partial, glob, or regex parameter-name match.

get_parameter(query, *, within='all')[source]#

Return the Tensor selected by one exact, partial, glob, or regex match.

independent_parameters(trainable=(), *, within='all')[source]#

Clone the complete parameter tree independently of its Population.

Exact or unique partial names select one leaf; full-name globs and re: or compiled regex selectors can select multiple leaves. Each selector must match. Selected leaves are returned as torch.nn.Parameter objects. Every other leaf is a detached ordinary Tensor. The returned mapping retains canonical names and parameter aliases, and can be passed directly to functional preparation and transitions. Selecting any alias makes its shared leaf trainable.

class NetworkTensors(parameters, constants, state)[source]#

Explicit parameters, constants and runtime state for a Network plan.

Extraction owns detached Tensor snapshots and preserves shared parameter identities across component mappings. Collection/component names match the native Network. Initialization can replace effective sources while preserving unchanged explicit leaves and their gradient history. Use inspect_sources() to inspect aliases and deduplicated optimizer leaves.

Create new instance of NetworkTensors(parameters, constants, state)

parameters: dict#

Alias for field number 0

constants: dict#

Alias for field number 1

state: dict#

Alias for field number 2

property named_parameters#

Flatten explicit leaves by canonical collection/component-qualified names.

property trainable_parameters#

Named gradient-requiring parameter entries, including aliases and nonleaves.

Use dn.func.inspect_sources(tensors).trainable_leaves for deduplicated optimizer leaves.

find_parameters(query)[source]#

Return parameter leaves matching a substring, glob, or regex query.

parameter_name(query)[source]#

Resolve one exact, partial, glob, or regex parameter-name match.

get_parameter(query)[source]#

Return the leaf selected by one unambiguous parameter query.

independent_parameters(trainable=())[source]#

Clone nested parameters with shared identities and trainable selection.

class InitializationInput(v_init, states=None, transforms=None, cache=None, random_draw=None, stimulation=None)[source]#

Population initialization values, separate from runtime inputs.

v_init is the fully expanded initial membrane voltage. states maps insertion-time initial conditions to canonical state names; shapes, dtypes and devices must match their support-local state. transforms contains explicit Tensor inputs of registered initialization transforms.

cache is a bound Population steady-state snapshot. When native cache policy permits restoration, cached state/materializations replace fresh hooks and produce effective initialized sources. Reseeding, retained samples and cache invalidation follow the model’s native initialization policy.

random_draw and stimulation are supported component draw fields. Prefer the separate draws=InitializationDraws(...) argument for complete replay; it cannot be combined with these fields. Host initialization samples missing draws automatically; pure plan initialization requires explicit stochastic inputs. These fields do not supply runtime stimulation tapes.

Create new instance of InitializationInput(v_init, states, transforms, cache, random_draw, stimulation)

v_init: Tensor#

Alias for field number 0

states: dict[str, Tensor] | None#

Alias for field number 1

transforms: dict[str, Tensor] | None#

Alias for field number 2

cache: Mapping[str, object] | None#

Alias for field number 3

random_draw: RandomParameterDraw | None#

Alias for field number 4

stimulation: StimulationDraw | None#

Alias for field number 5

class NetworkInitializationInput(populations, t, netstim_draw=None, cache=None, reinit_weights=True, reinit_delays=True, connection_draw=None)[source]#

Initialization-only Population values, starting time, and optional draw.

populations maps every authored Population name to an InitializationInput. t is a scalar Tensor matching the Network clock’s dtype and device. It is detached during initialization, matching native clock synchronization. netstim_draw is an explicit initialization packet; the host runner samples one when omitted. Step draw tapes remain separate runtime inputs. A bound Network-wide cache takes precedence over individual Population caches; otherwise each Population’s input controls its own initialization at its position in the authored order. reinit_weights and reinit_delays refresh connection materializations from their raw sources. A false flag retains the preceding explicit materialization, matching native Network initialization. Population initialization retains each owner’s effective buffers and solver workspaces separately from the final shared raw parameters in the resulting constants. connection_draw supplies parameter-independent connection base draws and resulting RNG checkpoints. Pure initialization requires this packet when refreshing supported stochastic roles; the host runner samples it after Population/cache writes. Its sampling flags must match this input.

Create new instance of NetworkInitializationInput(populations, t, netstim_draw, cache, reinit_weights, reinit_delays, connection_draw)

populations: dict[str, InitializationInput]#

Alias for field number 0

t: Tensor#

Alias for field number 1

netstim_draw: NetStimDraw | None#

Alias for field number 2

cache: NetworkInitializationCache | None#

Alias for field number 3

reinit_weights: bool#

Alias for field number 4

reinit_delays: bool#

Alias for field number 5

connection_draw: ConnectionSamplingDraw | None#

Alias for field number 6

class NetworkInitializationCache(populations, synapses, continuous_synapses)[source]#

Detached steady-state Population and normalized connection cache values.

Population entries use the native state-dict names. Connection entries are Tensor-only packets normalized for the plan’s fixed topology and timestep. Cache leaves are independent editable initialization inputs, not runtime checkpoints; restoration does not differentiate through the warm-up run.

Create new instance of NetworkInitializationCache(populations, synapses, continuous_synapses)

populations: Mapping#

Alias for field number 0

synapses: Mapping#

Alias for field number 1

continuous_synapses: Mapping#

Alias for field number 2

class StepInput(ve=None, intra=None, noise=None, stimulation=None)[source]#

Assembled voltage/current inputs and explicit stochastic draw packets.

Inputs supplies deterministic frames and RuntimeDraws supplies stochastic values through draws=. This combined packet remains supported with its separate noise and stimulation fields.

Create new instance of StepInput(ve, intra, noise, stimulation)

ve: Tensor | None#

Alias for field number 0

intra: Tensor | None#

Alias for field number 1

noise: RuntimeNoiseDraw | None#

Alias for field number 2

stimulation: StimulationDraw | None#

Alias for field number 3

class RolloutInput(ve=None, intra=None, noise=None, stimulation=None)[source]#

Time-first voltage/current inputs and explicit stochastic draw/RNG tapes.

Inputs supplies deterministic tapes and RuntimeDraws supplies stochastic values through draws=. This combined packet remains supported with its separate noise and stimulation fields.

Create new instance of RolloutInput(ve, intra, noise, stimulation)

ve: Tensor | None#

Alias for field number 0

intra: Tensor | None#

Alias for field number 1

noise: RuntimeNoiseDraw | None#

Alias for field number 2

stimulation: StimulationDraw | None#

Alias for field number 3

class NetworkRolloutInput(populations=None, netstim=None)[source]#

Time-leading per-Population inputs and explicit stochastic draw tapes.

Network execution accepts a mapping from Population names to Inputs and a separate RuntimeDraws packet through draws=. This combined packet remains supported for callers using its component-specific fields.

populations maps names to RolloutInput, including each Population’s noise and stimulation draw/RNG tapes. netstim is a NetStimDraw whose two Tensor fields have one leading time axis. Keep draw values and their matching post-draw RNG bytes together. Pure rollout/chunk calls require tapes for recurrent NOISE, stimulation and NetStim; the host run scheduler can sample bounded tapes from explicit carry.

Create new instance of NetworkRolloutInput(populations, netstim)

populations: Mapping[str, RolloutInput] | None#

Alias for field number 0

netstim: NetStimDraw | None#

Alias for field number 1

class RandomParameterDraw(draws, rng)[source]#

RAND/NOISE initialization draws and resulting shared stream states.

Create new instance of RandomParameterDraw(draws, rng)

draws: dict[str, Tensor]#

Alias for field number 0

rng: dict[str, dict[str, Tensor]]#

Alias for field number 1

class RuntimeNoiseDraw(draws, rng)[source]#

Detached NOISE/State SDE draws and resulting shared stream states.

Create new instance of RuntimeNoiseDraw(draws, rng)

draws: dict[str, Tensor]#

Alias for field number 0

rng: dict[str, dict[str, Tensor]]#

Alias for field number 1

class StimulationDraw(draws, rng)[source]#

Detached Poisson draws and resulting generator-state bytes.

Each registration uses an event vector for one invocation, or an invocation-by-event matrix for a repeated evaluation. Rollout packets prepend the timestep axis. Sampling helpers supply the fixed schema bound by the Population or Network’s initialization and runtime profiles.

Create new instance of StimulationDraw(draws, rng)

draws: dict[str, Tensor]#

Alias for field number 0

rng: dict[str, Tensor]#

Alias for field number 1

class ConnectionSamplingDraw(values, rng)[source]#

Parameter-independent base draws and resulting generator checkpoints.

values maps synapses and continuous_synapses to authored connection names, then weights/delays to stochastic block indices. rng maps canonical draw-device names to CPU generator-state byte vectors. Draws and generator states are detached initialization inputs.

Create new instance of ConnectionSamplingDraw(values, rng)

values: Mapping#

Alias for field number 0

rng: Mapping#

Alias for field number 1

Connections and event generators#

These plans expose shared delivery and renewal phases for applications that assemble their own functional networks. Ordinary Network lowering builds them from native connection objects.

make_functional_netcon(netcon, *, pending_capacity=None)[source]#

Return an explicit event-projection plan and independent Tensor snapshot.

netcon must be initialized. Optional pending_capacity sets bounded calendar capacity. The result is (FunctionalNetCon, NetConTensors); complete Network lowering constructs these projections automatically.

make_functional_netstim(source)[source]#

Return a pure renewal plan and independent state/parameter snapshots.

source is an initialized NetStim with its timestep/schedules configured. Returns (FunctionalNetStim, NetStimTensors). Initialization and step draws remain explicit; full Network lowering binds this component automatically.

make_functional_continuous_con(con)[source]#

Return an explicit continuous projection and independent Tensor snapshot.

con must be an initialized compatible ContinuousCon. Returns (FunctionalContinuousCon, ContinuousConTensors). Routing, delay quantization and stateless transform configuration are fixed; transform Tensor parameters remain explicit. Network lowering constructs these projections automatically.

class FunctionalNetCon(netcon, *, pending_capacity=None)[source]#

Explicit event projection using the initialized native NetCon policy.

Normally FunctionalNetwork constructs and orders these projections. For explicit composition, supply full source-shaped values using source_dtype/source_device and per-edge weights using target dtype/device. Differentiable delays are explicit per-edge milliseconds; their initialized two-/three-tap policy and capacity remain fixed. Threshold detectors retain native hard/surrogate semantics.

Preserve receive-before-observe order: call read_due, deliver its payload with a Population receive operation, then observe the source and advance. step combines phases when source values are already chosen. Projection methods do not advance a Population clock. Tensor schedule values are supplied as TensorScheduleTensors; routing/source indices remain fixed.

Transport follows the selected native backend: source-history delivery reads current weights/delays, while queued weighted payloads retain enqueue-time values. Fixed routing, timestep, thresholds, mode, schedule topology and capacity require lowering again when changed. Runtime state is explicit and extraction owns detached snapshots. Direct low-level loops must call check_overflow before using results from a bounded pending calendar.

property runtime#

Frozen native transport runtime.

property pending_capacity#

Maximum entries per pending calendar, or None for other runtimes.

Intrinsic-only packed plans with no imported pending traffic use zero entries by default and skip calendar transport. Other defaults use the largest of existing checkpoint traffic, twice the connection count, and sixteen entries. An explicit positive pending_capacity overrides either default. Increase it when lowering if traffic can accumulate.

check_overflow(state)[source]#

Raise on pending overflow; transformed calls retain explicit status.

Pure transitions expose sticky pending_overflow and, for tracked sparse projections, event_pending_overflow tensors. An overflow invalidates that invocation. Restart from an earlier checkpoint with a larger pending_capacity rather than continuing its returned carry. Host checks accept stacked or vmap outputs with leading batch axes and reject overflow in any lane, including nested batches.

extract(netcon=None)[source]#

Snapshot effective parameters, checkpoint carry, and schedule values.

initial_state(state, *, t)[source]#

Clear delivery/detector carry at finite scalar starting time t.

Routing and scheduled events are unchanged. The absolute schedule counter uses native NetCon rounding; all returned carry is detached, matching native initialization without weight or delay resampling.

normalize_cache(cache)[source]#

Own a detached steady-state cache at the lowered dt and topology.

restore_cache(parameters, state, cache, *, t)[source]#

Restore detached steady-state history using explicit current parameters.

read_due(state, *, weights=None, delays=None)[source]#

Return (delivery_state, payload) for one separate receive call.

This publishes due tracked events in the returned state without clearing the queue or changing the detector latch, ring slot, or global step. Compact-history plans require current weights because native delivery reconstructs traffic from past source gates at delivery time. Training with differentiable delays also requires current delays. Bitpacked inference publishes its scratch payload in the returned carry, including zero deliveries, without changing the input state.

advance(weights, state, source_values, *, delays=None, schedule=None)[source]#

Observe the source, update transport history, and return next carry.

Pass the state from read_due() after delivering its payload and observing the source. Threshold metadata is frozen; gradients flow through explicit weights, source values, pending payloads, and schedule amplitudes. Triangular scheduling also differentiates explicit times. Interpolated-delay plans require explicit delays; fixed-delay plans reject it. Delay values use the native fixed ring and are not scanned for a range on each step.

step(weights, state, source_gates, *, delays=None, schedule=None)[source]#

Return (next_state, due_payload) using prechosen source values.

source_gates retains its original argument name for callers using explicit raw gates; finite thresholds interpret it as source values. Use the separate phases when reception can change those values.

commit_state_(netcon, state)[source]#

Commit independent copies of validated carry into a compatible NetCon.

This restores queues, counters, detector history, and tracked events. Align effective weights, delays, and floating schedule values separately when resuming native execution; they are parameters rather than carry.

class FunctionalNetStim(source)[source]#

A pure renewal plan with explicit random draws and checkpointable RNG.

Lower an initialized NetStim with optional heap and tensor schedules. Effective interval, start, noise, and tau use the full native state shape; max_spikes is an explicit integer constant. Parameters are independent leaf snapshots, so gradients never reach the source module.

step() calls the same pure transition as native NetStim. Draw one packet with sample_step_draw() outside transformed/compiled code, then pass it into the step. Every native forward consumes one full-shape draw, including deterministic generators and calls that emit no spikes. RNG byte state travels with clock carry, while sampling remains outside the hot graph. bptt=False detaches the renewed clock as native execution does; emitted surrogate gates retain their current-step gradients.

initial_state() resets clocks using an explicit initialization packet. Its cold sampler reseeds when the lowered native NetStim has a fixed seed; with seed=None it continues the supplied state’s RNG stream. A fully deterministic initialization consumes no draw. Initialization clocks are detached, matching native initialization.

Configuration changes require lowering again. Runtime carry changes do not invalidate a plan. commit_state_() transfers clocks and both RNG states without changing native parameters or constants; those must match explicit values when continuing the same trajectory natively. Tensor schedule values are explicit in TensorScheduleTensors; routing and source indices are frozen at lowering, along with schedule_dt. Set the native timestep before lowering. Heap calendars use non-differentiable times (Float64 on CPU/CUDA, simulation dtype on MPS) and CSR row offsets in constants. Their absolute per-row cursors and any legacy head-only override belong to explicit carry. Calendar topology is fixed; changing it requires lowering again. Initialization preserves consumed cursors and clears legacy head overrides, matching native initialization.

extract(source=None)[source]#

Snapshot effective values and replayable carry without source mutation.

sample_step_draw(state)[source]#

Draw once from an independent copy of the explicit RNG state.

sample_initialization_draw(parameters, state)[source]#

Match native initialization’s reseeding and conditional draw policy.

initial_state(parameters, constants, state, draw)[source]#

Reset clocks/RNG, preserving consumed cursors and clearing legacy heads.

step(parameters, constants, state, t, draw, *, bptt=False, schedule=None)[source]#

Return next clock/RNG carry and hard/surrogate outputs for time t.

A plan with tensor events or bound sources requires an explicit schedule packet. Event values may change; routing and source-index maps retain the topology captured at lowering.

commit_state_(source, state)[source]#

Transfer validated clocks, RNG, and cursors to a compatible native NetStim.

Native training restores retain the incoming clock’s autograd history; evaluation restores detach the clock, clearing any prior native history. Schedule values and bound sources are left as configured on source; align them with the explicit packet before continuing a changed schedule.

class FunctionalContinuousCon(con)[source]#

Frozen zero/integer-delay routing with explicit values and presence masks.

advance(weights, state, source_values) returns (next_state, payload, mask). Source values have the complete presynaptic stored tensor shape; weights have one target-dtype value per edge. Transform values are explicit in transform_parameters using ordinary module parameter/buffer names. Stateless functions and modules use their same native callable; static Python configuration is frozen, while explicit tensor values may change.

Native observation order is represented by receive_before_source. When true, call read_due(state), deliver that payload/mask, then observe the source and call advance; do not deliver its returned payload a second time. Otherwise observe the source first, call advance, and deliver the combined immediate/due payload once. Empty plans have has_connections false and do not call the receiver. Reset each target once before visiting its projections in native order. No method advances a Population clock.

Delay quantization, capacity, routing, input, reduction, and source schemas are fixed. Native reinitialization or configuration changes require lowering again. Runtime queue snapshots preserve enqueue-time values and gradients; extraction creates independent detached carry. commit_state_ transfers runtime carry only; align weights/transform parameters separately before native continuation. Detached steady-state caches remain a separate API.

extract(con=None)[source]#

Extract independent parameter leaves and detached runtime carry.

initial_state(state, *, t)[source]#

Clear payload/presence rings at finite scalar starting time t.

The absolute counter retains native target-dtype rounding. Reset carry is detached; transform parameters, weights, and routing are unchanged.

normalize_cache(cache)[source]#

Own and resample native cache rows to this frozen routing/timestep.

The returned Tensor/None packet keeps raw and legacy transformed histories distinct. Cache construction is a cold operation; pass the normalized packet into transformed or compiled initialization.

restore_cache(parameters, state, cache, *, t)[source]#

Restore detached traffic with current explicit weights/transform.

parameters contains weights and transform_parameters as in the low-level ContinuousCon projection API. Historical observations and materialized runtime carry are detached, matching native steady-state restoration.

read_due(state)[source]#

Read queued payload/presence without mutation or counter advancement.

advance(weights, state, source_values, *, transform_parameters=None)[source]#

Project explicit source values and return next carry, payload, and mask.

commit_state_(con, state)[source]#

Restore independent runtime carry without changing model parameters.

class NetConTensors(weights, state, schedule=None, delays=None)[source]#

Independent effective parameters, transport carry, and schedule values.

delays contains effective milliseconds for differentiable-delay plans; fixed-delay plans store None. Weights and delays are parameters rather than checkpoint carry.

Create new instance of NetConTensors(weights, state, schedule, delays)

weights: Tensor#

Alias for field number 0

state: dict[str, Tensor]#

Alias for field number 1

schedule: TensorScheduleTensors | None#

Alias for field number 2

delays: Tensor | None#

Alias for field number 3

class NetStimTensors(parameters, constants, state, schedule=None)[source]#

Independent parameters, calendar constants, and clock/RNG/cursor snapshots.

Create new instance of NetStimTensors(parameters, constants, state, schedule)

parameters: dict[str, Tensor]#

Alias for field number 0

constants: dict[str, Tensor]#

Alias for field number 1

state: dict[str, Tensor]#

Alias for field number 2

schedule: TensorScheduleTensors | None#

Alias for field number 3

class ContinuousConTensors(weights, state, transform_parameters=None)[source]#

Independent effective weights, runtime carry, and transform parameters.

Create new instance of ContinuousConTensors(weights, state, transform_parameters)

weights: Tensor#

Alias for field number 0

state: dict[str, Tensor]#

Alias for field number 1

transform_parameters: dict[str, Tensor] | None#

Alias for field number 2

class NetStimDraw(exp_rand, rng_state)[source]#

An exponential draw and its matching post-draw generator byte state.

Sampling helpers produce replayable packets without touching the native NetStim or the input state. Keep the two fields together: manually supplied draws are accepted, but their RNG provenance cannot be inferred from values.

Create new instance of NetStimDraw(exp_rand, rng_state)

exp_rand: Tensor#

Alias for field number 0

rng_state: Tensor#

Alias for field number 1

class NetStimOutputs(spikes, spike_gate)[source]#

Hard boolean spikes and their differentiable straight-through gates.

Create new instance of NetStimOutputs(spikes, spike_gate)

spikes: Tensor#

Alias for field number 0

spike_gate: Tensor#

Alias for field number 1

class TensorScheduleTensors(times, amplitudes, time_source=None, amplitude_source=None)[source]#

Explicit event values and optional bound source vectors.

times and amplitudes are independent, per-event floating snapshots. Bound source snapshots retain their native dtype and shape. Fixed event routing and source indices belong to the lowered plan, rather than carry.

Create new instance of TensorScheduleTensors(times, amplitudes, time_source, amplitude_source)

times: Tensor#

Alias for field number 0

amplitudes: Tensor#

Alias for field number 1

time_source: Tensor | None#

Alias for field number 2

amplitude_source: Tensor | None#

Alias for field number 3

Stimulation plans#

class FunctionalIntra(population)[source]#

Pure plan for solver-owned model[slice].inject(waveform) specs.

Mechanism-owned injections are deliberately excluded: their effect belongs in functional mechanism lowering. An instance is always constructible; enabled is false and assemble() returns None when no solver-owned injection is registered.

property enabled: bool#
property layout_signature: tuple[Any, ...]#

Read-only injection topology and Waveform recipe contract.

is_compatible(other)[source]#

Whether other can supply leaves to this execution plan.

extract(population=None)[source]#
assemble(parameters, constants, times)[source]#

Assemble a contiguous [time, *population.shape] current.

assemble_values(parameters, constants, times)[source]#

Tensor-only lowering used inside compiled functional transitions.

The caller must provide already validated plan-local mappings and a one-dimensional time tensor on this plan’s device/dtype.

assemble_tensors(tensors, times, **assemble_kwargs)#

Token-check a bundle and assemble its complete time-first drive.

property batch_shape: tuple[int, ...]#
property constant_names: tuple[str, ...]#
property constant_schema: dict[str, TensorSchema]#
property device: device#
property dtype: dtype#
property parameter_names: tuple[str, ...]#
property parameter_schema: dict[str, TensorSchema]#
property plan_token: object#
replace(tensors=None, *, parameters=None, constants=None)#

Return a checked plan-bound bundle with partial leaf replacements.

property shape: tuple[int, ...]#
validate(tensors)#
class FunctionalExtra(population, extra, *, namespace='')[source]#

Pure lowering of Population’s existing raw ExtraSpec syntax.

Construct with FunctionalExtra(population, extra) or through FunctionalPopulation.make_extra(extra). Spatial fields and tensor temporal specifications are exposed as contacts.* constants; Waveform leaves use waveforms.*. extra=None creates a disabled always-present plan.

property enabled: bool#
property multicontact: bool#
property uses_waveforms: bool#
extract()[source]#
assemble(parameters, constants, times, *, temporal_slice=None, total_steps=None)[source]#

Assemble contiguous extracellular voltage [time, *shape].

assemble_values(parameters, constants, times, *, temporal_slice=None)[source]#

Tensor-only extracellular lowering for compiled transitions.

For tensor-temporal specs, temporal_slice=(start, stop) selects a host-resolved contiguous chunk from each globally bound time tensor.

assemble_tensors(tensors, times, **assemble_kwargs)#

Token-check a bundle and assemble its complete time-first drive.

property batch_shape: tuple[int, ...]#
property constant_names: tuple[str, ...]#
property constant_schema: dict[str, TensorSchema]#
property device: device#
property dtype: dtype#
property parameter_names: tuple[str, ...]#
property parameter_schema: dict[str, TensorSchema]#
property plan_token: object#
replace(tensors=None, *, parameters=None, constants=None)#

Return a checked plan-bound bundle with partial leaf replacements.

property shape: tuple[int, ...]#
validate(tensors)#
class StimulusTensors[source]#

Plan-bound explicit tensor leaves for one functional stimulus.

Use FunctionalIntra.replace() or FunctionalExtra.replace() for checked partial replacement. The bundle is a registered PyTorch PyTree: parameters and constants contain its tensor children, while the intentionally opaque plan token is static structural context that prevents bundles from two different plans from being confused.

property plan_token: object#

Opaque identity of the plan that produced this bundle.