Skip to content

QuantResidualAdd

Bases: QuantBase

Quantized residual block with two parallel layer streams.

The input flows through two parallel paths (layers_a and layers_b), whose outputs are added element-wise. An optional ReLU activation and output fake-quantization are applied after the add. An empty layers_b means the skip path is the identity.

Parameters:

Name Type Description Default
layers_a list[QuantBase]

Quantized layers for stream A (main path).

required
layers_b list[QuantBase]

Quantized layers for stream B (empty = identity skip).

required
act_func str | None

Either "relu" or None.

None
ema_constant float

EMA smoothing factor for the output observer.

0.01

build_testcase_outputs

build_testcase_outputs(
    x: Tensor,
) -> tuple[torch.Tensor, list[dict]]

Capture every sub-layer output plus the final combined output.