From c51ea064f5e1a7c704ff73339083fdbae1701125 Mon Sep 17 00:00:00 2001 From: Aaron-Zhao123 Date: Mon, 3 Feb 2025 11:03:58 +0000 Subject: [PATCH] fixes for python3.13 --- setup.py | 3 +-- src/chop/distributed/tensor/ops/utils.py | 2 +- src/chop/ir/graph/mase_graph.py | 2 +- src/chop/models/bert/configuration_bert.py | 2 +- src/chop/models/bert/configuration_bert_quantized.py | 2 +- src/chop/models/llama/configuration_llama_llora.py | 2 +- src/chop/models/llama/configuration_llama_quantized.py | 2 +- src/chop/models/llama/configuration_llama_sparse.py | 2 +- src/chop/models/llama/modeling_llama_llora.py | 2 +- src/chop/models/llama/modeling_llama_quantized.py | 2 +- src/chop/models/llama/modeling_llama_sparse.py | 2 +- src/chop/models/opt/configuration_opt.py | 2 +- src/chop/models/opt/configuration_opt_lora.py | 2 +- src/chop/models/opt/configuration_opt_quantized.py | 2 +- src/chop/models/opt/configuration_opt_sparse.py | 2 +- src/chop/models/opt/modeling_opt.py | 2 +- src/chop/models/opt/modeling_opt_lora.py | 2 +- src/chop/models/opt/modeling_opt_quantized.py | 2 +- src/chop/models/opt/modeling_opt_sparse.py | 2 +- 19 files changed, 19 insertions(+), 20 deletions(-) diff --git a/setup.py b/setup.py index 27d865de1..6bd0eea20 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_system(): "toml", "GitPython", "colorlog", - "cocotb[bus]==1.8.0", + "cocotb[bus]", "pytest", "pytorch-lightning", "transformers", @@ -37,7 +37,6 @@ def get_system(): "evaluate", "ipython", "ipdb", - "sentencepiece", "einops", "pybind11", "tabulate", diff --git a/src/chop/distributed/tensor/ops/utils.py b/src/chop/distributed/tensor/ops/utils.py index 28e5245c3..02d5db5e1 100644 --- a/src/chop/distributed/tensor/ops/utils.py +++ b/src/chop/distributed/tensor/ops/utils.py @@ -87,7 +87,7 @@ def wrapper(impl): def as_list( - x: Union[List[object], object] + x: Union[List[object], object], # pyre-fixme[11]: Annotation `immutable_list` is not defined as a type. ) -> Union[List[object], torch.fx.immutable_collections.immutable_list]: # type: ignore[valid-type] # During tracing, `aten.sum.dim_IntList` uses `immutable_list` for its args, diff --git a/src/chop/ir/graph/mase_graph.py b/src/chop/ir/graph/mase_graph.py index 322195869..58fcc0816 100644 --- a/src/chop/ir/graph/mase_graph.py +++ b/src/chop/ir/graph/mase_graph.py @@ -377,7 +377,7 @@ def from_checkpoint( MaseGraph: Loaded MaseGraph. """ with open(f"{checkpoint}.pt", "rb") as f: - loaded_model = torch.load(f) + loaded_model = torch.load(f, weights_only=False) assert isinstance( loaded_model, fx.GraphModule diff --git a/src/chop/models/bert/configuration_bert.py b/src/chop/models/bert/configuration_bert.py index a3f82a8d2..4c1fb7513 100644 --- a/src/chop/models/bert/configuration_bert.py +++ b/src/chop/models/bert/configuration_bert.py @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" BERT model configuration""" +"""BERT model configuration""" from collections import OrderedDict from typing import Mapping diff --git a/src/chop/models/bert/configuration_bert_quantized.py b/src/chop/models/bert/configuration_bert_quantized.py index 640c0eb7d..7e486868f 100644 --- a/src/chop/models/bert/configuration_bert_quantized.py +++ b/src/chop/models/bert/configuration_bert_quantized.py @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" BERT model configuration""" +"""BERT model configuration""" from collections import OrderedDict from typing import Mapping diff --git a/src/chop/models/llama/configuration_llama_llora.py b/src/chop/models/llama/configuration_llama_llora.py index 07578ef37..92f8b0f46 100644 --- a/src/chop/models/llama/configuration_llama_llora.py +++ b/src/chop/models/llama/configuration_llama_llora.py @@ -17,7 +17,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" LLaMA model configuration""" +"""LLaMA model configuration""" from transformers.configuration_utils import PretrainedConfig from transformers.utils import logging diff --git a/src/chop/models/llama/configuration_llama_quantized.py b/src/chop/models/llama/configuration_llama_quantized.py index d35fc18b4..aeb8320ab 100644 --- a/src/chop/models/llama/configuration_llama_quantized.py +++ b/src/chop/models/llama/configuration_llama_quantized.py @@ -17,7 +17,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" LLaMA model configuration""" +"""LLaMA model configuration""" from transformers.configuration_utils import PretrainedConfig from transformers.utils import logging diff --git a/src/chop/models/llama/configuration_llama_sparse.py b/src/chop/models/llama/configuration_llama_sparse.py index fde0975bb..918df0862 100644 --- a/src/chop/models/llama/configuration_llama_sparse.py +++ b/src/chop/models/llama/configuration_llama_sparse.py @@ -17,7 +17,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" LLaMA model configuration""" +"""LLaMA model configuration""" from transformers.configuration_utils import PretrainedConfig from transformers.utils import logging diff --git a/src/chop/models/llama/modeling_llama_llora.py b/src/chop/models/llama/modeling_llama_llora.py index b45dd8494..2880c3030 100644 --- a/src/chop/models/llama/modeling_llama_llora.py +++ b/src/chop/models/llama/modeling_llama_llora.py @@ -19,7 +19,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" PyTorch LLaMA model.""" +"""PyTorch LLaMA model.""" import math from typing import List, Optional, Tuple, Union diff --git a/src/chop/models/llama/modeling_llama_quantized.py b/src/chop/models/llama/modeling_llama_quantized.py index c31aa9091..46552001e 100644 --- a/src/chop/models/llama/modeling_llama_quantized.py +++ b/src/chop/models/llama/modeling_llama_quantized.py @@ -19,7 +19,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" PyTorch LLaMA model.""" +"""PyTorch LLaMA model.""" import math from typing import List, Optional, Tuple, Union diff --git a/src/chop/models/llama/modeling_llama_sparse.py b/src/chop/models/llama/modeling_llama_sparse.py index f5f37eba0..3c76ed0a9 100644 --- a/src/chop/models/llama/modeling_llama_sparse.py +++ b/src/chop/models/llama/modeling_llama_sparse.py @@ -19,7 +19,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" PyTorch LLaMA model.""" +"""PyTorch LLaMA model.""" import math from typing import List, Optional, Tuple, Union diff --git a/src/chop/models/opt/configuration_opt.py b/src/chop/models/opt/configuration_opt.py index 20826f630..a3fdff6e6 100644 --- a/src/chop/models/opt/configuration_opt.py +++ b/src/chop/models/opt/configuration_opt.py @@ -15,7 +15,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" OPT model configuration""" +"""OPT model configuration""" from transformers.configuration_utils import PretrainedConfig from transformers.utils import logging diff --git a/src/chop/models/opt/configuration_opt_lora.py b/src/chop/models/opt/configuration_opt_lora.py index d5807b3e6..82cfcbcaf 100644 --- a/src/chop/models/opt/configuration_opt_lora.py +++ b/src/chop/models/opt/configuration_opt_lora.py @@ -15,7 +15,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" OPT model configuration""" +"""OPT model configuration""" from transformers.configuration_utils import PretrainedConfig from transformers.utils import logging from .lora_config_opt import parse_opt_lora_config diff --git a/src/chop/models/opt/configuration_opt_quantized.py b/src/chop/models/opt/configuration_opt_quantized.py index dc644a4a0..6ea20f8b1 100644 --- a/src/chop/models/opt/configuration_opt_quantized.py +++ b/src/chop/models/opt/configuration_opt_quantized.py @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" OPT model configuration""" +"""OPT model configuration""" from transformers.configuration_utils import PretrainedConfig from .quant_config_opt import parse_opt_quantized_config diff --git a/src/chop/models/opt/configuration_opt_sparse.py b/src/chop/models/opt/configuration_opt_sparse.py index 3d22d3402..91be85e58 100644 --- a/src/chop/models/opt/configuration_opt_sparse.py +++ b/src/chop/models/opt/configuration_opt_sparse.py @@ -15,7 +15,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" OPT model configuration""" +"""OPT model configuration""" from transformers.configuration_utils import PretrainedConfig from transformers.utils import logging from .sparse_config_opt import parse_opt_sparse_config diff --git a/src/chop/models/opt/modeling_opt.py b/src/chop/models/opt/modeling_opt.py index e88db8c1f..e2214e28e 100644 --- a/src/chop/models/opt/modeling_opt.py +++ b/src/chop/models/opt/modeling_opt.py @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" PyTorch OPT model.""" +"""PyTorch OPT model.""" from typing import List, Optional, Tuple, Union import torch diff --git a/src/chop/models/opt/modeling_opt_lora.py b/src/chop/models/opt/modeling_opt_lora.py index 810cfe0d6..42bc65c82 100644 --- a/src/chop/models/opt/modeling_opt_lora.py +++ b/src/chop/models/opt/modeling_opt_lora.py @@ -16,7 +16,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" PyTorch OPT model.""" +"""PyTorch OPT model.""" import random from typing import Optional, Tuple, Union diff --git a/src/chop/models/opt/modeling_opt_quantized.py b/src/chop/models/opt/modeling_opt_quantized.py index d1086f413..6185c095d 100644 --- a/src/chop/models/opt/modeling_opt_quantized.py +++ b/src/chop/models/opt/modeling_opt_quantized.py @@ -12,7 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" PyTorch OPT model.""" +"""PyTorch OPT model.""" import random from typing import List, Optional, Tuple, Union diff --git a/src/chop/models/opt/modeling_opt_sparse.py b/src/chop/models/opt/modeling_opt_sparse.py index f39a29cc9..afd88bedf 100644 --- a/src/chop/models/opt/modeling_opt_sparse.py +++ b/src/chop/models/opt/modeling_opt_sparse.py @@ -16,7 +16,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" PyTorch OPT model.""" +"""PyTorch OPT model.""" import random from typing import Optional, Tuple, Union