Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix imports #1796

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix imports
  • Loading branch information
tastelikefeet committed Aug 22, 2024
commit 50b016556077569a2dbc292a7908435b93557c9c
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
Loading