Implicit Bridge API
This module contains compact implicit-layer building blocks used by the bridge notebooks and examples. They are PyTorch modules and can be combined with the main SILVA layers.
For the source-to-package derivation and scope notes, see Method Adaptation Atlas.
When these objects are used as part of SILVA methodology, cite Jose Luis Lima de Jesus Silva, SILVA Networks as Structured Implicit Layers and Vector Attractors via Dynamic Interaction Fields (2026; arXiv:2607.28989), and cite the software repository. Complete numbered entries are available for the article [1], package [2], DEQ [4], Neural ODEs [7], optimization layers [8] [9], and MDEQ [5].
Equations
The simplest DEQ block solves
The multiscale block solves
The compact differentiable optimization layer solves the unconstrained quadratic problem
The constrained package-native variants live in Optimization.
They implement projected fixed-point QP layers for common constraint sets. A
full CVXPYlayers-style disciplined convex optimization layer is available only
through the optional silva_cvxpy_layer bridge.
Jacobian regularization estimates
with Hutchinson VJP probes.
Minimal Fixed-Point Block
import torch
from silva_networks import SolverConfig, silva_fixed_point_block
block = silva_fixed_point_block(
in_dim=5,
state_dim=12,
config=SolverConfig(
solver="anderson",
max_iter=25,
backward_mode="implicit",
backward_solver="gmres",
),
)
x = torch.randn(8, 5)
result = block(x, return_result=True)
assert result.z.shape == (8, 12)
print(result.converged, result.residual)
The output state must preserve (batch, hidden_dim) across transition calls.
After a backward pass in implicit mode, inspect the backward residual recorded
in result.info as well as the forward residual.
Citation Map
| Object family | Cite |
|---|---|
| fixed-point and DEQ blocks | SILVA package; Deep Equilibrium Models; Deep Implicit Layers tutorial |
| Euler flow block | Neural Ordinary Differential Equations |
| quadratic optimization layer | SILVA package; OptNet for differentiable QP-layer framing |
| optional CVXPYlayers bridge | Differentiable Convex Optimization Layers; CVXPYlayers |
| multiscale block | Multiscale Deep Equilibrium Models |
| Jacobian regularization | Stabilizing Equilibrium Models by Jacobian Regularization; Hutchinson trace estimation |
Public Objects
| Object | Role |
|---|---|
SILVAImplicitTransition |
SILVA-named affine-tanh implicit transition |
SILVAFixedPointBlock |
SILVA-named solver-wrapped fixed-point block |
SILVAFixedPointClassifier |
SILVA-named classifier with equilibrium state and readout |
SILVAEulerFlowBlock |
SILVA-named explicit Euler bridge block |
SILVAQuadraticOptimizationLayer |
SILVA-named quadratic optimization layer |
SILVAMultiscaleDEQBlock |
SILVA-named two-scale equilibrium block |
silva_implicit_transition |
factory for SILVAImplicitTransition |
silva_fixed_point_block |
factory for SILVAFixedPointBlock |
silva_fixed_point_classifier |
factory for SILVAFixedPointClassifier |
silva_euler_flow_block |
factory for SILVAEulerFlowBlock |
silva_quadratic_optimization_layer |
factory for SILVAQuadraticOptimizationLayer |
silva_multiscale_deq_block |
factory for SILVAMultiscaleDEQBlock |
silva_jacobian_regularization_loss |
SILVA-named Hutchinson Jacobian penalty |
silva_residual_ratio |
SILVA-named residual-trace diagnostic |
DEQMLPTransition |
affine-tanh DEQ transition |
TanhFixedPointBlock |
solver-wrapped fixed-point block |
TanhFixedPointClassifier |
tutorial classifier with DEQ state and linear readout |
ExplicitEulerODEBlock |
finite Euler neural ODE-style block |
QuadraticOptimizationLayer |
differentiable quadratic solver layer |
ToyMultiscaleDEQBlock |
compact two-scale equilibrium block |
jacobian_regularization_loss |
Hutchinson Jacobian penalty |
residual_ratio |
small residual-trace diagnostic |
API Docs
Package-native implicit-layer and DEQ tutorial building blocks.
The classes in this module are small PyTorch modules used by the public
notebooks and documentation. They mirror the main ideas from the Deep Implicit
Layers tutorial, Deep Equilibrium Models, Multiscale Deep Equilibrium Models,
and Jacobian-regularized DEQs, while keeping all computation inside the
silva_networks solver, Jacobian, and device APIs.
References
- Silva, "SILVA Networks as Structured Implicit Layers and Vector Attractors via Dynamic Interaction Fields", 2026.
- Bai, Kolter, and Koltun, "Deep Equilibrium Models", NeurIPS 2019.
- Bai, Koltun, and Kolter, "Multiscale Deep Equilibrium Models", NeurIPS 2020.
- Bai, Koltun, and Kolter, "Stabilizing Equilibrium Models by Jacobian Regularization", ICML 2021.
- Duvenaud, Kolter, and Johnson, "Deep Implicit Layers" tutorial, NeurIPS 2020.
DEQMLPTransition
Bases: Module
Affine-tanh DEQ transition.
The transition computes
which is the smallest useful fixed-point block for reproducing the solver and implicit-differentiation mechanics of DEQ models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Number of input features. |
required |
state_dim
|
int
|
Number of equilibrium state features. |
required |
activation
|
Callable[[Tensor], Tensor]
|
Elementwise nonlinearity. Defaults to |
tanh
|
bias
|
bool
|
Whether to use affine biases. |
True
|
spectral_scale
|
float | None
|
Optional target spectral norm for the initial recurrent matrix. Values below one encourage Picard convergence in small tutorial examples. |
0.85
|
Inputs
z: State tensor with shape (batch, state_dim).
x: Input tensor with shape (batch, in_dim).
Output
Tensor with shape (batch, state_dim).
Source code in src/silva_networks/implicit.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
project_state_weight
Scale the recurrent matrix so its spectral norm is at most max_norm.
This is a lightweight tutorial utility. It does not replace full Lipschitz certification, but it keeps small fixed-point examples stable across CPU and GPU runtimes.
Source code in src/silva_networks/implicit.py
reset_parameters
Initialize input and recurrent maps, optionally scaling recurrence.
Source code in src/silva_networks/implicit.py
state_weight_spectral_norm
Return the spectral norm of the recurrent matrix as a Python float.
Source code in src/silva_networks/implicit.py
ExplicitEulerODEBlock
Bases: Module
Explicit Euler neural ODE-style block.
The continuous model
is discretized as
This block is intentionally explicit: it is included to connect neural ODE intuition to fixed-point layers in the tutorials without adding a runtime dependency on an ODE solver package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
State dimension. |
required |
hidden_dim
|
int | None
|
Width of the internal vector-field MLP. Defaults to |
None
|
steps
|
int
|
Number of Euler steps. |
8
|
step_size
|
float
|
Euler step size. |
0.1
|
vector_field
|
Module | None
|
Optional custom module mapping |
None
|
Inputs
x: Initial state tensor with shape (batch, dim).
Output
Terminal state, or (terminal, trajectory) when return_trajectory=True.
Source code in src/silva_networks/implicit.py
ImplicitModelOutput
dataclass
Structured output for compact implicit-layer tutorial models.
Attributes:
| Name | Type | Description |
|---|---|---|
output |
Tensor
|
Model prediction tensor. |
state |
Tensor
|
Equilibrium or terminal hidden state. |
solver_result |
SolverResult | None
|
Fixed-point solver diagnostics, when a fixed-point solve was used. |
trajectory |
Tensor | None
|
Optional explicit trajectory, used by ODE-style examples. |
Source code in src/silva_networks/implicit.py
QuadraticOptimizationLayer
Bases: Module
Differentiable quadratic optimization layer.
For each input row \(x_i\), the layer forms \(b_i=B_\theta x_i+c\) and solves
The first-order condition is
A gradient-descent fixed-point map for the same condition is
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Number of input features. |
required |
state_dim
|
int
|
Number of optimized variables. |
required |
ridge
|
float
|
Positive diagonal term added to \(L L^\top\). |
1.0
|
step_size
|
float
|
Gradient-descent step size for the fixed-point map. |
0.2
|
config
|
SolverConfig | None
|
Fixed-point solver configuration. |
None
|
reengage
|
bool
|
If true, run one differentiable transition evaluation after the numerical solve. |
True
|
Inputs
x: Tensor with shape (batch, in_dim).
Output
Optimizer state, or SolverResult when return_result=True.
Source code in src/silva_networks/implicit.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | |
energy
Return one quadratic objective value per batch row.
Source code in src/silva_networks/implicit.py
exact_solution
Solve \(Az=b_\theta(x)\) directly with torch.linalg.solve.
matrix
Return the positive-definite matrix \(A=L L^\top+\lambda I\).
rhs
Return \(b_\theta(x)\) with shape (batch, state_dim).
Source code in src/silva_networks/implicit.py
transition
Return one gradient-descent fixed-point step for the KKT equation.
SILVAEulerFlowBlock
Bases: ExplicitEulerODEBlock
SILVA-named explicit Euler flow block for bridge tutorials.
The block is included for the neural-ODE bridge from repeated explicit computation to equilibrium computation. It is not a SILVA interaction layer by itself, but it is part of the package tutorial path.
Source code in src/silva_networks/implicit.py
SILVAFixedPointBlock
Bases: TanhFixedPointBlock
SILVA-named fixed-point block with configurable package solvers.
The block solves
using SolverConfig. It is a compact import path for tutorial baselines,
ablations, and user extensions inside the SILVA package.
Source code in src/silva_networks/implicit.py
SILVAFixedPointClassifier
Bases: TanhFixedPointClassifier
SILVA-named classifier built from a fixed-point state and readout head.
This class is the package-facing classifier for small DEQ/SILVA bridge experiments. Cite the SILVA Networks paper when it is used to reproduce, extend, or explain SILVA methodology.
Source code in src/silva_networks/implicit.py
SILVAImplicitTransition
Bases: DEQMLPTransition
SILVA-named affine-tanh implicit transition.
This class gives the package-facing name to the compact DEQ transition used throughout the bridge tutorials:
The equation is a DEQ baseline. It becomes part of the SILVA suite when it is used as a controlled comparison or as a building block beside structured stimulus/local/global SILVA operators. Cite the SILVA Networks paper when using this transition in that SILVA context.
Source code in src/silva_networks/implicit.py
SILVAMultiscaleDEQBlock
Bases: ToyMultiscaleDEQBlock
SILVA-named two-scale equilibrium block.
The block provides a compact multiscale DEQ comparison point for the SILVA suite. Cite the SILVA Networks paper when using it to compare structured SILVA operators with multiscale implicit models.
Source code in src/silva_networks/implicit.py
SILVAQuadraticOptimizationLayer
Bases: QuadraticOptimizationLayer
SILVA-named differentiable quadratic optimization layer.
The layer is used in the package bridge for optimization-as-layer examples and for checking fixed-point solvers against an exact linear solve.
Source code in src/silva_networks/implicit.py
TanhFixedPointBlock
Bases: Module
Solve an affine-tanh fixed point with a package solver.
The block computes
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Number of input features. |
required |
state_dim
|
int
|
Number of equilibrium state features. |
required |
config
|
SolverConfig | None
|
Fixed-point solver configuration. |
None
|
spectral_scale
|
float | None
|
Initial recurrent spectral-norm target. |
0.85
|
reengage
|
bool
|
If true, run one differentiable transition evaluation after the numerical solve. This keeps gradients available when using acceleration methods that store detached history. |
True
|
Inputs
x: Tensor with shape (batch, in_dim).
z0: Optional initial state with shape (batch, state_dim).
Output
Equilibrium tensor or SolverResult when return_result=True.
Source code in src/silva_networks/implicit.py
TanhFixedPointClassifier
Bases: Module
Classifier built from TanhFixedPointBlock and a linear readout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_features
|
int
|
Flattened input feature count. |
required |
state_dim
|
int
|
Hidden equilibrium width. |
required |
num_classes
|
int
|
Number of output classes. |
required |
config
|
SolverConfig | None
|
Solver configuration used by the fixed-point block. |
None
|
spectral_scale
|
float | None
|
Initial recurrent spectral-norm target. |
0.85
|
dropout
|
float
|
Dropout probability before the readout. |
0.0
|
Inputs
x: Tensor with shape (batch, in_features) or image-like tensors that
flatten to in_features.
Output
Class logits, or ImplicitModelOutput when return_result=True.
Source code in src/silva_networks/implicit.py
ToyMultiscaleDEQBlock
Bases: Module
Two-scale DEQ block for multiscale equilibrium tutorials.
The state is split into a low-resolution part \(z_\ell\) and a high-resolution part \(z_h\). The transition is
This is a compact tensor version of the MDEQ idea: multiple feature scales are solved together rather than stacked as separate explicit layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Number of input features. |
required |
low_dim
|
int
|
Width of the first scale. |
required |
high_dim
|
int
|
Width of the second scale. |
required |
config
|
SolverConfig | None
|
Fixed-point solver configuration. |
None
|
spectral_scale
|
float
|
Initial coupling scale. |
0.45
|
reengage
|
bool
|
If true, run one differentiable transition evaluation after the numerical solve. |
True
|
Inputs
x: Tensor with shape (batch, in_dim).
Output
Concatenated state (batch, low_dim + high_dim), or SolverResult when
return_result=True.
Source code in src/silva_networks/implicit.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | |
reset_parameters
Initialize coupling matrices at a conservative scale.
Source code in src/silva_networks/implicit.py
scale_couplings_
Multiply all recurrent cross-scale maps by scale in place.
Source code in src/silva_networks/implicit.py
split_state
jacobian_regularization_loss
Estimate a Jacobian regularization penalty for a transition.
The Jacobian-regularized DEQ objective adds a penalty proportional to
Hutchinson probes estimate this trace without materializing \(J_f\):
where \(v\) has independent Rademacher entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transition
|
Callable[[Tensor], Tensor]
|
Function mapping |
required |
z
|
Tensor
|
State where the penalty is evaluated. |
required |
samples
|
int
|
Number of Hutchinson probes. |
1
|
squared
|
bool
|
If true, return a squared Frobenius estimate; otherwise return its square root. |
True
|
weight
|
float
|
Multiplicative penalty weight. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Scalar tensor suitable for adding to a PyTorch loss. |
Source code in src/silva_networks/implicit.py
residual_ratio
Return final residual divided by initial residual for a solver trace.
Source code in src/silva_networks/implicit.py
silva_euler_flow_block
Create a SILVA-named explicit Euler flow block.
Source code in src/silva_networks/implicit.py
silva_fixed_point_block
Create a SILVA-named fixed-point block.
Source code in src/silva_networks/implicit.py
silva_fixed_point_classifier
silva_fixed_point_classifier(in_features, state_dim, num_classes, *, config=None, spectral_scale=0.85, dropout=0.0)
Create a SILVA-named fixed-point classifier.
Source code in src/silva_networks/implicit.py
silva_implicit_transition
silva_implicit_transition(in_dim, state_dim, *, activation=torch.tanh, bias=True, spectral_scale=0.85)
Create a SILVA-named affine-tanh implicit transition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dim
|
int
|
Number of input features. |
required |
state_dim
|
int
|
Number of equilibrium state features. |
required |
activation
|
Callable[[Tensor], Tensor]
|
Elementwise nonlinearity. |
tanh
|
bias
|
bool
|
Whether to use affine biases. |
True
|
spectral_scale
|
float | None
|
Optional recurrent spectral-norm target. |
0.85
|
Returns:
| Type | Description |
|---|---|
SILVAImplicitTransition
|
|
Source code in src/silva_networks/implicit.py
silva_jacobian_regularization_loss
Estimate the SILVA/DEQ Jacobian regularization penalty.
Source code in src/silva_networks/implicit.py
silva_multiscale_deq_block
silva_multiscale_deq_block(in_dim, low_dim, high_dim, *, config=None, spectral_scale=0.45, reengage=True)
Create a SILVA-named two-scale equilibrium block.
Source code in src/silva_networks/implicit.py
silva_quadratic_optimization_layer
silva_quadratic_optimization_layer(in_dim, state_dim, *, ridge=1.0, step_size=0.2, config=None, reengage=True)
Create a SILVA-named quadratic optimization layer.
Source code in src/silva_networks/implicit.py
silva_residual_ratio
Return the final-to-initial residual ratio for a SILVA solver trace.
Where to Go Next
| Question | Page |
|---|---|
| How do these compact objects connect to the learning path? | Implicit Layers Bridge |
| Where is a fixed-point block executed? | DEQ Engine Bridge Example |
| Which optimization layers share the implicit viewpoint? | Optimization API |