Skip to content

Commit

Permalink
ENH Apply sorting of imports (#2279)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluenote10 authored Dec 13, 2024
1 parent 8bafdb1 commit cf0dfe5
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 75 deletions.
71 changes: 36 additions & 35 deletions src/peft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

__version__ = "0.14.1.dev0"

from .auto import ( # noqa: I001
from .auto import (
AutoPeftModel,
AutoPeftModelForCausalLM,
AutoPeftModelForSequenceClassification,
AutoPeftModelForFeatureExtraction,
AutoPeftModelForQuestionAnswering,
AutoPeftModelForSeq2SeqLM,
AutoPeftModelForSequenceClassification,
AutoPeftModelForTokenClassification,
AutoPeftModelForQuestionAnswering,
AutoPeftModelForFeatureExtraction,
)
from .config import PeftConfig, PromptLearningConfig
from .mapping import (
MODEL_TYPE_TO_PEFT_MODEL_MAPPING,
PEFT_TYPE_TO_CONFIG_MAPPING,
Expand All @@ -34,32 +35,48 @@
from .peft_model import (
PeftModel,
PeftModelForCausalLM,
PeftModelForFeatureExtraction,
PeftModelForQuestionAnswering,
PeftModelForSeq2SeqLM,
PeftModelForSequenceClassification,
PeftModelForTokenClassification,
PeftModelForQuestionAnswering,
PeftModelForFeatureExtraction,
get_layer_status,
get_model_status,
)
from .tuners import (
AdaLoraConfig,
AdaLoraModel,
AdaptionPromptConfig,
AdaptionPromptModel,
LoraConfig,
LoraRuntimeConfig,
LoftQConfig,
BOFTConfig,
BOFTModel,
BoneConfig,
BoneModel,
CPTConfig,
CPTEmbedding,
EvaConfig,
LoraModel,
FourierFTConfig,
FourierFTModel,
HRAConfig,
HRAModel,
IA3Config,
IA3Model,
LNTuningConfig,
LNTuningModel,
LoftQConfig,
LoHaConfig,
LoHaModel,
LoKrConfig,
LoKrModel,
IA3Config,
IA3Model,
AdaLoraConfig,
AdaLoraModel,
BOFTConfig,
BOFTModel,
LoraConfig,
LoraModel,
LoraRuntimeConfig,
MultitaskPromptTuningConfig,
MultitaskPromptTuningInit,
OFTConfig,
OFTModel,
PolyConfig,
PolyModel,
PrefixEncoder,
PrefixTuningConfig,
PromptEmbedding,
Expand All @@ -68,45 +85,29 @@
PromptEncoderReparameterizationType,
PromptTuningConfig,
PromptTuningInit,
MultitaskPromptTuningConfig,
MultitaskPromptTuningInit,
OFTConfig,
OFTModel,
PolyConfig,
PolyModel,
LNTuningConfig,
LNTuningModel,
VBLoRAConfig,
VBLoRAModel,
VeraConfig,
VeraModel,
FourierFTConfig,
FourierFTModel,
XLoraConfig,
XLoraModel,
HRAConfig,
HRAModel,
get_eva_state_dict,
initialize_lora_eva_weights,
CPTEmbedding,
CPTConfig,
BoneConfig,
BoneModel,
)
from .utils import (
TRANSFORMERS_MODELS_TO_PREFIX_TUNING_POSTPROCESS_MAPPING,
PeftType,
TaskType,
bloom_model_postprocess_past_key_value,
cast_mixed_precision_params,
get_peft_model_state_dict,
load_peft_weights,
prepare_model_for_kbit_training,
replace_lora_weights_loftq,
set_peft_model_state_dict,
shift_tokens_right,
load_peft_weights,
cast_mixed_precision_params,
)
from .config import PeftConfig, PromptLearningConfig


__all__ = [
"MODEL_TYPE_TO_PEFT_MODEL_MAPPING",
Expand Down
37 changes: 19 additions & 18 deletions src/peft/tuners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .adaption_prompt import AdaptionPromptConfig, AdaptionPromptModel # noqa: I001
from .adalora import AdaLoraConfig, AdaLoraModel
from .adaption_prompt import AdaptionPromptConfig, AdaptionPromptModel
from .boft import BOFTConfig, BOFTModel
from .bone import BoneConfig, BoneModel
from .cpt import CPTConfig, CPTEmbedding
from .fourierft import FourierFTConfig, FourierFTModel
from .hra import HRAConfig, HRAModel
from .ia3 import IA3Config, IA3Model
from .ln_tuning import LNTuningConfig, LNTuningModel
from .loha import LoHaConfig, LoHaModel
from .lokr import LoKrConfig, LoKrModel
from .lora import (
EvaConfig,
LoftQConfig,
LoraConfig,
LoraModel,
LoftQConfig,
EvaConfig,
LoraRuntimeConfig,
get_eva_state_dict,
initialize_lora_eva_weights,
)
from .loha import LoHaConfig, LoHaModel
from .lokr import LoKrConfig, LoKrModel
from .ia3 import IA3Config, IA3Model
from .adalora import AdaLoraConfig, AdaLoraModel
from .boft import BOFTConfig, BOFTModel
from .p_tuning import PromptEncoder, PromptEncoderConfig, PromptEncoderReparameterizationType
from .prefix_tuning import PrefixEncoder, PrefixTuningConfig
from .prompt_tuning import PromptEmbedding, PromptTuningConfig, PromptTuningInit
from .mixed import MixedModel
from .multitask_prompt_tuning import MultitaskPromptEmbedding, MultitaskPromptTuningConfig, MultitaskPromptTuningInit
from .oft import OFTConfig, OFTModel
from .mixed import MixedModel
from .p_tuning import PromptEncoder, PromptEncoderConfig, PromptEncoderReparameterizationType
from .poly import PolyConfig, PolyModel
from .ln_tuning import LNTuningConfig, LNTuningModel
from .prefix_tuning import PrefixEncoder, PrefixTuningConfig
from .prompt_tuning import PromptEmbedding, PromptTuningConfig, PromptTuningInit
from .vblora import VBLoRAConfig, VBLoRAModel
from .vera import VeraConfig, VeraModel
from .fourierft import FourierFTConfig, FourierFTModel
from .xlora import XLoraConfig, XLoraModel
from .hra import HRAConfig, HRAModel
from .vblora import VBLoRAConfig, VBLoRAModel
from .cpt import CPTConfig, CPTEmbedding
from .bone import BoneConfig, BoneModel


__all__ = [
"AdaLoraConfig",
Expand Down
45 changes: 23 additions & 22 deletions src/peft/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,43 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .integrations import map_cache_to_layer_device_map # noqa: I001
from .integrations import map_cache_to_layer_device_map
from .loftq_utils import replace_lora_weights_loftq
from .peft_types import PeftType, TaskType
from .other import (
TRANSFORMERS_MODELS_TO_PREFIX_TUNING_POSTPROCESS_MAPPING,
TRANSFORMERS_MODELS_TO_LORA_TARGET_MODULES_MAPPING,
CONFIG_NAME,
INCLUDE_LINEAR_LAYERS_SHORTHAND,
SAFETENSORS_WEIGHTS_NAME,
TRANSFORMERS_MODELS_TO_ADALORA_TARGET_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_IA3_TARGET_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_FOURIERFT_TARGET_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_IA3_FEEDFORWARD_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_IA3_TARGET_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_LNTUNING_TARGET_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_VERA_TARGET_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_FOURIERFT_TARGET_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_LORA_TARGET_MODULES_MAPPING,
TRANSFORMERS_MODELS_TO_PREFIX_TUNING_POSTPROCESS_MAPPING,
TRANSFORMERS_MODELS_TO_VBLORA_TARGET_MODULES_MAPPING,
CONFIG_NAME,
TRANSFORMERS_MODELS_TO_VERA_TARGET_MODULES_MAPPING,
WEIGHTS_NAME,
SAFETENSORS_WEIGHTS_NAME,
INCLUDE_LINEAR_LAYERS_SHORTHAND,
_set_trainable,
bloom_model_postprocess_past_key_value,
prepare_model_for_kbit_training,
shift_tokens_right,
transpose,
ModulesToSaveWrapper,
_freeze_adapter,
_get_batch_size,
_get_submodules,
_set_adapter,
_freeze_adapter,
ModulesToSaveWrapper,
_prepare_prompt_learning_config,
_is_valid_match,
infer_device,
_prepare_prompt_learning_config,
_set_adapter,
_set_trainable,
bloom_model_postprocess_past_key_value,
cast_mixed_precision_params,
get_auto_gptq_quant_linear,
get_quantization_config,
id_tensor_storage,
cast_mixed_precision_params,
infer_device,
prepare_model_for_kbit_training,
shift_tokens_right,
transpose,
)
from .save_and_load import get_peft_model_state_dict, set_peft_model_state_dict, load_peft_weights
from .peft_types import PeftType, TaskType
from .save_and_load import get_peft_model_state_dict, load_peft_weights, set_peft_model_state_dict


__all__ = [
"CONFIG_NAME",
Expand Down

0 comments on commit cf0dfe5

Please sign in to comment.