Skip to content

Commit

Permalink
fix imports (modelscope#1796)
Browse files Browse the repository at this point in the history
  • Loading branch information
tastelikefeet authored Aug 22, 2024
1 parent 3d5a07c commit 2ff689e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 2 additions & 4 deletions swift/llm/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from packaging import version

from swift.trainers import TrainerCallback
from swift.tuners import (AdaLoraConfig, AdapterConfig, BOFTConfig, IA3Config, LongLoRAModelType, LoraConfig,
LoRAConfig, NEFTuneConfig, Swift, VeraConfig)
from swift.tuners.llamapro import LLaMAProConfig
from swift.tuners.reft import ReftConfig
from swift.tuners import (AdaLoraConfig, AdapterConfig, BOFTConfig, IA3Config, LLaMAProConfig, LongLoRAModelType,
LoraConfig, LoRAConfig, NEFTuneConfig, ReftConfig, Swift, VeraConfig)
from swift.utils import activate_model_parameters, freeze_model_parameters, get_logger, use_torchacc
from swift.utils.module_mapping import MODEL_KEYS_MAPPING
from .utils import SftArguments, find_all_linears, find_embedding, find_ln, is_adapter
Expand Down
4 changes: 4 additions & 0 deletions swift/tuners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from .neftune import NEFTune, NEFTuneConfig
from .longlora.longlora import LongLoRAModelType, LongLoRAConfig, LongLoRA
from .restuning import ResTuning, ResTuningConfig, ResTuningBypassModule
from .reft import Reft, ReftConfig
from .llamapro import LLaMAPro, LLaMAProConfig
from .peft import (AdaLoraConfig, IA3Config, LoftQConfig, LoHaConfig, LoKrConfig, LoraConfig, VeraConfig,
BOFTConfig, OFTConfig, PeftConfig, PeftModel, PeftModelForCausalLM, PeftModelForSeq2SeqLM,
PeftModelForSequenceClassification, PeftModelForTokenClassification, PrefixTuningConfig,
Expand All @@ -28,6 +30,8 @@
'longlora.longlora': ['LongLoRAModelType', 'LongLoRAConfig', 'LongLoRA'],
'mapping': ['SWIFT_MAPPING', 'SwiftTuners'],
'side': ['Side', 'SideConfig', 'SideModule'],
'reft': ['Reft', 'ReftConfig'],
'llamapro': ['LLaMAPro', 'LLaMAProConfig'],
'neftune': ['NEFTune', 'NEFTuneConfig'],
'restuning': ['ResTuning', 'ResTuningConfig', 'ResTuningBypassModule'],
'peft': [
Expand Down
2 changes: 1 addition & 1 deletion swift/tuners/reft.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from torch import nn

from swift import get_logger
from ..llm.utils.utils import is_pyreft_available
from .utils import SwiftAdapter, SwiftConfig, SwiftOutput

logger = get_logger()
Expand Down Expand Up @@ -52,6 +51,7 @@ class Reft(SwiftAdapter):

@staticmethod
def prepare_model(model: nn.Module, config: ReftConfig, adapter_name: str):
from swift.llm.utils.utils import is_pyreft_available
if not is_pyreft_available():
raise ImportError('Please install pyreft before using ReFT: '
'`pip install git+https://github.com/stanfordnlp/pyreft.git`')
Expand Down

0 comments on commit 2ff689e

Please sign in to comment.