Repository Analysis

huggingface/peft

🤗 PEFT: State-of-the-art Parameter-Efficient Fine-Tuning.

20.9 Moderate AI signal View on GitHub
20.9
Adjusted Score
20.9
Raw Score
100%
Time Factor
2026-05-29
Last Push
21,206
Stars
Python
Language
170,191
Lines of Code
709
Files
2702
Pattern Hits
2026-05-31
Scan Date

Score History

Severity Breakdown

CRITICAL 35HIGH 200MEDIUM 53LOW 2414

Pattern Findings

2702 matches across 15 categories. Click a row to expand file-level details.

Cross-File Repetition187 hits · 935 pts
SeverityFileLineSnippet
HIGHtests/test_gpu_examples.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gpu_examples.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gpu_examples.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gpu_examples.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gpu_examples.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gpu_examples.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gpu_examples.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_vision_models.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gptqmodel.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gptqmodel.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_common_gpu.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_torch_compile.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109
HIGHtests/test_gpu_examples.py0test the causallm training on a single gpu device. the test would simply fail if the adapters are not set correctly.
HIGHtests/test_gpu_examples.py0test the causallm training on a single gpu device. the test would simply fail if the adapters are not set correctly.
HIGHtests/test_gpu_examples.py0test the causallm training on a single gpu device. the test would simply fail if the adapters are not set correctly.
HIGHtests/test_gpu_examples.py0test the causallm training on a single gpu device. the test would simply fail if the adapters are not set correctly.
HIGHtests/test_gptqmodel.py0test the causallm training on a single gpu device. the test would simply fail if the adapters are not set correctly.
HIGHtests/test_gptqmodel.py0test the causallm training on a single gpu device. the test would simply fail if the adapters are not set correctly.
HIGHtests/test_gpu_examples.py0test the causallm training on a multi-accelerator device. the test would simply fail if the adapters are not set correct
HIGHtests/test_gptqmodel.py0test the causallm training on a multi-accelerator device. the test would simply fail if the adapters are not set correct
HIGHtests/test_gptqmodel.py0test the causallm training on a multi-accelerator device. the test would simply fail if the adapters are not set correct
HIGHdocs/source/developer_guides/lora.md0run forward and backward passes for gradient estimation.
HIGHexamples/lora_ga_finetuning/README.md0run forward and backward passes for gradient estimation.
HIGHexamples/lora_ga_finetuning/lora_ga_finetuning.py0run forward and backward passes for gradient estimation.
HIGHexamples/boft_controlnet/utils/tracemalloc.py0get resident set size memory for the current process
HIGH…_modeling/peft_lora_clm_accelerate_ds_zero3_offload.py0get resident set size memory for the current process
HIGHexamples/oft_dreambooth/train_dreambooth.py0get resident set size memory for the current process
HIGHexamples/hra_dreambooth/utils/tracemalloc.py0get resident set size memory for the current process
HIGHexamples/stable_diffusion/train_dreambooth.py0get resident set size memory for the current process
HIGHexamples/lora_dreambooth/train_dreambooth.py0get resident set size memory for the current process
HIGHexamples/boft_dreambooth/utils/tracemalloc.py0get resident set size memory for the current process
HIGH…ation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py0get resident set size memory for the current process
HIGHexamples/waveft_finetuning/waveft_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructio
HIGHexamples/hira_finetuning/hira_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructio
HIGHexamples/olora_finetuning/olora_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructio
HIGHexamples/shira_finetuning/shira_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructio
HIGHexamples/oft_dreambooth/train_dreambooth.py0a dataset to prepare the instance and class images with the prompts for fine-tuning the model. it pre-processes the imag
HIGHexamples/hra_dreambooth/utils/dataset.py0a dataset to prepare the instance and class images with the prompts for fine-tuning the model. it pre-processes the imag
HIGHexamples/stable_diffusion/train_dreambooth.py0a dataset to prepare the instance and class images with the prompts for fine-tuning the model. it pre-processes the imag
HIGHexamples/lora_dreambooth/train_dreambooth.py0a dataset to prepare the instance and class images with the prompts for fine-tuning the model. it pre-processes the imag
HIGHexamples/boft_dreambooth/utils/dataset.py0a dataset to prepare the instance and class images with the prompts for fine-tuning the model. it pre-processes the imag
HIGHsrc/peft/peft_model.py0add an adapter to the model based on the passed configuration. this adapter is not trained. to load a trained adapter, c
HIGHsrc/peft/peft_model.py0add an adapter to the model based on the passed configuration. this adapter is not trained. to load a trained adapter, c
HIGHsrc/peft/peft_model.py0add an adapter to the model based on the passed configuration. this adapter is not trained. to load a trained adapter, c
HIGHsrc/peft/peft_model.py0add an adapter to the model based on the passed configuration. this adapter is not trained. to load a trained adapter, c
HIGHsrc/peft/peft_model.py0deletes an existing adapter. args: adapter_name (str): name of the adapter to be deleted.
HIGHsrc/peft/tuners/tuners_utils.py0deletes an existing adapter. args: adapter_name (str): name of the adapter to be deleted.
HIGHsrc/peft/tuners/waveft/model.py0deletes an existing adapter. args: adapter_name (str): name of the adapter to be deleted.
HIGHsrc/peft/utils/other.py0return all adapter names that can be found on this module.
HIGHsrc/peft/utils/other.py0return all adapter names that can be found on this module.
HIGHsrc/peft/utils/other.py0return all adapter names that can be found on this module.
HIGHsrc/peft/tuners/tuners_utils.py0return all adapter names that can be found on this module.
HIGHsrc/peft/utils/other.py0check if the arguments are compatible with the configs and state of the model
HIGHsrc/peft/tuners/road/layer.py0check if the arguments are compatible with the configs and state of the model
HIGHsrc/peft/tuners/lora/layer.py0check if the arguments are compatible with the configs and state of the model
HIGHsrc/peft/tuners/lora/layer.py0check if the arguments are compatible with the configs and state of the model
HIGHsrc/peft/utils/other.py0helper function to check if the given adapter(s) can be set. return the name of the adapter to be set or none if no adap
HIGHsrc/peft/utils/other.py0helper function to check if the given adapter(s) can be set. return the name of the adapter to be set or none if no adap
HIGHsrc/peft/utils/other.py0helper function to check if the given adapter(s) can be set. return the name of the adapter to be set or none if no adap
HIGHsrc/peft/utils/other.py0enable or disable gradients on the given adapter(s). args: adapter_name (`str` or `sequence[str]`): the name of the adap
127 more matches not shown…
Hyper-Verbose Identifiers1192 hits · 902 pts
SeverityFileLineSnippet
LOWtests/test_mixed.py448 def test_target_different_layers(self, config0, config1):
LOWtests/test_mixed.py489 def test_target_last_layer_same_type(self, config0, config1):
LOWtests/test_mixed.py518 def test_target_first_layer_same_type(self, config0, config1):
LOWtests/test_mixed.py666 def test_get_nb_trainable_parameters(self):
LOWtests/test_mixed.py695 def test_incompatible_config_raises(self):
LOWtests/test_seq_classifier.py302 def prepare_inputs_for_testing(self):
LOWtests/test_seq_classifier.py309 def test_attributes_parametrized(self, model_id, config_cls, config_kwargs):
LOWtests/test_seq_classifier.py319 def test_prepare_for_training_parametrized(self, model_id, config_cls, config_kwargs):
LOWtests/test_seq_classifier.py324 def test_prompt_tuning_text_prepare_for_training(self, model_id, config_cls, config_kwargs):
LOWtests/test_seq_classifier.py341 def test_save_pretrained_pickle(self, model_id, config_cls, config_kwargs):
LOWtests/test_seq_classifier.py347 def test_save_pretrained_selected_adapters(self, model_id, config_cls, config_kwargs):
LOWtests/test_seq_classifier.py353 def test_save_pretrained_selected_adapters_pickle(self, model_id, config_cls, config_kwargs):
LOWtests/test_seq_classifier.py361 def test_from_pretrained_config_construction(self, model_id, config_cls, config_kwargs):
LOWtests/test_seq_classifier.py366 def test_modules_to_save_correctly_set(self, model_id, config_cls, config_kwargs):
LOWtests/test_lora_conversion.py78 def test_no_peft_layer_raises(self):
LOWtests/test_lora_conversion.py85 def test_prompt_learning_model_raises(self):
LOWtests/test_lora_conversion.py96 def test_peft_model_but_no_support_raises(self):
LOWtests/test_lora_conversion.py106 def test_model_with_unsupported_layers_raises(self):
LOWtests/test_lora_conversion.py122 def test_targeted_modules_identical(self, lokr_model):
LOWtests/test_lora_conversion.py138 def test_targeted_modules_identical_target_modules_str(self):
LOWtests/test_lora_conversion.py157 def test_fixed_rank_lora_config(self, lokr_model):
LOWtests/test_lora_conversion.py167 def test_dynamic_rank_lora_config(self, lokr_model):
LOWtests/test_lora_conversion.py193 def test_threshold_wrong_value_raises(self, lokr_model):
LOWtests/test_lora_conversion.py203 def test_rank_higher_than_weight_dim_raises(self, lokr_model):
LOWtests/test_lora_conversion.py214 def test_converting_transformers_model_works(self, lokr_model, tmp_path):
LOWtests/test_lora_conversion.py245 def test_converted_lora_approximates_original_adapter(self, lokr_model):
LOWtests/test_lora_conversion.py334 def test_model_without_peft_config(self, lokr_model):
LOWtests/test_lora_conversion.py372 def test_converted_lora_to_lora_works_and_warns(self):
LOWtests/test_lora_conversion.py410 def test_converted_lora_with_multiple_adapters(self, lokr_model):
LOWtests/test_lora_conversion.py456 def test_convert_model_with_modules_to_save(self):
LOWtests/test_lora_conversion.py496 def test_convert_model_with_trainable_bias_raises(self, bias):
LOWtests/test_lora_conversion.py605 def test_miss_supports_lora_conversion(self, miss_model_standard, miss_model_mini, miss_model_bat):
LOWtests/test_lora_conversion.py610 def test_miss_standard_exact_conversion(self, miss_model_standard):
LOWtests/test_lora_conversion.py627 def test_miss_mini_exact_conversion(self, miss_model_mini):
LOWtests/test_lora_conversion.py644 def test_miss_bat_approximate_conversion(self, miss_model_bat):
LOWtests/test_lora_conversion.py666 def test_miss_targeted_modules_identical(self, miss_model_standard):
LOWtests/test_tuners_utils.py450 def test_one_targeted_module_regex(self):
LOWtests/test_tuners_utils.py455 def test_two_targeted_module_regex(self):
LOWtests/test_tuners_utils.py460 def test_one_targeted_module_list(self):
LOWtests/test_tuners_utils.py465 def test_two_targeted_module_list(self):
LOWtests/test_tuners_utils.py526 def test_two_excluded_module_regex(self):
LOWtests/test_tuners_utils.py531 def test_two_excluded_module_list(self):
LOWtests/test_tuners_utils.py536 def test_multiple_excluded_modules_list(self):
LOWtests/test_tuners_utils.py794 def test_available_adapters_small(self, small_model):
LOWtests/test_tuners_utils.py800 def test_available_adapters_large(self, large_model):
LOWtests/test_tuners_utils.py806 def test_devices_all_cpu_small(self, small_model):
LOWtests/test_tuners_utils.py812 def test_devices_all_cpu_large(self, large_model):
LOWtests/test_tuners_utils.py912 def test_base_model_type_small(self, small_model):
LOWtests/test_tuners_utils.py916 def test_base_model_type_large(self, large_model):
LOWtests/test_tuners_utils.py920 def test_base_model_type_transformers_automodel(self):
LOWtests/test_tuners_utils.py929 def test_adapter_model_type_small(self, small_model):
LOWtests/test_tuners_utils.py933 def test_adapter_model_type_large(self, large_model):
LOWtests/test_tuners_utils.py971 def test_model_disabled_small(self, small_model):
LOWtests/test_tuners_utils.py976 def test_model_disabled_large(self, large_model):
LOWtests/test_tuners_utils.py981 def test_model_enabled_irregular(self, large_model):
LOWtests/test_tuners_utils.py1018 def test_model_active_adapters_small(self, small_model):
LOWtests/test_tuners_utils.py1022 def test_model_active_adapters_large(self, large_model):
LOWtests/test_tuners_utils.py1030 def test_model_active_adapters_irregular(self, large_model):
LOWtests/test_tuners_utils.py1102 def test_model_merged_adapters_irregular(self, large_model):
LOWtests/test_tuners_utils.py1110 def test_model_requires_grad_model_small(self, small_model):
1132 more matches not shown…
Hallucination Indicators35 hits · 440 pts
SeverityFileLineSnippet
CRITICALtests/test_lora_conversion.py468 lokr_model.base_model.model.model.decoder.layers[0].fc1.modules_to_save.default.weight.data.mul_(-10.0)
CRITICALtests/test_lora_conversion.py469 lokr_model.base_model.model.model.decoder.layers[0].fc1.modules_to_save.default.bias.data.mul_(-10.0)
CRITICALtests/test_cpt.py247 emb = model.prompt_encoder.default.embedding.weight.data.clone().detach()
CRITICALtests/test_cpt.py263 assert torch.all(model.prompt_encoder.default.embedding.weight.data.clone().detach().cpu() == emb.cpu())
CRITICALtests/test_cpt.py277 emb = model.prompt_encoder.default.embedding.weight.data.clone().detach()
CRITICALtests/test_cpt.py294 assert torch.all(model.prompt_encoder.default.embedding.weight.data.clone().detach().cpu() == emb.cpu())
CRITICALtests/test_trainable_tokens.py228 initial_delta = model.model.model.embed_tokens.trainable_tokens_delta.default.clone()
CRITICALtests/test_trainable_tokens.py229 initial_originals = model.model.model.embed_tokens.trainable_tokens_original.default.clone()
CRITICALtests/test_trainable_tokens.py680 assert merged_model.model.decoder.embed_tokens.weight.data_ptr() == merged_model.lm_head.weight.data_ptr()
CRITICALtests/test_trainable_tokens.py717 assert merged_model.model.decoder.embed_tokens.weight.data_ptr() == merged_model.lm_head.weight.data_ptr()
CRITICALtests/test_trainable_tokens.py816 expected_changed_weights = peft_model.model.model.embed_tokens.trainable_tokens_delta.default.data.clone()
CRITICALtests/test_gpu_examples.py2194 embed_params = model.base_model.model.model.decoder.embed_tokens.original_module.weight.numel()
CRITICALtests/test_initialization.py5545 model.base_model.model.model.embed_tokens.weight.data_ptr()
CRITICALtests/test_initialization.py5546 != model.base_model.model.lm_head.weight.data_ptr()
CRITICALtests/test_initialization.py5017 peft_model.prompt_encoder.default.embedding.weight.data.fill_(1.0)
CRITICALtests/test_initialization.py5234 embed_np = dict(model.base_model.model.model.embed_tokens.named_parameters())
CRITICALtests/test_initialization.py5294 embed_np = dict(model.base_model.model.model.embed_tokens.named_parameters())
CRITICALtests/test_initialization.py5469 shared_np = dict(model.base_model.model.model.shared.named_parameters())
CRITICALtests/test_target_parameters.py386 gate_proj_1_0.lora_A.default.weight.data.copy_(gate_proj_0_0.lora_A.default.weight.data)
CRITICALtests/test_target_parameters.py387 gate_proj_1_1.lora_A.default.weight.data.copy_(gate_proj_0_1.lora_A.default.weight.data)
CRITICALtests/test_target_parameters.py388 gate_proj_1_0.lora_B.default.weight.data.copy_(gate_proj_0_0.lora_B.default.weight.data)
CRITICALtests/test_target_parameters.py389 gate_proj_1_1.lora_B.default.weight.data.copy_(gate_proj_0_1.lora_B.default.weight.data)
CRITICALtests/test_decoder_models.py777 layers[0].mlp.up_proj.base_layer.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py778 == layers[1].mlp.up_proj.base_layer.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py779 and layers[2].mlp.up_proj.base_layer.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py780 == layers[3].mlp.up_proj.base_layer.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py783 layers[0].mlp.up_proj.base_layer.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py784 != layers[2].mlp.up_proj.base_layer.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py787 layers[0].mlp.up_proj.lora_A.default.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py788 != layers[1].mlp.up_proj.lora_A.default.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py789 and layers[2].mlp.up_proj.lora_A.default.weight.data.storage().data_ptr()
CRITICALtests/test_decoder_models.py790 != layers[3].mlp.up_proj.lora_A.default.weight.data.storage().data_ptr()
CRITICALtests/test_custom_models.py3695 lm_head_keys = list(model.base_model.model.lm_head.modules_to_save.keys())
CRITICALtests/test_custom_models.py3698 embed_token_keys = list(model.base_model.model.model.decoder.embed_tokens.modules_to_save.keys())
CRITICALsrc/peft/tuners/tuners_utils.py609 model.lm_head.weight.data = model.model.embed_tokens.weight.data.clone()
Unused Imports548 hits · 406 pts
SeverityFileLineSnippet
LOWtests/test_lorafa.py15
LOWtests/test_trainable_tokens.py15
LOWtests/test_loraplus.py14
LOWexamples/stable_diffusion/inc_flux_lora_hpu.py26
LOWsrc/peft/config.py14
LOWsrc/peft/__init__.py17
LOWsrc/peft/__init__.py17
LOWsrc/peft/__init__.py17
LOWsrc/peft/__init__.py17
LOWsrc/peft/__init__.py17
LOWsrc/peft/__init__.py17
LOWsrc/peft/__init__.py17
LOWsrc/peft/__init__.py17
LOWsrc/peft/__init__.py27
LOWsrc/peft/__init__.py27
LOWsrc/peft/__init__.py28
LOWsrc/peft/__init__.py29
LOWsrc/peft/__init__.py29
LOWsrc/peft/__init__.py29
LOWsrc/peft/__init__.py29
LOWsrc/peft/__init__.py29
LOWsrc/peft/__init__.py36
LOWsrc/peft/__init__.py37
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py38
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
LOWsrc/peft/__init__.py49
488 more matches not shown…
Over-Commented Block350 hits · 340 pts
SeverityFileLineSnippet
LOWsetup.py1# Copyright 2023 The HuggingFace Team. All rights reserved.
LOWsetup.py101# Push the tag to git:
LOWtests/test_mixed.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_seq_classifier.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_lora_conversion.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_tuners_utils.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_tuners_utils.py61# Implements tests for regex matching logic common for all BaseTuner subclasses, and
LOWtests/conftest.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_xlora.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_hub_features.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_lorafa.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_cpt.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_low_level_api.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_lora_megatron.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_trainable_tokens.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_gpu_examples.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_integrations.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_poly.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/testing_utils.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_loraplus.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_adaption_prompt.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_initialization.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_initialization.py4781 def __getattr__(self, item):
LOWtests/test_initialization.py4801 # (attn): VisionSdpaAttention(
LOWtests/test_initialization.py4821 # (model): Qwen2VLModel(
LOWtests/test_initialization.py4881 # (visual): Qwen2VisionTransformerPretrainedModel(
LOWtests/test_initialization.py4901 # (merger): PatchMerger(
LOWtests/test_initialization.py4921 # (mlp): Qwen2MLP(
LOWtests/test_target_parameters.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_pvera.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_vision_models.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_gptqmodel.py1# Note: These tests were copied from test_common_gpu.py and test_gpu_examples.py as they can run on CPU too.
LOWtests/test_decoder_models.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_encoder_decoder_models.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_multitask_prompt_tuning.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_lora_ga.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/testing_common.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_common_gpu.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_cartridge.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_vblora.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_config.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_randlora.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_shira.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_boft.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_feature_extraction_models.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_helpers.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_stablediffusion.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_lora_variants.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_incremental_pca.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_auto.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_other.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_arrow.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/test_vera.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_torch_compile.py1# Copyright 2024-present the HuggingFace Inc. team.
LOWtests/test_custom_models.py1# Copyright 2023-present the HuggingFace Inc. team.
LOWtests/test_mapping.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/training/lora_tp.py1# Copyright 2026-present the HuggingFace Inc. team.
LOWtests/training/training.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/training/adapters.py1# Copyright 2025-present the HuggingFace Inc. team.
LOWtests/regression/test_regression.py1# Copyright 2023-present the HuggingFace Inc. team.
290 more matches not shown…
Deep Nesting248 hits · 225 pts
SeverityFileLineSnippet
LOWtests/test_lora_conversion.py576
LOWtests/test_trainable_tokens.py586
LOWtests/test_gpu_examples.py6527
LOWtests/test_gpu_examples.py6581
LOWtests/test_gpu_examples.py5814
LOWtests/testing_utils.py318
LOWtests/test_initialization.py1355
LOWtests/test_initialization.py4218
LOWtests/test_initialization.py4395
LOWtests/test_initialization.py4427
LOWtests/test_decoder_models.py398
LOWtests/testing_common.py563
LOWtests/testing_common.py1159
LOWtests/testing_common.py1263
LOWtests/testing_common.py1295
LOWtests/testing_common.py1355
LOWtests/testing_common.py1464
LOWtests/test_other.py650
LOWtests/test_arrow.py474
LOWtests/test_custom_models.py2551
LOWmethod_comparison/sanitizer.py6
LOWmethod_comparison/app.py194
LOWmethod_comparison/text_generation_benchmark/run.py139
LOWmethod_comparison/text_generation_benchmark/utils.py205
LOWmethod_comparison/MetaMathQA/utils.py210
LOWmethod_comparison/MetaMathQA/utils.py359
LOW…les/sequence_classification/peft_no_lora_accelerate.py79
LOWexamples/boft_controlnet/train_controlnet.py86
LOWexamples/boft_controlnet/utils/pipeline_controlnet.py53
LOWexamples/boft_controlnet/utils/pipeline_controlnet.py166
LOWexamples/boft_controlnet/utils/dataset.py82
LOWexamples/boft_controlnet/utils/dataset.py136
LOW…ture_extraction/peft_lora_embedding_semantic_search.py210
LOW…_modeling/peft_lora_clm_accelerate_ds_zero3_offload.py110
LOWexamples/arrow_multitask/arrow_phi3_mini.py120
LOWexamples/loftq_finetuning/int8_correction.py68
LOWexamples/loftq_finetuning/train_gsm8k_llama.py297
LOW…orthogonal_subspace_learning/osf_continual_learning.py51
LOW…orthogonal_subspace_learning/osf_continual_learning.py99
LOW…orthogonal_subspace_learning/osf_continual_learning.py142
LOWexamples/orthogonal_subspace_learning/utils.py42
LOWexamples/oft_dreambooth/train_dreambooth.py590
LOWexamples/hra_dreambooth/train_dreambooth.py82
LOWexamples/qalora_finetuning/qalora_gptq_finetuning.py23
LOWexamples/stable_diffusion/train_dreambooth.py754
LOWexamples/stable_diffusion/convert_sd_adapter_to_peft.py285
LOWexamples/lora_dreambooth/train_dreambooth.py580
LOWexamples/corda_finetuning/datautils.py106
LOWexamples/sft/utils.py86
LOWexamples/boft_dreambooth/train_dreambooth.py82
LOW…ation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py104
LOW…s/int8_training/peft_adalora_whisper_large_training.py423
LOWscripts/log_reports.py19
LOWscripts/train_memory.py109
LOWsrc/peft/peft_model.py3227
LOWsrc/peft/peft_model.py212
LOWsrc/peft/peft_model.py421
LOWsrc/peft/peft_model.py642
LOWsrc/peft/peft_model.py761
LOWsrc/peft/peft_model.py928
188 more matches not shown…
Self-Referential Comments24 hits · 70 pts
SeverityFileLineSnippet
MEDIUMtests/test_trainable_tokens.py1205 # Create a composite model with two BART sub-models
MEDIUMtests/test_lora_ga.py130 # Create a fresh model and load the saved state
MEDIUMtests/test_helpers.py669 # Create a minimal dummy MoE model with fused 3D weights
MEDIUMtests/test_custom_models.py4271 # Create a weighted adapter combining both adapters and check that its output is same as setting multiple
MEDIUMmethod_comparison/app.py102 # Create an empty figure.
MEDIUMexamples/boft_controlnet/train_controlnet.py537 # Create the pipeline using using the trained modules and save it.
MEDIUMexamples/arrow_multitask/arrow_phi3_mini.py362 # Creating the Arrow model
MEDIUM…orthogonal_subspace_learning/osf_continual_learning.py57 # Create a simple dataloader
MEDIUMexamples/oft_dreambooth/train_dreambooth.py1079 # Create the pipeline using using the trained modules and save it.
MEDIUMexamples/hra_dreambooth/train_dreambooth.sh4# Define the UNIQUE_TOKEN, CLASS_TOKENs, and SUBJECT_NAMES
MEDIUMexamples/stable_diffusion/train_dreambooth.py1239 # Create the pipeline using using the trained modules and save it.
MEDIUMexamples/stable_diffusion/convert_sd_adapter_to_peft.py409 # Create a corresponding adapter info
MEDIUMexamples/lora_dreambooth/train_dreambooth.py1071 # Create the pipeline using using the trained modules and save it.
MEDIUMexamples/boft_dreambooth/train_dreambooth.sh5# Define the UNIQUE_TOKEN, CLASS_TOKENs, and SUBJECT_NAMES
MEDIUMexamples/lora_ga_finetuning/lora_ga_finetuning.py167 # Create a simple DataLoader for gradient estimation
MEDIUMsrc/peft/utils/other.py1643 # Create the causal mask with fixed shape in advance, to reduce recompilations. If the function to create
MEDIUMsrc/peft/tuners/tuners_utils.py1762 # Create a reverse lookup for other_module_names to quickly check suffix matches
MEDIUMsrc/peft/tuners/boft/layer.py177 # Create a mask with 1s for matrices to be replaced with identity and 0s otherwise
MEDIUMsrc/peft/tuners/waveft/layer.py133 # Create a padded spectrum matrix with additional rows and columns
MEDIUMsrc/peft/tuners/waveft/layer.py144 # Create the padded dense spectrum matrix
MEDIUMsrc/peft/tuners/waveft/waverec2d.py6# This file contains code derived from PyTorch-Wavelet-Toolbox:
MEDIUMsrc/peft/tuners/osf/model.py103 # Create a new or update an existing OSF layer in place
MEDIUMsrc/peft/tuners/xlora/model.py244 # Create an empty LoraModel
MEDIUMsrc/peft/tuners/adalora/model.py348 """This method is not supported for AdaLoRA, use LoRA instead."""
Decorative Section Separators17 hits · 57 pts
SeverityFileLineSnippet
MEDIUMtests/test_arrow.py30# ─── Fixtures ──────────────────────────────────────────────────────────
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py19# ==========================================
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py21# ==========================================
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py47# ==========================================
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py49# ==========================================
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py146# ==========================================
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py148# ==========================================
MEDIUM…etuning/sequence_classification_finetune_monteclora.py21# ----------------------------------------------------------------------------
MEDIUM…etuning/sequence_classification_finetune_monteclora.py23# ----------------------------------------------------------------------------
MEDIUM…etuning/sequence_classification_finetune_monteclora.py29# ----------------------------------------------------------------------------
MEDIUM…etuning/sequence_classification_finetune_monteclora.py31# ----------------------------------------------------------------------------
MEDIUM…etuning/sequence_classification_finetune_monteclora.py42# ----------------------------------------------------------------------------
MEDIUM…etuning/sequence_classification_finetune_monteclora.py44# ----------------------------------------------------------------------------
MEDIUM…etuning/sequence_classification_finetune_monteclora.py162# ----------------------------------------------------------------------------
MEDIUM…etuning/sequence_classification_finetune_monteclora.py164# ----------------------------------------------------------------------------
MEDIUMsrc/peft/tuners/lora/layer.py766# ------------------------------------------------------------------------------------------
MEDIUMsrc/peft/tuners/lora/layer.py769# ------------------------------------------------------------------------------------------
Docstring Block Structure8 hits · 40 pts
SeverityFileLineSnippet
HIGHexamples/boft_controlnet/utils/pipeline_controlnet.py196 Function invoked when calling the pipeline for generation. Args: prompt (`str` or `List[st
HIGHexamples/qalora_finetuning/qalora_gptq_finetuning.py109 Tokenize text data and prepare it for language modeling. Args: examples: Dataset examples with 'text'
HIGHsrc/peft/peft_model.py1189Get the status of each adapter layer in the model. This method returns a list of `TunerLayerStatus` dataclass i
HIGHsrc/peft/peft_model.py1219Get the status of tuners of the model. This method returns a `TunerModelStatus` dataclass instance, which conta
HIGHsrc/peft/peft_model.py3228Get the status of each adapter layer in the model. This function returns a list of `TunerLayerStatus` dataclass ins
HIGHsrc/peft/peft_model.py3355Get the status of tuners of the model. This function returns a `TunerModelStatus` dataclass instance, which contain
HIGHsrc/peft/tuners/tuners_utils.py358 A private method to prepare the adapter config. For transformers based models, if `peft_config.target_
HIGHsrc/peft/tuners/tuners_utils.py1710Find the minimal set of target modules that is sufficient to separate them from the other modules. Sometimes, a ver
Redundant / Tautological Comments25 hits · 38 pts
SeverityFileLineSnippet
LOWtests/test_xlora.py317 # Set it to 2 and make sure it actually is
LOWtests/test_xlora.py322 # Set it to None and make sure it is 1/n
LOWtests/test_lorafa.py144 # Check if lora_A weights have not changed
LOWtests/test_lorafa.py149 # Check if lora_B weights are non-zero
LOWtests/test_config.py412 # Check if the user supplied timing values that will certainly fail because it breaks
LOWmethod_comparison/MetaMathQA/utils.py440 # Check if the string represents a fraction.
LOWexamples/waveft_finetuning/waveft_finetuning.py50 # Set device_map to the right place when enabling DDP.
LOWexamples/olora_finetuning/olora_finetuning.py51 # Set device_map to the right place when enabling DDP.
LOWexamples/alora_finetuning/alora_finetuning.py186 # Print results
LOWexamples/qalora_finetuning/qalora_gptq_finetuning.py50 # Check if the model has GPTQ quantization attributes
LOWexamples/qalora_finetuning/qalora_gptq_finetuning.py78 # Check if we already have a cached quantized version
LOWexamples/shira_finetuning/shira_finetuning.py49 # Set device_map to the right place when enabling DDP.
LOWexamples/sft/utils.py194 # Check if the model is quantized
LOW…s/int8_training/peft_adalora_whisper_large_training.py707 # Check if rank_pattern exists before calling update_and_allocate
LOWsrc/peft/utils/other.py1550 # Check if this is the embedding layer (use endswith to allow flexible matching)
LOWsrc/peft/utils/other.py1555 # Check if this target layer matches any tied module (considering nested structures)
LOWsrc/peft/utils/other.py1563 # Check if all tied layers have the same indices
LOWsrc/peft/tuners/tuners_utils.py1779 # Check if adding this suffix covers the item
LOWsrc/peft/tuners/adamss/model.py98 # Check if already an Adamss layer
LOWsrc/peft/tuners/hira/layer.py138 fan_in_fan_out: bool = False, # Set this to True if the layer to replace stores weight like (fan_in, fan_out)
LOWsrc/peft/tuners/hira/layer.py299 fan_in_fan_out: bool = False, # Set this to True if the layer to replace stores weight like (fan_in, fan_out)
LOWsrc/peft/tuners/adalora/config.py94 # Check if 'r' has been set to a non-default value
LOWsrc/peft/tuners/lora/loraga.py136 # Check if any supported layers were found
LOWsrc/peft/tuners/oft/layer.py548 fan_in_fan_out: bool = False, # Set this to True if the layer to replace stores weight like (fan_in, fan_out)
LOWsrc/peft/tuners/oft/layer.py703 fan_in_fan_out: bool = False, # Set this to True if the layer to replace stores weight like (fan_in, fan_out)
Excessive Try-Catch Wrapping34 hits · 32 pts
SeverityFileLineSnippet
LOWtests/testing_utils.py370 except Exception:
MEDIUMtests/test_initialization.py310def test_lora_init_orthogonal_half_precision_dtype(self, dtype):
LOWtests/test_initialization.py313 except Exception:
LOWtests/test_arrow.py336 except Exception:
LOWtests/test_custom_models.py2260 except Exception:
LOWtests/test_custom_models.py2300 except Exception:
LOWtests/test_custom_models.py2339 except Exception:
LOWtests/test_custom_models.py2378 except Exception:
LOWmethod_comparison/app.py284 except Exception as exc:
LOWmethod_comparison/app.py299 except Exception as exc:
LOWmethod_comparison/app.py313 except Exception as e:
LOWmethod_comparison/app.py334 except Exception as e:
LOWmethod_comparison/text_generation_benchmark/run.py214 except Exception as exc:
LOWmethod_comparison/text_generation_benchmark/run.py299 except Exception as exc:
LOWmethod_comparison/MetaMathQA/run.py386 except Exception as exc:
LOWmethod_comparison/MetaMathQA/utils.py355 except Exception as exc:
LOWmethod_comparison/MetaMathQA/utils.py371 except Exception as exc:
LOWmethod_comparison/MetaMathQA/utils.py379 except Exception as exc:
LOWmethod_comparison/MetaMathQA/utils.py508 except Exception as exc:
LOWmethod_comparison/MetaMathQA/utils.py516 except Exception as exc:
LOWexamples/ephemeral_gpu_offloading/load_with_dora.py75 except Exception as e:
LOWexamples/ephemeral_gpu_offloading/load_with_dora.py80 except Exception as e:
LOWexamples/qalora_finetuning/qalora_gptq_finetuning.py69 except Exception as e:
LOWexamples/adamss_finetuning/test_adamss_quick.py169except Exception as e:
LOWsrc/peft/config.py116 except Exception:
LOWsrc/peft/config.py258 except Exception as exc:
LOWsrc/peft/config.py322 except Exception:
MEDIUMsrc/peft/peft_model.py176def active_adapters(self) -> list[str]:
LOWsrc/peft/peft_model.py1146 except Exception: # something went wrong, roll back
LOWsrc/peft/mixed_model.py242 except Exception: # something went wrong, roll back
LOWsrc/peft/helpers.py162 except Exception:
LOWsrc/peft/utils/other.py1452 except Exception as e:
LOWsrc/peft/tuners/boft/layer.py96 except Exception as e:
LOWsrc/peft/tuners/adamss/layer.py179 except Exception as e:
AI Slop Vocabulary15 hits · 31 pts
SeverityFileLineSnippet
MEDIUMtests/test_trainable_tokens.py664 # for this we can leverage the fact that emb_out(1/emb_in(x)) is embed_dim on the
MEDIUMtests/test_trainable_tokens.py701 # for this we can leverage the fact that emb_out(1/emb_in(x)) is embed_dim on the
MEDIUMtests/test_trainable_tokens.py762 # for this we can leverage the fact that emb_out(1/emb_in(x)) is embed_dim on the
MEDIUMtests/test_initialization.py1424 # some arguments don't work in conjunction with lora_bias and should raise
LOWtests/test_decoder_models.py478 # a malicious prompt tuning model. This is because PEFT would just pass the on the tokenizer_kwargs defined in
LOWtests/test_other.py404 # aware that some of the passing tests may just pass owing to randomness.
LOWexamples/dora_finetuning/dora_finetuning.py73 use_dora=use_dora, # to use Dora OR compare to Lora just set the --use_dora
MEDIUMsrc/peft/peft_model.py1032 # TODO: consider replacing this patching of methods with a more robust mechanism: setting a flag and
LOWsrc/peft/utils/other.py1740 # technically it would be sufficient to just return candidates since that contains all the keys of
LOWsrc/peft/utils/transformers_weight_conversion.py431 # If, for any reason, we cannot apply conversion, we just return the PEFT config as is.
MEDIUMsrc/peft/tuners/tuners_utils.py865 # TODO: check if this the most robust way
LOWsrc/peft/tuners/tuners_utils.py295 # model, just add a `peft_config` dict attribute to your model.
LOWsrc/peft/tuners/adamss/layer.py394 # so just call base_layer directly (no adapter delta needed).
LOWsrc/peft/tuners/lora/conversion.py329 # effective rank is the same and target_modules are a set, just add the name
MEDIUMsrc/peft/tuners/lora/layer.py325 # check without importing bitsandbytes and robust to bnb_4bit_quant_storage=float*
Verbosity Indicators7 hits · 13 pts
SeverityFileLineSnippet
LOWtests/test_adamss_asa.py107 # Step 1: train so B becomes non-zero
LOWtests/test_adamss_asa.py113 # Step 2: now gradients for A should be non-zero
LOWtests/test_adamss_asa.py123 # Step 3: another update should change scores via EMA
LOWtests/test_adamss_asa.py166 # Step 0: train to make B non-zero
LOWsrc/peft/import_utils.py96 # We need to check if `xla_device` can be found, will raise a RuntimeError if not
LOWsrc/peft/tuners/adamss/model.py193 # Step 1: accumulate importance EVERY step during warmup
LOWsrc/peft/tuners/adamss/model.py198 # Step 2: at mask intervals → schedule, global mask, then reset
Cross-Language Confusion5 hits · 12 pts
SeverityFileLineSnippet
HIGHsrc/peft/peft_model.py1752 trainable params: 370178 || all params: 108680450 || trainable%: 0.3406113979101117
HIGHsrc/peft/peft_model.py2006 trainable params: 1843200 || all params: 775873280 || trainable%: 0.23756456724479544
HIGHsrc/peft/peft_model.py2365 trainable params: 884736 || all params: 223843584 || trainable%: 0.3952474242013566
HIGHsrc/peft/peft_model.py2650 trainable params: 370178 || all params: 108680450 || trainable%: 0.3406113979101117
HIGHsrc/peft/peft_model.py2886 trainable params: 592900 || all params: 108312580 || trainable%: 0.5473971721475013
Slop Phrases7 hits · 10 pts
SeverityFileLineSnippet
LOWtests/regression/test_regression.py196 model output, and load_base_model(name) to load the base model. Don't forget to fix the seed in load_base_model.
MEDIUMexamples/beft_finetuning/beft_finetuning.py68# you can try target_modules=["v"], target_modules=["q"], target_modules=["k"]
LOW…ture_extraction/peft_lora_embedding_semantic_search.py157 # make sure to pop weight so that corresponding model is not saved again
MEDIUMexamples/arrow_multitask/arrow_phi3_mini.py57This script is mainly meant for demonstration purposes and lightweight evaluation,
MEDIUMexamples/alora_finetuning/alora_finetuning.py168 Purely for demonstration purposes. See the [paper](https://huggingface.co/papers/2504.12397)
LOW…s/int8_training/peft_adalora_whisper_large_training.py325 # make sure to pop weight so that corresponding model is not saved again
LOWsrc/peft/tuners/lora/intruders.py112 # we're not modifying the weights since there are no intruders but we make sure to copy the