|
3 | 3 | # SPDX-License-Identifier: Apache-2.0 |
4 | 4 | # Contact: qubitium@modelcloud.ai, x.com/qubitium |
5 | 5 |
|
6 | | -import inspect |
7 | 6 | import json |
| 7 | +import numpy as np |
8 | 8 | import os |
9 | 9 | import sys |
| 10 | +import transformers |
10 | 11 | import warnings |
| 12 | +from accelerate import init_empty_weights |
11 | 13 | from contextlib import contextmanager |
12 | 14 | from functools import lru_cache |
13 | | -from typing import Any, Optional |
14 | | - |
15 | | -import numpy as np |
16 | | -import torch |
17 | | -import transformers |
18 | | -from accelerate import init_empty_weights |
19 | 15 | from transformers import ( |
20 | 16 | AutoConfig, |
21 | 17 | AutoModelForCausalLM, |
22 | 18 | AutoTokenizer, |
23 | 19 | GenerationConfig, |
24 | 20 | PreTrainedModel, |
25 | 21 | ) |
| 22 | +from typing import Any, Optional |
26 | 23 |
|
| 24 | +import inspect |
| 25 | +import torch |
27 | 26 | from ..nn_modules.qlinear.gguf import ( |
28 | 27 | PRISM_Q1_0_G128_BLOCK_SIZE, |
29 | 28 | PRISM_Q1_0_G128_NAME, |
@@ -991,9 +990,6 @@ def _normalize_rope_parameters_config_compat(config: Any) -> None: |
991 | 990 | legacy_rope_scaling = getattr(config, "rope_scaling", None) |
992 | 991 | rope_parameters = dict(legacy_rope_scaling) if isinstance(legacy_rope_scaling, dict) else dict(rope_parameters or {}) |
993 | 992 |
|
994 | | - if not rope_parameters and getattr(config, "rope_theta", None) is None and getattr(config, "default_theta", None) is None: |
995 | | - return |
996 | | - |
997 | 993 | rope_parameters.setdefault("rope_type", rope_parameters.get("type", "default")) |
998 | 994 | if rope_parameters.get("rope_theta") is None: |
999 | 995 | rope_theta = getattr(config, "rope_theta", None) |
@@ -1138,6 +1134,10 @@ def normalize_hf_config_compat(config: Any, *, trust_remote_code: bool = False) |
1138 | 1134 | # some config classes synchronize `rope_scaling` from `rope_parameters` and |
1139 | 1135 | # can drop legacy keys like `rope_scaling["type"]`. |
1140 | 1136 | _normalize_remote_code_config_compat(config) |
| 1137 | + # Some config classes can still nullify rope_parameters during the second |
| 1138 | + # remote-code field normalization pass. Ensure final config always carries |
| 1139 | + # valid rope_parameters for model classes that directly subscript it. |
| 1140 | + _normalize_rope_parameters_config_compat(config) |
1141 | 1141 |
|
1142 | 1142 |
|
1143 | 1143 | def prepare_remote_code_compat(config: Any) -> None: |
|
0 commit comments