Parameters and random distributions#
Raw PyTorch parameters, constrained parameter modules, and registered PyTorch parametrizations work in native and functional execution. See Train models and select parameters for selecting trainable sources, parameter sharing, and optimizer examples.
Constrained parameters#
- class Bounded(init, *, min_val=None, max_val=None, beta=1.0, threshold=20.0, lower_mode='softplus', lower_alpha=0.1, cap_mode='auto', cap_beta=None, requires_grad=None)[source]#
Trainable tensor constrained by optional lower and upper bounds.
- Parameters:
init (array_like) – Initial constrained value. The raw parameter
rhois initialized by inverting the selected transform.min_val (float, optional) – Lower bound. When
None, no lower constraint is enforced.max_val (float, optional) – Upper bound. When
None, no upper constraint is enforced.beta (float, optional) – Sharpness parameter used by softplus or sigmoid transforms.
threshold (float, optional) – Softplus threshold used for numerical stability.
lower_mode ({'softplus', 'hard-ste', 'leaky-ste'}, optional) – Strategy for enforcing the lower bound.
lower_alpha (float, optional) – Surrogate slope used in
'leaky-ste'mode below the bound.cap_mode ({'auto', 'softcap', 'sigmoid', 'hard-ste'}, optional) – Strategy for enforcing the upper bound.
cap_beta (float, optional) – Softcap temperature. Defaults to
betawhenNone.requires_grad (bool or None, optional) – Whether the raw parameter tracks gradients.
Noneuses theREQUIRE_GRADcontext setting.
Notes
cap_mode='auto'selects'softcap'when only an upper bound exists and'sigmoid'when both bounds are present.- set(value)[source]#
Set the parameter value directly, bypassing the unconstrained
rho.- Parameters:
value (array_like) – New value for the parameter, which will be clamped to the valid range.
- clear_cache()#
Invalidate the stored forward result.
- class PositiveParam(init, *, include_zero=False, max_val=None, beta=1.0, threshold=20.0, lower_alpha=0.1, cap_mode='auto', cap_beta=None, requires_grad=None)[source]#
Bounded parameter constrained to non-negative values.
- Parameters:
init (array_like) – Initial value for the parameter.
include_zero (bool, optional) – If True, make the zero bound inclusive using a leaky STE transform.
max_val (float, optional) – Optional upper bound.
beta (float, optional) – Softplus/sigmoid sharpness parameter.
threshold (float, optional) – Softplus threshold for numerical stability.
lower_alpha (float, optional) – Surrogate slope below zero when
include_zerois True.cap_mode ({'auto', 'softcap', 'sigmoid', 'hard-ste'}, optional) – Strategy for the optional upper bound.
cap_beta (float, optional) – Softcap temperature. Defaults to
betawhenNone.requires_grad (bool or None, optional) – Whether the raw parameter tracks gradients.
Noneuses theREQUIRE_GRADcontext setting.
- batch(n)#
Add a leading batch axis before optimizers are constructed.
- clear_cache()#
Invalidate the stored forward result.
- repeat_and_reinit(n)#
Repeat along a new leading axis before optimizers are constructed.
- set(value)#
Set the parameter value directly, bypassing the unconstrained
rho.- Parameters:
value (array_like) – New value for the parameter, which will be clamped to the valid range.
- class NegativeParam(init, *, include_zero=False, min_val=None, beta=1.0, threshold=20.0, upper_alpha=0.1, cap_mode='auto', cap_beta=None, requires_grad=None)[source]#
Bounded parameter constrained to non-positive values.
- Parameters:
init (array_like) – Initial value for the parameter.
include_zero (bool, optional) – If True, make the zero bound inclusive using a leaky STE transform.
min_val (float, optional) – Optional lower bound (must be negative when provided).
beta (float, optional) – Softplus/sigmoid sharpness parameter.
threshold (float, optional) – Softplus threshold for numerical stability.
upper_alpha (float, optional) – Surrogate slope above zero when
include_zerois True.cap_mode ({'auto', 'softcap', 'sigmoid', 'hard-ste'}, optional) – Strategy for the optional lower bound.
cap_beta (float, optional) – Softcap temperature. Defaults to
betawhenNone.requires_grad (bool or None, optional) – Whether the raw parameter tracks gradients.
Noneuses theREQUIRE_GRADcontext setting.
- batch(n)#
Add a leading batch axis before optimizers are constructed.
- clear_cache()#
Invalidate the stored forward result.
- repeat_and_reinit(n)#
Repeat along a new leading axis before optimizers are constructed.
- set(value)#
Set the parameter value directly, bypassing the unconstrained
rho.- Parameters:
value (array_like) – New value for the parameter, which will be clamped to the valid range.
Parameter declarations#
Mechanisms and MaterialProcesses inherit these declarations. GLOBAL values
are shared; BATCH values vary over population rows; RANGE values vary
over sites. Their P and N variants constrain signs. RAND values are
sampled during initialization; NOISE values are detached runtime samples.
TABLE creates an interpolated lookup for a named method.
- class SimpleParameterized(**kwargs)[source]#
Mixin that manages a flat set of named parameters for subclasses.
Declare parameters with
PARAMETER()at class definition time; instances receive automatic instantiation of buffers or modules viato_param().- classmethod all_parameter_names()[source]#
Get all declared parameter names for the class.
- Returns:
Mapping from parameter names to default values.
- Return type:
dict
- static PARAMETER(**kwargs)[source]#
Declare parameters for the next subclass initialization.
- Parameters:
**kwargs – Parameter names with default values. These are per-instance and flattened (no shape metadata); use
Parameterizedfor GLOBAL/RANGE/RNG categories when population-aware shapes are needed.
- static PARAMETERP(**kwargs)[source]#
Declare positive parameters for the next subclass initialization.
- Parameters:
**kwargs – Parameter names with default values. These are per-instance and flattened (no shape metadata); use
Parameterizedfor GLOBAL/RANGE/RNG categories when population-aware shapes are needed.
- static FLAG(**kwargs)[source]#
Declare flags for the next subclass initialization.
- Parameters:
**kwargs – Flag names with default boolean values.
- class Parameterized(shape, shape_f, additional_parameters=None, *, device=None, dtype=None, **kwargs)[source]#
A base class that allows subclasses to declare parameters which are automatically inherited and aggregated.
Use uppercase classmethods at definition time:
GLOBAL: shared scalar parameters (broadcast across compartments).BATCH: parameters with shapeshape_p[:-1] + (1,)so they broadcast across the final compartment dimension.RANGE: per-compartment parameters (shaped likeshape_p).PARAMETER: flat per-instance parameters fromSimpleParameterized.RNG: declare RNG seeds/generators to be instantiated.
Subclasses (e.g.,
Mechanism,State) build on these declarations and expose additional lifecycle hooks.- static GLOBAL(**kwargs)[source]#
Declare scalar (compartment-independent) parameters.
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated once per instance and broadcast across compartments.
- static GLOBALP(**kwargs)[source]#
Declare scalar (compartment-independent) strictly positive parameters.
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated once per instance and broadcast across compartments.
- static GLOBALN(**kwargs)[source]#
Declare scalar (compartment-independent) strictly negative parameters.
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated once per instance and broadcast across compartments.
- static GLOBAL_SIGNED(**kwargs)[source]#
Declare scalar (compartment-independent) signed parameters.
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated once per instance and broadcast across compartments.
- static RANGE(**kwargs)[source]#
Declare per-compartment parameters (range variables).
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated with shape matching the population
shape_p.
- static RANGEP(**kwargs)[source]#
Declare per-compartment strictly positive parameters (range variables).
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated with shape matching the population
shape_p.
- static RANGEN(**kwargs)[source]#
Declare per-compartment strictly negative parameters (range variables).
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated with shape matching the population
shape_p.
- static BATCH(**kwargs)[source]#
Declare parameters that broadcast over the final compartment dimension.
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated with shape
shape_p[:-1] + (1,).
- static BATCHP(**kwargs)[source]#
Declare strictly positive parameters that broadcast over compartments.
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated with shape
shape_p[:-1] + (1,).
- static BATCHN(**kwargs)[source]#
Declare strictly negative parameters that broadcast over compartments.
- Parameters:
**kwargs – Mapping of parameter name to default value. Values are instantiated with shape
shape_p[:-1] + (1,).
- static GLOBALRAND(name, *, distribution='normal', resample_on_initialize=True, seed=None, reparameterized=True, rng_name=None, reseed_on_initialize=False, **distribution_parameters)[source]#
Declare a sampled scalar buffer with parametric distribution parameters.
- static RANGERAND(name, *, distribution='normal', resample_on_initialize=True, seed=None, reparameterized=True, rng_name=None, reseed_on_initialize=False, **distribution_parameters)[source]#
Declare a sampled per-compartment buffer.
Distribution parameters are exposed as ordinary RANGE parameters named
<name>_<distribution_parameter>. For example,RANGERAND('rvar', distribution='normal', mu=0, sigma=1)declares a sampled bufferrvarplusrvar_muand positivervar_sigmarange parameters that can be locally overridden at insertion time.
- static BATCHRAND(name, *, distribution='normal', resample_on_initialize=True, seed=None, reparameterized=True, rng_name=None, reseed_on_initialize=False, **distribution_parameters)[source]#
Declare a sampled buffer with BATCH-shaped distribution parameters.
- static GLOBALNOISE(name, *, distribution='normal', seed=None, rng_name=None, cadence='step', phase='pre_state', scale='standard', **distribution_parameters)[source]#
Declare a detached scalar runtime-noise buffer.
Runtime noise is resampled in-place during simulation and does not preserve gradients through its distribution parameters.
- static RANGENOISE(name, *, distribution='normal', seed=None, rng_name=None, cadence='step', phase='pre_state', scale='standard', **distribution_parameters)[source]#
Declare a detached per-compartment runtime-noise buffer.
- static BATCHNOISE(name, *, distribution='normal', seed=None, rng_name=None, cadence='step', phase='pre_state', scale='standard', **distribution_parameters)[source]#
Declare a detached runtime-noise buffer with BATCH shape.
- static RNG(*args, **kwargs)[source]#
Declare RNG identifiers to instantiate device-local generators. May supply initial seed values via keyword arguments.
- Parameters:
*args (str) – Names of RNG streams to create. Instances receive generator buffers accessible via these names. No initial seed is set.
**kwargs (str -> int) – Mapping of RNG stream names to initial seed values. Instances receive generator buffers initialized with the specified seeds.
- static TABLE(func, low, high, n, learnable=False)[source]#
Declare a lookup table to be created for the instance. The table maps inputs in [low, high] to outputs of the named function.
This automatically creates a flag
usetable_<func>that can be used to enable or disable table usage at runtime. By default, table usage is enabled, and can be disabled by setting the flag to False. Interpolation tables can be disabled for an entire State / Mechanism by using .usetables(False).This does not require any modification of the State / Mechanism implementation (beyond the TABLE declaration); internally, Dendra will check the flag and use the table when enabled whenever the State / Mechanism calls
func(within, e.g.,assigned_values).In practice, this can speed up repeated evaluations of expensive functions, but for simple functions the overhead of the table lookup may outweigh the benefits. May also be useful to optimize functions without assuming a specific functional form (besides that used for table initialization).
- Parameters:
func (str) – Name of the function to tabulate (e.g., ‘exp’, ‘sigmoid’). This must correspond to a method that belongs to the Parameterized class and can be called with a single argument (i.e., can be called as
self.func(x)).low (float) – Lower bound of the tabulation range.
high (float) – Upper bound of the tabulation range.
n (int) – Number of points in the table.
learnable (bool, optional) – If True, the table values are trainable parameters. Defaults to False.
- resample_random_parameters(*names, force=True)[source]#
Regenerate sampled random-parameter buffers.
- resample_runtime_noise(*names, dt=None, phase=None)[source]#
Explicitly resample detached runtime-noise buffers.
- parameters_dict(clone=True, trainable_only=False)[source]#
Returns a dictionary of all parameters in the model.
- load_parameters_dict(parameters, strict=True)[source]#
Load parameters from a dictionary.
- Parameters:
parameters (dict) – Mapping of parameter names to tensors. The tensors are copied into the model’s parameters.
strict (bool, optional) – If True, raises an error if a parameter in the model is not found in the dictionary.
Distribution specifications#
Runtime noise does not propagate gradients through distribution parameters.
For differentiable stochastic state dynamics, declare State.DIFFUSION
with euler_maruyama or euler_heun. See
Custom models and explicit functional execution and Stimulation, input tapes and randomness.
- class RandomParameterSpec(name, scope, distribution, params, constraints, resample_on_initialize=True, seed=None, reparameterized=True, rng_name=None, reseed_on_initialize=False)[source]#
Specification for a sampled, usually initialization-time, parameter buffer.
- class RuntimeNoiseSpec(name, scope, distribution, params, constraints, seed=None, rng_name=None, cadence='step', phase='pre_state', scale='standard')[source]#
Specification for a detached runtime-noise buffer.
Runtime noise is intended for stochastic drives in mechanisms/states during simulation. Samples are written into stable buffers in-place under
torch.no_grad()by Dendra’s fast path, so gradients do not flow through the distribution parameters. For differentiable stochastic state dynamics, prefer first-class State SDE support viaState.DIFFUSIONand an SDE integration method.
- class DistributionSpec(name, parameter_defaults, parameter_constraints, sampler, draw_sampler=None, transform=None)[source]#
Registered random distribution.
- Parameters:
name (str) – Canonical distribution name.
parameter_defaults (Mapping[str, object]) – Default scalar/tensor values for each distribution parameter.
parameter_constraints (Mapping[str, str]) – Mapping from parameter names to Dendra parameter constraints. Supported constraints are
"real","positive", and"negative".sampler (collections.abc.Callable[[...], torch.Tensor]) – Callable with signature
sampler(parameters, rng, shape, *, device, dtype). The sampler must return a tensor broadcastable toshape.draw_sampler (collections.abc.Callable | None) – Optional
draw_sampler(rng, shape, *, device, dtype)producing a Tensor tree of parameter-independent base draws.transform (collections.abc.Callable | None) – Optional pure
transform(parameters, draw)converting those base draws to samples. Both split hooks are required together. Native sampling uses the split hooks when provided; legacy-only samplers remain available for imperative execution.
- register_random_distribution(name, parameter_defaults, parameter_constraints=None, sampler=None, *, overwrite=False, draw_sampler=None, transform=None)[source]#
Register a distribution for RAND/NOISE declarations.
samplerreceives tensor-valued distribution parameters after all Dendra overrides and parametrizations have been applied, plus a DendraRNGModule.
- make_random_parameter_spec(name, *, scope, distribution='normal', resample_on_initialize=True, seed=None, reparameterized=True, rng_name=None, reseed_on_initialize=False, **distribution_parameters)[source]#
Construct and validate a quenched random-parameter declaration.
- make_runtime_noise_spec(name, *, scope, distribution='normal', seed=None, rng_name=None, cadence='step', phase='pre_state', scale='standard', **distribution_parameters)[source]#
Construct and validate a detached runtime-noise declaration.
Trainable module controls#
Population, Network, and other model modules inherit these native selection
helpers. Source reports provide glob/regex selection and full alias groups
across native and functional models; see dendra.func.inspect_sources().
- class DNModule(*args, **kwargs)[source]#
Base class for modular neuron model components.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- unfreeze(*names, exclude=None)[source]#
Unfreezes model parameters, making them trainable.
If no names are provided, all parameters will be unfrozen. If names are provided, only parameters whose names match any of the provided patterns will be unfrozen.
- Parameters:
*names (str) – Variable length argument list of parameter name patterns. If empty, all parameters will be unfrozen. Otherwise, only parameters matching any of these patterns will be unfrozen.
exclude (Iterable[str], optional) – Optional collection of name patterns to exclude from unfreezing. If provided, any parameter whose name matches any of these patterns will not be unfrozen, even if it matches a pattern in names.
Notes
The matching is done using the matches_any_pattern function. When a parameter is unfrozen, a message is printed to the console.
- Returns:
The module instance for chaining.
- Return type:
- unfreeze_(*names)[source]#
In-place alias of
unfreeze().- Parameters:
*names (str) – Optional name patterns forwarded to
unfreeze().
- freeze(*names, exclude=None)[source]#
Freeze parameters to disable gradient computation.
- Parameters:
*names (str) – Optional name patterns selecting parameters to freeze. When omitted, all parameters are frozen.
exclude (Iterable[str], optional) – Optional collection of name patterns to exclude from freezing. If provided, any parameter whose name matches any of these patterns will not be frozen, even if it matches a pattern in names.
Notes
The matching is done using the matches_any_pattern function. When a parameter is frozen, a message is printed to the console.
- Returns:
The module instance for chaining.
- Return type:
- freeze_(*names)[source]#
In-place alias of
freeze().- Parameters:
*names (str) – Optional name patterns forwarded to
freeze().
- collect_parameters(*names)[source]#
Collects parameters from the model based on the provided names.
- Parameters:
*names (str) – Variable length argument list of parameter name patterns. If empty, all parameters will be collected. Otherwise, only parameters matching any of these patterns will be collected.
- Returns:
Generator yielding parameters matching the provided names.
- Return type:
generator
- collect_named_parameters(*names)[source]#
Collects parameters from the model based on the provided names.
- Parameters:
*names (str) – Variable length argument list of parameter name patterns. If empty, all parameters will be collected. Otherwise, only parameters matching any of these patterns will be collected.
- Returns:
Generator yielding tuples (name, parameter) matching the provided names.
- Return type:
generator
Connection distributions#
Connection weights and delays accept distribution modules. Explicit draw hooks allow the same sampling recipe to be replayed in native and functional execution while differentiating through the distribution parameters.
- class Distribution(*args, **kwargs)[source]#
Abstract base class for re-parameterised probability distributions.
Implement
sample_draw_schema(),sample_draw(), andsample_from_draw()to share explicit sampling between native and functional connections. The inherited sampling adapters retain independent draws for checkpoint continuation and differentiable rematerialization.Existing subclasses can implement
rsample()andlog_prob()following the PyTorch distribution API for native sampling.Initialize internal Module state, shared by both nn.Module and ScriptModule.
- sample_draw_schema(sample_shape=())[source]#
Return the base draw’s
(shape, floating dtype, device)metadata.The draw may have additional dimensions consumed by the transform; its shape need not equal the resulting sample shape. Metadata must describe the draw without consuming randomness or changing module state.
- sample_draw(sample_shape=(), *, generator=None)[source]#
Draw independent base noise using only the supplied generator.
generator=Noneuses the ordinary Torch RNG for the draw’s device. Return one Tensor matchingsample_draw_schema().
- sample_draw_placeholder(sample_shape=())[source]#
Return a deterministic valid base draw without consuming randomness.
The default is zeros. Override this hook when zeros lie outside the transform’s domain, such as an inverse CDF requiring interior uniforms. This value permits safe evaluation of inactive legacy-checkpoint paths; it does not replace a sampled draw or reconstruct missing provenance.
- sample_with_draw(sample_shape=(), *, generator=None)[source]#
Return a differentiable sample and detached independent base draw.
- class Normal(mean=0.0, std=1.0)[source]#
Diagonal normal distribution with learnable mean and scale.
- Parameters:
mean (float or torch.Tensor or torch.nn.Parameter, optional) – Location parameter \(\mu\). Broadcast across event dimensions.
std (float or torch.Tensor or torch.nn.Parameter, optional) – Positive scale parameter \(\sigma\).
- sample_draw_schema(sample_shape=())[source]#
Describe the independent standard-normal draw without sampling.
- sample_draw(sample_shape=(), *, generator=None)[source]#
Draw standard-normal noise for an explicit reparameterization.
- sample_with_draw(sample_shape=(), *, generator=None)[source]#
Sample and retain base noise while evaluating source getters once.
- rsample(sample_shape=())[source]#
Draw a differentiable sample.
- Parameters:
sample_shape (torch.Size, optional) – Leading shape of independent samples.
- Returns:
Sample tensor with shape
sample_shape + mean.shape.- Return type:
torch.Tensor
- class TruncatedNormal(mean=0.0, std=1.0, *, low=0.0, high=inf)[source]#
Normal distribution truncated to a bounded interval.
- Parameters:
mean (float or torch.Tensor or torch.nn.Parameter, optional) – Location parameter \(\mu\).
std (float or torch.Tensor or torch.nn.Parameter, optional) – Positive scale parameter \(\sigma\).
low (float or torch.Tensor, optional) – Inclusive lower truncation bound.
high (float or torch.Tensor, optional) – Inclusive upper truncation bound.
- property std#
- sample_draw_schema(sample_shape=())[source]#
Describe the independent uniform draw without sampling.
- sample_draw(sample_shape=(), *, generator=None)[source]#
Draw uniforms using the native default floating-point dtype.
- sample_draw_placeholder(sample_shape=())[source]#
Use interior uniforms for safe inactive inverse-CDF evaluation.
- sample_with_draw(sample_shape=(), *, generator=None)[source]#
Sample and retain the uniforms used by the inverse-CDF transform.
- rsample(sample_shape=())[source]#
Draw differentiable samples using inverse-CDF reparameterisation.
- Parameters:
sample_shape (torch.Size, optional) – Leading shape of independent samples.
- Returns:
Sample tensor with shape
sample_shape + mean.shape.- Return type:
torch.Tensor
Explicit distribution sampling#
These lower-level adapters describe and evaluate individual base draws. Most
simulation code should use dendra.func.sample_initialization_draws() and
dendra.func.sample_runtime_draws() for complete model packets.
- sample_random_parameter_draw(spec, rng, shape, *, device, dtype)[source]#
Draw explicit parameter-independent noise using the Native RNG calls.
- evaluate_random_parameter(spec, parameters, draw)[source]#
Purely evaluate one distribution from its parameters and explicit draw.
- sample_random_parameter_with_draw(spec, parameters, rng, shape, *, device, dtype)[source]#
Sample through the shared pure core, retaining optional base provenance.
- class RandomParameterDrawRequest(rng_key, spec, shape, device, dtype, reseed_on_initialize=False)[source]#
One host draw in Native order, keyed by its explicit shared RNG stream.
Create new instance of RandomParameterDrawRequest(rng_key, spec, shape, device, dtype, reseed_on_initialize)
- rng_key: str#
Alias for field number 0
- spec: RandomParameterSpec | RuntimeNoiseSpec | DistributionSpec#
Alias for field number 1
- shape: tuple[int, ...]#
Alias for field number 2
- device: device | str#
Alias for field number 3
- dtype: dtype#
Alias for field number 4
- reseed_on_initialize: bool#
Alias for field number 5
- sample_random_parameter_draws(requests, rng_states, *, initialization=True, samplers=None)[source]#
Sample an ordered draw packet from independent explicit RNG checkpoints.
Requests with the same key consume one shared stream in sequence. The returned checkpoints include every supplied stream and retain base seeds and deferred per-device state, without mutating a source model or packet. This host adapter is separate from pure distribution evaluation. An optional caller-owned
samplersmapping lets adjacent owners consume isolated streams in a shared order. Those modules advance in place;rng_statesand source models remain unchanged.
- prepare_rng_for_random_parameter(spec, rng, generation, *, reseed_on_initialize=None)[source]#
Apply one declaration’s ordered initialization reseed request.
- class RuntimeNoiseDrawRequest(rng_key, spec, shape, device, dtype)[source]#
One detached runtime base draw from an explicit shared RNG stream.
Create new instance of RuntimeNoiseDrawRequest(rng_key, spec, shape, device, dtype)
- rng_key: str#
Alias for field number 0
- spec: RuntimeNoiseSpec | DistributionSpec#
Alias for field number 1
- shape: tuple[int, ...]#
Alias for field number 2
- device: device | str#
Alias for field number 3
- dtype: dtype#
Alias for field number 4
- sample_runtime_noise_draws(requests, rng_states, *, samplers=None)[source]#
Return detached base draws and advanced checkpoints.
This host adapter shares the ordered stream machinery used by RAND initialization, including its optional caller-owned samplers. Runtime draws never apply initialization reseeding.
- sample_runtime_noise_draw(spec, rng, shape, *, device, dtype)[source]#
Sample a parameter-independent runtime base draw through explicit RNG.
- evaluate_runtime_noise(spec, parameters, draw, *, dt=None)[source]#
Evaluate detached runtime noise from explicit parameters and a base draw.
Distribution evaluation and timestep scaling use the same algebra as native sampling. The result is detached from parameters, base draws, and
dt.
- sample_runtime_noise_with_draw(spec, parameters, rng, shape, *, device, dtype, dt=None)[source]#
Sample detached noise through the pure core or a legacy native sampler.
- iter_initialization_random_declarations(owner)[source]#
Yield canonical owner initialization draws in their native order.
Each item is
(owner, kind, name, spec), wherekindis"random"or"noise". Mechanism initialization samples its nested State noise through the mechanism’s runtime sampler before separately populating each State’s parameters. That early noise draw consumes the shared stream even though the State’s later initialization noise replaces its value.