Skip to content

vllm.benchmarks.sweep.sla_sweep

SLA_EPS module-attribute

SLA_EPS = 1e-08

Offset used to differentiate margins for equality checks.

SLACriterionBase dataclass

Bases: ABC

Source code in vllm/benchmarks/sweep/sla_sweep.py
@dataclass
class SLACriterionBase(ABC):
    target: float

    @abstractmethod
    def compute_margin(self, actual: float) -> float:
        """
        Return a negative value or `0` if this criterion is met;
        otherwise a positive value indicating the distance to the target.
        """
        raise NotImplementedError

    @abstractmethod
    def format_cond(self, lhs: str) -> str:
        raise NotImplementedError

    def print_and_compute_margin(
        self,
        metrics: dict[str, float],
        metrics_key: str,
    ) -> float:
        metric = metrics[metrics_key]
        margin = self.compute_margin(metric)

        cond = self.format_cond(f"{metrics_key} = {metric:.2f}")
        print(f"Validating SLA: {cond} | " + ("PASSED" if margin <= 0 else "FAILED"))

        return margin

compute_margin abstractmethod

compute_margin(actual: float) -> float

Return a negative value or 0 if this criterion is met; otherwise a positive value indicating the distance to the target.

Source code in vllm/benchmarks/sweep/sla_sweep.py
@abstractmethod
def compute_margin(self, actual: float) -> float:
    """
    Return a negative value or `0` if this criterion is met;
    otherwise a positive value indicating the distance to the target.
    """
    raise NotImplementedError