[Bugfix] Migrate to REGEX Library to prevent catastrophic backtracking (#18454)

Signed-off-by: Crucifixion-Fxl <xmufxl@gmail.com>
Co-authored-by: Crucifixion-Fxl <xmufxl@gmail.com>
This commit is contained in:
Feng XiaoLong
2025-05-24 07:16:26 +08:00
committed by GitHub
parent f2036734fb
commit 4fc1bf813a
52 changed files with 62 additions and 58 deletions

View File

@@ -1,10 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
import re
from collections.abc import Iterable, Mapping
from types import MappingProxyType
from typing import Optional
import regex as re
from compressed_tensors import CompressionFormat
from torch.nn import Module

View File

@@ -228,7 +228,7 @@ class ModelOptNvFp4Config(QuantizationConfig):
exclude_modules, group_size)
def is_layer_excluded(self, prefix: str, exclude_modules: list):
import re
import regex as re
for pattern in exclude_modules:
regex_str = pattern.replace('.', r'\.').replace('*', r'.*')
if re.fullmatch(regex_str, prefix):

View File

@@ -1,10 +1,11 @@
# SPDX-License-Identifier: Apache-2.0
import re
from collections.abc import Iterable, Mapping
from types import MappingProxyType
from typing import Any, Optional
import regex as re
def deep_compare(dict1: Any, dict2: Any) -> bool:
if type(dict1) is not type(dict2):

View File

@@ -1,8 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
import re
from copy import deepcopy
from typing import Optional, Union
import regex as re
import torch
from vllm.config import QuantizationConfig