llmcompressor.pipelines.sequential.error_logging
Functions:
-
compute_sqnr–Compute the Signal-to-Quantization-Noise Ratio (SQNR), in decibels, from
-
compute_subgraph_sqnr–Aggregate per-batch signal/noise power sums and compute the subgraph's
-
process_batch_error–Process SQNR tracking for a single batch during the propagation pass. When
compute_sqnr
Compute the Signal-to-Quantization-Noise Ratio (SQNR), in decibels, from
accumulated signal and noise power sums; higher values indicate less
distortion. Callers should sum power across every batch in a subgraph
(see :func:_accumulate_batch_power) and call this once on the totals,
since SQNR is a logarithmic ratio and cannot be meaningfully averaged
batch-by-batch.
Parameters:
-
signal_power_sum(float) –sum of squared pre-compression activation values
-
noise_power_sum(float) –sum of squared compression noise values
Returns:
-
float–SQNR in dB, or
infif there is no noise
Source code in src/llmcompressor/pipelines/sequential/error_logging.py
compute_subgraph_sqnr
Aggregate per-batch signal/noise power sums and compute the subgraph's overall SQNR in one call.
Parameters:
-
batch_powers(list[tuple[float, float]]) –list of (signal power sum, noise power sum) tuples, one per batch, as returned by :func:
process_batch_error
Returns:
-
float–SQNR in dB, or
infif there is no noise
Source code in src/llmcompressor/pipelines/sequential/error_logging.py
process_batch_error
process_batch_error(
cache: IntermediatesCache,
activations: IntermediatesCache,
batch_idx: int,
output: dict[str, Any],
propagate_error: bool,
consumed_names: set[str],
) -> tuple[float, float] | None
Process SQNR tracking for a single batch during the propagation pass. When
propagate_error is disabled, first transfer this subgraph's unquantized
outputs into activations for the next subgraph, since pass 2 doesn't do
so itself in that case. Then compare pre/post-compression outputs to
accumulate this batch's signal/noise power (see
:func:_accumulate_batch_power).
Parameters:
-
cache(IntermediatesCache) –intermediates cache dedicated to log_sequential_error
-
activations(IntermediatesCache) –intermediates cache shared across the pipeline
-
batch_idx(int) –index of the current propagation batch
-
output(dict[str, Any]) –subgraph output dict from the propagation (post-compression) pass
-
propagate_error(bool) –whether quantized outputs are fed to the next subgraph
-
consumed_names(set[str]) –names no longer needed by any subsequent subgraph
Returns:
-
tuple[float, float] | None–(signal power sum, noise power sum) for this batch, or None if either tensor is unavailable