kaira.constraints.PAPRConstraint

Inheritance diagram of PAPRConstraint

Inheritance diagram for PAPRConstraint

class kaira.constraints.PAPRConstraint(max_papr: float = 3.0, *args, **kwargs)[source]

Bases: BaseConstraint

Reduces peak-to-average power ratio using soft clipping to minimize signal distortion.

Limits the peak-to-average power ratio of the signal, which is critical in OFDM and multicarrier systems to reduce nonlinear distortions and improve power amplifier efficiency [Han and Lee, 2005] [Jiang and Wu, 2008].

This constraint applies soft clipping to signal peaks that would cause the PAPR to exceed the specified threshold, while preserving the signal shape as much as possible. The PAPR reduction techniques are extensively studied in wireless communications [Tellambura, 2001].

max_papr

Maximum allowed peak-to-average power ratio in linear units (not dB)

Type:

float

Methods

__init__

Initialize the PAPR constraint.

forward

Apply PAPR constraint to the input tensor.

get_dimensions

Helper method to get all dimensions except batch for calculating norms/means.

__init__(max_papr: float = 3.0, *args, **kwargs) None[source]

Initialize the PAPR constraint.

Parameters:
  • max_papr (float, optional) – Maximum allowed peak-to-average power ratio in linear units (not dB). For reference, a max_papr of 4.0 corresponds to approximately 6 dB. Defaults to 3.0.

  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

forward(x: Tensor, *args, **kwargs) Tensor[source]

Apply PAPR constraint to the input tensor.

Finds signal peaks that cause excessive PAPR and scales them down to meet the constraint while preserving the overall signal shape.

Parameters:
  • x (torch.Tensor) – The input tensor of any shape

  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

Returns:

Signal with constrained PAPR with the same shape as input

Return type:

torch.Tensor

Note

This implementation uses a multi-iteration approach to ensure the PAPR constraint is strictly enforced even for challenging signals.

static get_dimensions(x: Tensor, exclude_batch: bool = True) Tuple[int, ...]

Helper method to get all dimensions except batch for calculating norms/means.

Utility function to generate dimension indices for reduction operations like mean or norm. Typically used to calculate signal properties across all dimensions except the batch dimension.

Parameters:
  • x (torch.Tensor) – Input tensor

  • exclude_batch (bool, optional) – Whether to exclude the batch dimension (first dimension). Defaults to True.

Returns:

Dimensions to use for reduction operations (e.g., mean, norm)

Return type:

Tuple[int, …]

Example

>>> x = torch.randn(32, 4, 128)  # [batch, antennas, time]
>>> dims = BaseConstraint.get_dimensions(x)
>>> # dims will be (1, 2) for summing across antennas and time