Unverified Commit 4fc1bf81 authored by Feng XiaoLong's avatar Feng XiaoLong Committed by GitHub
Browse files

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


Signed-off-by: default avatarCrucifixion-Fxl <xmufxl@gmail.com>
Co-authored-by: default avatarCrucifixion-Fxl <xmufxl@gmail.com>
parent f2036734
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
import re
from copy import deepcopy from copy import deepcopy
from typing import Optional, Union from typing import Optional, Union
import regex as re
import torch import torch
from vllm.config import QuantizationConfig from vllm.config import QuantizationConfig
......
...@@ -7,7 +7,6 @@ import dataclasses ...@@ -7,7 +7,6 @@ import dataclasses
import io import io
import json import json
import os import os
import re
import threading import threading
import time import time
from collections.abc import Generator from collections.abc import Generator
...@@ -15,6 +14,7 @@ from dataclasses import dataclass ...@@ -15,6 +14,7 @@ from dataclasses import dataclass
from functools import partial from functools import partial
from typing import Any, BinaryIO, Optional, Union from typing import Any, BinaryIO, Optional, Union
import regex as re
import torch import torch
from torch import nn from torch import nn
from torch.utils._python_dispatch import TorchDispatchMode from torch.utils._python_dispatch import TorchDispatchMode
......
...@@ -250,7 +250,7 @@ class MiMoMTP(nn.Module): ...@@ -250,7 +250,7 @@ class MiMoMTP(nn.Module):
return loaded_params return loaded_params
def map_model_name_to_mtp_param_name(self, name: str) -> str: def map_model_name_to_mtp_param_name(self, name: str) -> str:
import re import regex as re
name_without_prefix = [ name_without_prefix = [
"token_layernorm", "hidden_layernorm", "input_proj", "token_layernorm", "hidden_layernorm", "input_proj",
"final_layernorm" "final_layernorm"
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
"""Inference-only MiniMaxText01 model.""" """Inference-only MiniMaxText01 model."""
import copy import copy
import math import math
import re
from collections.abc import Iterable from collections.abc import Iterable
from typing import Optional, Union from typing import Optional, Union
import regex as re
import torch import torch
import torch.distributed import torch.distributed
import torch.nn.functional as F import torch.nn.functional as F
......
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import re
from collections.abc import Iterable, Mapping, Sequence from collections.abc import Iterable, Mapping, Sequence
from typing import Any, Literal, Optional, TypedDict, Union from typing import Any, Literal, Optional, TypedDict, Union
import regex as re
import torch import torch
import torch.nn as nn import torch.nn as nn
from transformers import (BatchFeature, CLIPVisionConfig, PretrainedConfig, from transformers import (BatchFeature, CLIPVisionConfig, PretrainedConfig,
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
import copy import copy
import math import math
import re
import unicodedata import unicodedata
from collections.abc import Collection, Mapping, Sequence, Set from collections.abc import Collection, Mapping, Sequence, Set
from functools import lru_cache, partial from functools import lru_cache, partial
from typing import Callable, Literal, Optional, TypedDict, Union from typing import Callable, Literal, Optional, TypedDict, Union
import regex as re
import torch import torch
from torch import nn from torch import nn
from torchvision import transforms from torchvision import transforms
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
"""Wrapper around `transformers` models""" """Wrapper around `transformers` models"""
import re
from collections.abc import Iterable from collections.abc import Iterable
from contextlib import nullcontext from contextlib import nullcontext
from typing import Literal, Optional, Union from typing import Literal, Optional, Union
import regex as re
import torch import torch
from torch import nn from torch import nn
from transformers import AutoModel, PretrainedConfig, PreTrainedModel from transformers import AutoModel, PretrainedConfig, PreTrainedModel
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
import json import json
import re
import sys import sys
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from collections import defaultdict from collections import defaultdict
...@@ -12,6 +11,7 @@ from functools import lru_cache ...@@ -12,6 +11,7 @@ from functools import lru_cache
from typing import (TYPE_CHECKING, Generic, NamedTuple, Optional, Protocol, from typing import (TYPE_CHECKING, Generic, NamedTuple, Optional, Protocol,
TypeVar, Union, cast) TypeVar, Union, cast)
import regex as re
import torch import torch
from typing_extensions import assert_never from typing_extensions import assert_never
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
import re
from collections.abc import Sequence from collections.abc import Sequence
from typing import Optional, Union from typing import Optional, Union
import regex as re
from transformers import PreTrainedTokenizerBase from transformers import PreTrainedTokenizerBase
from vllm.entrypoints.openai.protocol import (ChatCompletionRequest, from vllm.entrypoints.openai.protocol import (ChatCompletionRequest,
......
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
import os import os
import re
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING, Any, Optional, Union, cast from typing import TYPE_CHECKING, Any, Optional, Union, cast
import huggingface_hub import huggingface_hub
import regex as re
from huggingface_hub import HfApi, hf_hub_download from huggingface_hub import HfApi, hf_hub_download
from vllm.logger import init_logger from vllm.logger import init_logger
......
...@@ -19,7 +19,6 @@ import json ...@@ -19,7 +19,6 @@ import json
import multiprocessing import multiprocessing
import os import os
import pickle import pickle
import re
import signal import signal
import socket import socket
import subprocess import subprocess
...@@ -54,6 +53,7 @@ import cloudpickle ...@@ -54,6 +53,7 @@ import cloudpickle
import numpy as np import numpy as np
import numpy.typing as npt import numpy.typing as npt
import psutil import psutil
import regex as re
import torch import torch
import torch.types import torch.types
import yaml import yaml
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import re import regex as re
def grammar_is_likely_lark(grammar_str: str) -> bool: def grammar_is_likely_lark(grammar_str: str) -> bool:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment