Skip to content

vllm.model_executor.layers.quantization.quark.utils

_is_equal_or_regex_match

_is_equal_or_regex_match(
    value: str, target: str, check_contains: bool = False
) -> bool

Checks whether a value is exactly equal or a regex match for target if target starts with 're:'. If check_contains is set to True, additionally checks if the target string is contained within the value.

Source code in vllm/model_executor/layers/quantization/quark/utils.py
def _is_equal_or_regex_match(
    value: str, target: str, check_contains: bool = False
) -> bool:
    """
    Checks whether a value is exactly equal or a regex match for target
    if target starts with 're:'. If check_contains is set to True,
    additionally checks if the target string is contained within the value.
    """

    if target.startswith("re:"):
        pattern = target[3:]
        if re.match(pattern, value):
            return True
    elif check_contains:
        if target.lower() in value.lower():
            return True
    elif target == value:
        return True
    return False

check_equal_or_regex_match

check_equal_or_regex_match(
    layer_name: str, targets: Iterable[str]
) -> bool

Checks whether a layer_name is exactly equal or a regex match for if target starts with 're:' to any target in list.

Source code in vllm/model_executor/layers/quantization/quark/utils.py
def check_equal_or_regex_match(layer_name: str, targets: Iterable[str]) -> bool:
    """
    Checks whether a layer_name is exactly equal or a regex match for
    if target starts with 're:' to any target in list.
    """
    return any(_is_equal_or_regex_match(layer_name, target) for target in targets)