Repository Analysis

huggingface/peft

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

18.2 Moderate AI signal View on GitHub

Analysis Overview

This report presents the forensic synthetic code analysis of huggingface/peft, a Python project with 21,393 GitHub stars. SynthScan v2.0 examined 195,534 lines of code across 845 source files, recording 3009 pattern matches distributed across 20 syntactic categories. The overall adjusted score of 18.2 places this repository in the Moderate AI signal band.

The scanner applied 160+ deterministic lexical heuristics, multi-line block detectors, abstract syntax tree depth profilers, and a cross-file Jaccard similarity matrix to construct a statistically normalised synthetic code estimate. All matches are individually weighted by severity coefficient and contextual multiplier before summation, and the resulting headline score is temporally discounted to account for the repository's development history relative to the commercial emergence of large language model coding tooling (November 2022 onward).

18.2
Adjusted Score
18.2
Raw Score
100%
Time Factor
2026-07-13
Last Push
21.4K
Stars
Python
Language
195.5K
Lines of Code
845
Files
3.0K
Pattern Hits
2026-07-14
Scan Date
0.19
HC Hit Rate

What These Metrics Mean

Adjusted Score
Primary synthetic code indicator. Raw score normalised per 1,000 lines of code and multiplied by the temporal discount factor. This is the definitive comparative metric — use it to rank repositories by AI authorship density.
Raw Score
The unmodified sum of all severity-weighted, context-multiplied pattern match scores before temporal discounting. Reflects the absolute signal strength independent of when the repository was last active.
Time Factor
The temporal discount multiplier (0–100%) applied to the raw score. Repositories last updated before ChatGPT's launch (Nov 2022) receive a 5% factor. Full signal is only assigned to repositories active in the post-adoption era (Jan 2024+).
Pattern Hits
Total count of individual pattern matches across all files and categories. A high hit count with a low score may indicate a very large codebase with isolated AI snippets; a low count with a high score indicates dense, concentrated AI signatures.
HC Hit Rate
High+Critical pattern hits per file, averaged across the repository. This orthogonal signal catches repositories where a few files are densely packed with high-severity AI tells — a strong indicator even when the normalised score appears moderate due to codebase size.
Lines of Code / Files
Total lines and files analysed. The scanner examines 94 file extensions. These denominators are used to normalise the score, enabling fair comparison between repositories of vastly different sizes.

Score History

This chart maps the temporal evolution of the adjusted synthetic code score across successive scan runs. An upward trajectory indicates ongoing incorporation of AI-generated code or expanding LLM-assisted scaffolding; a stable or declining trajectory may reflect active human refactoring, code removal, or the adoption of stricter authorship policies. The dashed secondary line (right axis) independently tracks total raw pattern hit count, which can diverge from the normalised score when codebase size changes significantly between scans.

Severity Breakdown

Classifies detected patterns by their diagnostic confidence and structural impact. CRITICAL patterns (coefficient 10) represent definitive synthetic signatures — hallucinated imports, explicit LLM attribution metadata — virtually never produced by human authors. HIGH (5) indicates strong structural tells such as cross-file repetition or cross-linguistic idioms. MEDIUM (2) covers recognisable conversational padding and AI-specific vocabulary. LOW (1) captures subtle indicators like tautological comments and generic boilerplate that require density to carry independent signal.

CRITICAL 35HIGH 128MEDIUM 57LOW 2789

Directory Score Breakdown

This horizontal bar chart decomposes the repository's raw synthetic code score by top-level directory, allowing you to pinpoint precisely which modules or components carry the highest AI authorship density. Directories with disproportionately high scores relative to their size warrant targeted manual review: concentrated AI signatures often trace back to mass-generated configuration layers, auto-ported test suites, LLM-scaffolded boilerplate classes, or entire subsystems authored under heavy copilot assistance. Use this view to prioritise your human code-review effort.

Pattern Findings

The scanner identified 3009 distinct pattern matches across 20 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a statistically significant AI authorship indicator. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.

Reading the findings table: The Severity column indicates the diagnostic confidence level (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — comment-context matches receive a ×1.5 weight because LLMs systematically over-annotate. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier as dense clusters constitute far stronger evidence of synthetic authorship than isolated hits.

Hyper-Verbose Identifiers1289 hits · 982 pts
SeverityFileLineSnippetContext
LOWtests/test_mixed.py449 def test_target_different_layers(self, config0, config1):CODE
LOWtests/test_mixed.py490 def test_target_last_layer_same_type(self, config0, config1):CODE
LOWtests/test_mixed.py519 def test_target_first_layer_same_type(self, config0, config1):CODE
LOWtests/test_mixed.py667 def test_get_nb_trainable_parameters(self):CODE
LOWtests/test_mixed.py696 def test_bias_only_honored_for_non_lora_tuner(self):CODE
LOWtests/test_mixed.py707 def test_incompatible_config_raises(self):CODE
LOWtests/test_seq_classifier.py327 def prepare_inputs_for_testing(self):STRING
LOWtests/test_seq_classifier.py334 def test_attributes_parametrized(self, model_id, config_cls, config_kwargs):STRING
LOWtests/test_seq_classifier.py344 def test_prepare_for_training_parametrized(self, model_id, config_cls, config_kwargs):STRING
LOWtests/test_seq_classifier.py349 def test_prompt_tuning_text_prepare_for_training(self, model_id, config_cls, config_kwargs):STRING
LOWtests/test_seq_classifier.py366 def test_save_pretrained_pickle(self, model_id, config_cls, config_kwargs):STRING
LOWtests/test_seq_classifier.py372 def test_save_pretrained_selected_adapters(self, model_id, config_cls, config_kwargs):STRING
LOWtests/test_seq_classifier.py378 def test_save_pretrained_selected_adapters_pickle(self, model_id, config_cls, config_kwargs):STRING
LOWtests/test_seq_classifier.py386 def test_from_pretrained_config_construction(self, model_id, config_cls, config_kwargs):STRING
LOWtests/test_seq_classifier.py391 def test_modules_to_save_correctly_set(self, model_id, config_cls, config_kwargs):STRING
LOWtests/test_lora_conversion.py78 def test_no_peft_layer_raises(self):CODE
LOWtests/test_lora_conversion.py85 def test_prompt_learning_model_raises(self):CODE
LOWtests/test_lora_conversion.py96 def test_peft_model_but_no_support_raises(self):CODE
LOWtests/test_lora_conversion.py106 def test_model_with_unsupported_layers_raises(self):CODE
LOWtests/test_lora_conversion.py122 def test_targeted_modules_identical(self, lokr_model):CODE
LOWtests/test_lora_conversion.py138 def test_targeted_modules_identical_target_modules_str(self):CODE
LOWtests/test_lora_conversion.py157 def test_fixed_rank_lora_config(self, lokr_model):CODE
LOWtests/test_lora_conversion.py167 def test_dynamic_rank_lora_config(self, lokr_model):CODE
LOWtests/test_lora_conversion.py193 def test_threshold_wrong_value_raises(self, lokr_model):CODE
LOWtests/test_lora_conversion.py203 def test_rank_higher_than_weight_dim_raises(self, lokr_model):CODE
LOWtests/test_lora_conversion.py214 def test_converting_transformers_model_works(self, lokr_model, tmp_path):CODE
LOWtests/test_lora_conversion.py245 def test_converted_lora_approximates_original_adapter(self, lokr_model):CODE
LOWtests/test_lora_conversion.py334 def test_model_without_peft_config(self, lokr_model):CODE
LOWtests/test_lora_conversion.py372 def test_converted_lora_to_lora_works_and_warns(self):CODE
LOWtests/test_lora_conversion.py410 def test_converted_lora_with_multiple_adapters(self, lokr_model):CODE
LOWtests/test_lora_conversion.py456 def test_convert_model_with_modules_to_save(self):CODE
LOWtests/test_lora_conversion.py496 def test_convert_model_with_trainable_bias_raises(self, bias):CODE
LOWtests/test_lora_conversion.py605 def test_miss_supports_lora_conversion(self, miss_model_standard, miss_model_mini, miss_model_bat):CODE
LOWtests/test_lora_conversion.py610 def test_miss_standard_exact_conversion(self, miss_model_standard):CODE
LOWtests/test_lora_conversion.py627 def test_miss_mini_exact_conversion(self, miss_model_mini):CODE
LOWtests/test_lora_conversion.py644 def test_miss_bat_approximate_conversion(self, miss_model_bat):CODE
LOWtests/test_lora_conversion.py666 def test_miss_targeted_modules_identical(self, miss_model_standard):CODE
LOWtests/test_tuners_utils.py460 def test_one_targeted_module_regex(self):STRING
LOWtests/test_tuners_utils.py465 def test_two_targeted_module_regex(self):STRING
LOWtests/test_tuners_utils.py470 def test_one_targeted_module_list(self):STRING
LOWtests/test_tuners_utils.py475 def test_two_targeted_module_list(self):STRING
LOWtests/test_tuners_utils.py578 def test_two_excluded_module_regex(self):STRING
LOWtests/test_tuners_utils.py583 def test_two_excluded_module_list(self):STRING
LOWtests/test_tuners_utils.py588 def test_multiple_excluded_modules_list(self):STRING
LOWtests/test_tuners_utils.py846 def test_available_adapters_small(self, small_model):STRING
LOWtests/test_tuners_utils.py852 def test_available_adapters_large(self, large_model):STRING
LOWtests/test_tuners_utils.py858 def test_devices_all_cpu_small(self, small_model):STRING
LOWtests/test_tuners_utils.py864 def test_devices_all_cpu_large(self, large_model):STRING
LOWtests/test_tuners_utils.py950 def test_target_parameters_and_target_modules(self, large_model):STRING
LOWtests/test_tuners_utils.py960 def test_quantization_backend_small(self, small_model):STRING
LOWtests/test_tuners_utils.py965 def test_quantization_backend_large(self, large_model):STRING
LOWtests/test_tuners_utils.py971 def test_quantization_backend_bnb(self, small_base_model_cls):STRING
LOWtests/test_tuners_utils.py1007 def test_base_model_type_small(self, small_model):STRING
LOWtests/test_tuners_utils.py1011 def test_base_model_type_large(self, large_model):STRING
LOWtests/test_tuners_utils.py1015 def test_base_model_type_transformers_automodel(self):STRING
LOWtests/test_tuners_utils.py1024 def test_adapter_model_type_small(self, small_model):STRING
LOWtests/test_tuners_utils.py1028 def test_adapter_model_type_large(self, large_model):STRING
LOWtests/test_tuners_utils.py1066 def test_model_disabled_small(self, small_model):STRING
LOWtests/test_tuners_utils.py1071 def test_model_disabled_large(self, large_model):STRING
LOWtests/test_tuners_utils.py1076 def test_model_enabled_irregular(self, large_model):STRING
1229 more matches not shown…
Cross-File Repetition117 hits · 585 pts
SeverityFileLineSnippetContext
HIGHtests/test_gpu_examples.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109STRING
HIGHtests/test_vision_models.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109STRING
HIGHtests/test_gptqmodel.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109STRING
HIGHtests/test_common_gpu.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109STRING
HIGHtests/test_torch_compile.py0efficient mechanism to free gpu memory after each test. based on https://github.com/huggingface/transformers/issues/2109STRING
HIGHdocs/source/package_reference/lora.md0run forward and backward passes for gradient estimation.STRING
HIGHexamples/lora_ga_finetuning/README.md0run forward and backward passes for gradient estimation.STRING
HIGHexamples/lora_ga_finetuning/lora_ga_finetuning.py0run forward and backward passes for gradient estimation.STRING
HIGHexamples/boft_controlnet/utils/tracemalloc.py0get resident set size memory for the current processSTRING
HIGH…_modeling/peft_lora_clm_accelerate_ds_zero3_offload.py0get resident set size memory for the current processSTRING
HIGHexamples/deft_dreambooth/train_dreambooth.py0get resident set size memory for the current processSTRING
HIGHexamples/oft_dreambooth/train_dreambooth.py0get resident set size memory for the current processSTRING
HIGHexamples/hra_dreambooth/utils/tracemalloc.py0get resident set size memory for the current processSTRING
HIGHexamples/stable_diffusion/train_dreambooth.py0get resident set size memory for the current processSTRING
HIGHexamples/lora_dreambooth/train_dreambooth.py0get resident set size memory for the current processSTRING
HIGHexamples/boft_dreambooth/utils/tracemalloc.py0get resident set size memory for the current processSTRING
HIGH…ation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py0get resident set size memory for the current processSTRING
HIGHexamples/waveft_finetuning/waveft_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructioSTRING
HIGHexamples/hira_finetuning/hira_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructioSTRING
HIGHexamples/glora_finetuning/glora_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructioSTRING
HIGHexamples/olora_finetuning/olora_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructioSTRING
HIGHexamples/shira_finetuning/shira_finetuning.py0below is an instruction that describes a task. write a response that appropriately completes the request. ### instructioSTRING
HIGHexamples/deft_dreambooth/train_dreambooth.py0a dataset to prepare the instance and class images with the prompts for fine-tuning the model. it pre-processes the imagSTRING
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 imagSTRING
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 imagSTRING
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 imagSTRING
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 imagSTRING
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 imagSTRING
HIGHexamples/corda_finetuning/corda_finetuning.py0returns the number of trainable parameters and number of all parameters in the model.STRING
HIGHsrc/peft/peft_model.py0returns the number of trainable parameters and number of all parameters in the model.STRING
HIGHsrc/peft/mixed_model.py0returns the number of trainable parameters and number of all parameters in the model.STRING
HIGHsrc/peft/peft_model.py0deletes an existing adapter. args: adapter_name (str): name of the adapter to be deleted.STRING
HIGHsrc/peft/tuners/tuners_utils.py0deletes an existing adapter. args: adapter_name (str): name of the adapter to be deleted.STRING
HIGHsrc/peft/tuners/waveft/model.py0deletes an existing adapter. args: adapter_name (str): name of the adapter to be deleted.STRING
HIGHsrc/peft/utils/other.py0check if the arguments are compatible with the configs and state of the modelSTRING
HIGHsrc/peft/tuners/road/layer.py0check if the arguments are compatible with the configs and state of the modelSTRING
HIGHsrc/peft/tuners/lora/layer.py0check if the arguments are compatible with the configs and state of the modelSTRING
HIGHsrc/peft/tuners/lycoris_utils.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/hra/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/road/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/miss/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/oft/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/vera/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/delora/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/boft/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/waveft/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/c3a/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/hira/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/hira/bnb.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/road/bnb.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/fourierft/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/vblora/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/gralora/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/ia3/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/osf/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/adalora/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/pvera/layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/lora/hqq.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/lora/tp_layer.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
HIGHsrc/peft/tuners/lora/inc.py0merge the active adapter weights into the base weights. args: safe_merge (`bool`, *optional*): if `true`, the merge operSTRING
57 more matches not shown…
Hallucination Indicators35 hits · 440 pts
SeverityFileLineSnippetContext
CRITICALtests/test_lora_conversion.py468 lokr_model.base_model.model.model.decoder.layers[0].fc1.modules_to_save.default.weight.data.mul_(-10.0)CODE
CRITICALtests/test_lora_conversion.py469 lokr_model.base_model.model.model.decoder.layers[0].fc1.modules_to_save.default.bias.data.mul_(-10.0)CODE
CRITICALtests/test_cpt.py247 emb = model.prompt_encoder.default.embedding.weight.data.clone().detach()CODE
CRITICALtests/test_cpt.py263 assert torch.all(model.prompt_encoder.default.embedding.weight.data.clone().detach().cpu() == emb.cpu())CODE
CRITICALtests/test_cpt.py277 emb = model.prompt_encoder.default.embedding.weight.data.clone().detach()CODE
CRITICALtests/test_cpt.py294 assert torch.all(model.prompt_encoder.default.embedding.weight.data.clone().detach().cpu() == emb.cpu())CODE
CRITICALtests/test_trainable_tokens.py228 initial_delta = model.model.model.embed_tokens.trainable_tokens_delta.default.clone()CODE
CRITICALtests/test_trainable_tokens.py229 initial_originals = model.model.model.embed_tokens.trainable_tokens_original.default.clone()CODE
CRITICALtests/test_trainable_tokens.py680 assert merged_model.model.decoder.embed_tokens.weight.data_ptr() == merged_model.lm_head.weight.data_ptr()CODE
CRITICALtests/test_trainable_tokens.py717 assert merged_model.model.decoder.embed_tokens.weight.data_ptr() == merged_model.lm_head.weight.data_ptr()CODE
CRITICALtests/test_trainable_tokens.py816 expected_changed_weights = peft_model.model.model.embed_tokens.trainable_tokens_delta.default.data.clone()CODE
CRITICALtests/test_gpu_examples.py2231 embed_params = model.base_model.model.model.decoder.embed_tokens.original_module.weight.numel()STRING
CRITICALtests/test_initialization.py5792 model.base_model.model.model.embed_tokens.weight.data_ptr()CODE
CRITICALtests/test_initialization.py5793 != model.base_model.model.lm_head.weight.data_ptr()CODE
CRITICALtests/test_initialization.py5264 peft_model.prompt_encoder.default.embedding.weight.data.fill_(1.0)CODE
CRITICALtests/test_initialization.py5481 embed_np = dict(model.base_model.model.model.embed_tokens.named_parameters())CODE
CRITICALtests/test_initialization.py5541 embed_np = dict(model.base_model.model.model.embed_tokens.named_parameters())CODE
CRITICALtests/test_initialization.py5716 shared_np = dict(model.base_model.model.model.shared.named_parameters())CODE
CRITICALtests/test_target_parameters.py384 gate_proj_1_0.lora_A.default.weight.data.copy_(gate_proj_0_0.lora_A.default.weight.data)CODE
CRITICALtests/test_target_parameters.py385 gate_proj_1_1.lora_A.default.weight.data.copy_(gate_proj_0_1.lora_A.default.weight.data)CODE
CRITICALtests/test_target_parameters.py386 gate_proj_1_0.lora_B.default.weight.data.copy_(gate_proj_0_0.lora_B.default.weight.data)CODE
CRITICALtests/test_target_parameters.py387 gate_proj_1_1.lora_B.default.weight.data.copy_(gate_proj_0_1.lora_B.default.weight.data)CODE
CRITICALtests/test_decoder_models.py821 layers[0].mlp.up_proj.base_layer.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py822 == layers[1].mlp.up_proj.base_layer.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py823 and layers[2].mlp.up_proj.base_layer.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py824 == layers[3].mlp.up_proj.base_layer.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py827 layers[0].mlp.up_proj.base_layer.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py828 != layers[2].mlp.up_proj.base_layer.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py831 layers[0].mlp.up_proj.lora_A.default.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py832 != layers[1].mlp.up_proj.lora_A.default.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py833 and layers[2].mlp.up_proj.lora_A.default.weight.data.storage().data_ptr()CODE
CRITICALtests/test_decoder_models.py834 != layers[3].mlp.up_proj.lora_A.default.weight.data.storage().data_ptr()CODE
CRITICALtests/test_custom_models.py4051 lm_head_keys = list(model.base_model.model.lm_head.modules_to_save.keys())CODE
CRITICALtests/test_custom_models.py4054 embed_token_keys = list(model.base_model.model.model.decoder.embed_tokens.modules_to_save.keys())CODE
CRITICALsrc/peft/tuners/tuners_utils.py619 model.lm_head.weight.data = model.model.embed_tokens.weight.data.clone()CODE
Unused Imports589 hits · 431 pts
SeverityFileLineSnippetContext
LOWtests/test_lorafa.py15CODE
LOWtests/test_trainable_tokens.py15CODE
LOWtests/test_loraplus.py14CODE
LOWmethod_comparison/app_embed.py26CODE
LOWmethod_comparison/app_embed.py26CODE
LOWexamples/stable_diffusion/inc_flux_lora_hpu.py26CODE
LOWsrc/peft/config.py14CODE
LOWsrc/peft/__init__.py17CODE
LOWsrc/peft/__init__.py17CODE
LOWsrc/peft/__init__.py17CODE
LOWsrc/peft/__init__.py17CODE
LOWsrc/peft/__init__.py17CODE
LOWsrc/peft/__init__.py17CODE
LOWsrc/peft/__init__.py17CODE
LOWsrc/peft/__init__.py17CODE
LOWsrc/peft/__init__.py27CODE
LOWsrc/peft/__init__.py27CODE
LOWsrc/peft/__init__.py28CODE
LOWsrc/peft/__init__.py29CODE
LOWsrc/peft/__init__.py29CODE
LOWsrc/peft/__init__.py29CODE
LOWsrc/peft/__init__.py29CODE
LOWsrc/peft/__init__.py29CODE
LOWsrc/peft/__init__.py36CODE
LOWsrc/peft/__init__.py37CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py38CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
LOWsrc/peft/__init__.py49CODE
529 more matches not shown…
Over-Commented Block382 hits · 371 pts
SeverityFileLineSnippetContext
LOWsetup.py1# Copyright 2023 The HuggingFace Team. All rights reserved.COMMENT
LOWsetup.py101# Push the tag to git:COMMENT
LOWtests/test_mixed.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_seq_classifier.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_lora_conversion.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_tuners_utils.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_tuners_utils.py61from .testing_utils import hub_online_once, require_bitsandbytes, require_non_cpuCOMMENT
LOWtests/test_tuners_utils.py1981 super().__init__()COMMENT
LOWtests/conftest.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_xlora.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_hub_features.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_lorafa.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_cpt.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
LOWtests/test_low_level_api.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_lora_megatron.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_trainable_tokens.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_gpu_examples.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_integrations.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
LOWtests/test_poly.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/testing_utils.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_loraplus.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
LOWtests/test_adaption_prompt.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_frod.py1# Copyright 2026-present the HuggingFace Inc. team.COMMENT
LOWtests/test_initialization.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_initialization.py5041 # (proj): Conv3d(3, 1280, kernel_size=(2, 14, 14), stride=(2, 14, 14), bias=False)COMMENT
LOWtests/test_initialization.py5061 # (mlp): Sequential(COMMENT
LOWtests/test_initialization.py5081 # (up_proj): Linear(in_features=1536, out_features=8960, bias=False)COMMENT
LOWtests/test_initialization.py5121 return modelCOMMENT
LOWtests/test_initialization.py5141 # (mlp): VisionMlp(COMMENT
LOWtests/test_initialization.py5161 # (self_attn): Qwen2VLAttention(COMMENT
LOWtests/test_target_parameters.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_pvera.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_vision_models.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
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.COMMENT
LOWtests/test_decoder_models.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_encoder_decoder_models.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_multitask_prompt_tuning.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_lora_ga.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/testing_common.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_quantization.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_common_gpu.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_cartridge.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_vblora.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
LOWtests/test_config.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_randlora.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_unilora.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_shira.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_boft.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
LOWtests/test_feature_extraction_models.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_bdlora.py1# Copyright 2026-present the HuggingFace Inc. team.COMMENT
LOWtests/test_helpers.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
LOWtests/test_stablediffusion.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_lora_variants.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_incremental_pca.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
LOWtests/test_auto.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_deft.py1# Copyright 2026-present the HuggingFace Inc. team.COMMENT
LOWtests/test_other.py1# Copyright 2023-present the HuggingFace Inc. team.COMMENT
LOWtests/test_arrow.py1# Copyright 2025-present the HuggingFace Inc. team.COMMENT
LOWtests/test_vera.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
LOWtests/test_torch_compile.py1# Copyright 2024-present the HuggingFace Inc. team.COMMENT
322 more matches not shown…
Deep Nesting258 hits · 232 pts
SeverityFileLineSnippetContext
LOWtests/test_lora_conversion.py576CODE
LOWtests/test_trainable_tokens.py586CODE
LOWtests/test_gpu_examples.py6646CODE
LOWtests/test_gpu_examples.py6700CODE
LOWtests/test_gpu_examples.py5933CODE
LOWtests/testing_utils.py318CODE
LOWtests/test_initialization.py1487CODE
LOWtests/test_initialization.py4465CODE
LOWtests/test_initialization.py4642CODE
LOWtests/test_initialization.py4674CODE
LOWtests/test_decoder_models.py442CODE
LOWtests/testing_common.py588CODE
LOWtests/testing_common.py1038CODE
LOWtests/testing_common.py1196CODE
LOWtests/testing_common.py1300CODE
LOWtests/testing_common.py1332CODE
LOWtests/testing_common.py1392CODE
LOWtests/testing_common.py1501CODE
LOWtests/test_other.py655CODE
LOWtests/test_arrow.py474CODE
LOWtests/test_custom_models.py2723CODE
LOWtests/test_custom_models.py2842CODE
LOWmethod_comparison/app_embed.py38CODE
LOWmethod_comparison/sanitizer.py6CODE
LOWmethod_comparison/app.py280CODE
LOWmethod_comparison/image-gen/run.py159CODE
LOWmethod_comparison/image-gen/utils.py314CODE
LOWmethod_comparison/text_generation_benchmark/run.py139CODE
LOWmethod_comparison/text_generation_benchmark/utils.py205CODE
LOWmethod_comparison/peft-shop/app.py1110CODE
LOWmethod_comparison/MetaMathQA/utils.py210CODE
LOWmethod_comparison/MetaMathQA/utils.py359CODE
LOW…les/sequence_classification/peft_no_lora_accelerate.py79CODE
LOWexamples/boft_controlnet/train_controlnet.py86CODE
LOWexamples/boft_controlnet/utils/pipeline_controlnet.py53CODE
LOWexamples/boft_controlnet/utils/pipeline_controlnet.py166CODE
LOWexamples/boft_controlnet/utils/dataset.py82CODE
LOWexamples/boft_controlnet/utils/dataset.py136CODE
LOW…ture_extraction/peft_lora_embedding_semantic_search.py210CODE
LOW…_modeling/peft_lora_clm_accelerate_ds_zero3_offload.py110CODE
LOWexamples/arrow_multitask/arrow_phi3_mini.py120CODE
LOWexamples/loftq_finetuning/int8_correction.py68CODE
LOWexamples/loftq_finetuning/train_gsm8k_llama.py297CODE
LOW…orthogonal_subspace_learning/osf_continual_learning.py51CODE
LOW…orthogonal_subspace_learning/osf_continual_learning.py99CODE
LOW…orthogonal_subspace_learning/osf_continual_learning.py142CODE
LOWexamples/orthogonal_subspace_learning/utils.py42CODE
LOWexamples/deft_dreambooth/train_dreambooth.py585CODE
LOWexamples/oft_dreambooth/train_dreambooth.py590CODE
LOWexamples/hra_dreambooth/train_dreambooth.py82CODE
LOWexamples/qalora_finetuning/qalora_gptq_finetuning.py23CODE
LOWexamples/stable_diffusion/train_dreambooth.py754CODE
LOWexamples/stable_diffusion/convert_sd_adapter_to_peft.py285CODE
LOWexamples/lora_dreambooth/train_dreambooth.py580CODE
LOWexamples/corda_finetuning/datautils.py106CODE
LOWexamples/sft/utils.py86CODE
LOWexamples/boft_dreambooth/train_dreambooth.py82CODE
LOW…ation/peft_lora_seq2seq_accelerate_ds_zero3_offload.py104CODE
LOW…s/int8_training/peft_adalora_whisper_large_training.py423CODE
LOWscripts/log_reports.py19CODE
198 more matches not shown…
Modern Structural Boilerplate93 hits · 91 pts
SeverityFileLineSnippetContext
LOWmethod_comparison/app.py46logger = logging.getLogger(__name__)CODE
LOWmethod_comparison/peft-shop/app.py294def _set_data(data: dict[str, Any]) -> None:CODE
LOWexamples/stable_diffusion/convert_sd_adapter_to_peft.py20logger = logging.getLogger(__name__)CODE
LOWsrc/peft/__init__.py175__all__ = [CODE
LOWsrc/peft/peft_model.py1578 def set_adapter(self, adapter_name: str, inference_mode: bool = False) -> None:CODE
LOWsrc/peft/peft_model.py1603 def set_requires_grad(self, adapter_names: str | Sequence[str], requires_grad: bool = True) -> None:CODE
LOWsrc/peft/functional.py26__all__ = [CODE
LOWsrc/peft/mixed_model.py251 def set_modules_to_save(self, peft_config: PeftConfig, adapter_name: str) -> None:CODE
LOWsrc/peft/mixed_model.py266 def set_adapter(self, adapter_name: Union[str, list[str]], inference_mode: bool = False) -> None:CODE
LOWsrc/peft/helpers.py38def update_forward_signature(model: PeftModel) -> None:CODE
LOWsrc/peft/helpers.py72def update_generate_signature(model: PeftModel) -> None:CODE
LOWsrc/peft/helpers.py113def update_signature(model: PeftModel, method: str = "all") -> None:CODE
LOWsrc/peft/utils/__init__.py85__all__ = [CODE
LOWsrc/peft/utils/other.py91__all__ = [CODE
LOWsrc/peft/utils/other.py521 def set_adapter(self, adapter_names: Union[str, list[str]], inference_mode: bool = False) -> None:CODE
LOWsrc/peft/utils/other.py547 def set_requires_grad(self, adapter_names: str | Sequence[str], requires_grad: bool = True) -> None:CODE
LOWsrc/peft/utils/other.py700 def set_adapter(self, adapter_names: Union[str, list[str]], inference_mode: bool = False) -> None:CODE
LOWsrc/peft/utils/other.py944 def set_adapter(self, adapter_names: Union[str, list[str]], inference_mode: bool = False) -> None:CODE
LOWsrc/peft/utils/other.py1124def _set_adapter(model, adapter_name: str | list[str], inference_mode: bool = False) -> None:CODE
LOWsrc/peft/utils/other.py277def _set_layer_requires_grad(layer, requires_grad: bool) -> None:STRING
LOWsrc/peft/utils/quantization_utils.py75 def set_base_weight(self, peft_layer, weight_data: torch.Tensor) -> None:CODE
LOWsrc/peft/utils/quantization_utils.py116 def set_base_weight(self, peft_layer, weight_data: torch.Tensor) -> None:CODE
LOWsrc/peft/utils/quantization_utils.py137 def set_base_weight(self, peft_layer, weight_data: torch.Tensor) -> None:CODE
LOWsrc/peft/utils/quantization_utils.py159 def set_base_weight(self, peft_layer, weight_data: torch.Tensor) -> None:CODE
LOWsrc/peft/utils/quantization_utils.py191 def set_base_weight(self, peft_layer, weight_data: torch.Tensor) -> None:CODE
LOWsrc/peft/utils/quantization_utils.py233 def set_base_weight(self, peft_layer, weight_data: torch.Tensor) -> None:CODE
LOWsrc/peft/tuners/__init__.py78__all__ = [CODE
LOWsrc/peft/tuners/tuners_utils.py1265 def set_adapter(self, adapter_name: str | list[str], inference_mode: bool = False) -> None:CODE
LOWsrc/peft/tuners/tuners_utils.py1609 def set_adapter(self, adapter_names: str | list[str], inference_mode: bool = False) -> None:CODE
LOWsrc/peft/tuners/tuners_utils.py1689 def set_requires_grad(self, adapter_names: str | Sequence[str], requires_grad: bool = True) -> None:CODE
LOWsrc/peft/tuners/tuners_utils.py2291def set_requires_grad(model, adapter_names: str | Sequence[str], requires_grad: bool = True) -> None:CODE
LOWsrc/peft/tuners/tuners_utils.py553 def set_requires_grad(self, adapter_names: str | Sequence[str], requires_grad: bool = True) -> None:STRING
LOWsrc/peft/tuners/tuners_utils.py1459 def set_base_weight(self, weight_data: torch.Tensor) -> None:STRING
LOWsrc/peft/tuners/peanut/__init__.py22__all__ = ["Linear", "PeanutConfig", "PeanutLayer", "PeanutModel"]CODE
LOWsrc/peft/tuners/prompt_tuning/__init__.py21__all__ = ["PromptEmbedding", "PromptTuningConfig", "PromptTuningInit"]CODE
LOWsrc/peft/tuners/hra/__init__.py22__all__ = ["HRAConfig", "HRAConv2d", "HRALayer", "HRALinear", "HRAModel"]CODE
LOWsrc/peft/tuners/loha/__init__.py22__all__ = ["Conv2d", "Linear", "LoHaConfig", "LoHaLayer", "LoHaModel"]CODE
LOWsrc/peft/tuners/lokr/__init__.py22__all__ = ["Conv2d", "Linear", "LoKrConfig", "LoKrLayer", "LoKrModel"]CODE
LOWsrc/peft/tuners/vera/__init__.py22__all__ = ["Linear", "VeraConfig", "VeraLayer", "VeraModel"]CODE
LOWsrc/peft/tuners/ln_tuning/__init__.py21__all__ = ["LNTuningConfig", "LNTuningModel"]CODE
LOWsrc/peft/tuners/cpt/__init__.py22__all__ = ["CPTConfig", "CPTEmbedding"]CODE
LOWsrc/peft/tuners/delora/__init__.py21__all__ = ["DeloraConfig", "DeloraLayer", "DeloraLinear", "DeloraModel"]CODE
LOWsrc/peft/tuners/boft/__init__.py22__all__ = ["BOFTConfig", "BOFTLayer", "BOFTModel"]CODE
LOWsrc/peft/tuners/psoft/__init__.py22__all__ = ["Linear", "PsoftConfig", "PsoftLayer", "PsoftModel"]CODE
LOWsrc/peft/tuners/psoft/layer.py235 def _set_psoft_ab_cache_buffers(self, adapter_name: str, A: torch.Tensor, B: torch.Tensor) -> None:CODE
LOWsrc/peft/tuners/psoft/layer.py239 def update_layer(self, adapter_name: str, config: PsoftConfig, **kwargs: Any) -> None:CODE
LOWsrc/peft/tuners/beft/__init__.py23__all__ = ["BeftConfig", "BeftLayer", "BeftModel", "Linear"]CODE
LOWsrc/peft/tuners/waveft/__init__.py22__all__ = ["WaveFTConfig", "WaveFTLayer", "WaveFTLinear", "WaveFTModel"]CODE
LOWsrc/peft/tuners/c3a/__init__.py21__all__ = ["C3AConfig", "C3ALayer", "C3ALinear", "C3AModel"]CODE
LOWsrc/peft/tuners/p_tuning/__init__.py21__all__ = ["PromptEncoder", "PromptEncoderConfig", "PromptEncoderReparameterizationType"]CODE
LOWsrc/peft/tuners/adamss/__init__.py22__all__ = [CODE
LOWsrc/peft/tuners/adamss/model.py157 def update_and_allocate(self, global_step: int) -> None:CODE
LOWsrc/peft/tuners/hira/__init__.py23__all__ = [CODE
LOWsrc/peft/tuners/hira/layer.py309 def update_layer(self, adapter_name, r, config: HiraConfig, **kwargs) -> None:CODE
LOWsrc/peft/tuners/mixed/__init__.py18__all__ = ["COMPATIBLE_TUNER_TYPES", "MixedModel"]CODE
LOWsrc/peft/tuners/mixed/model.py201 def set_adapter(self, adapter_name: Union[str, list[str]], inference_mode: bool = False) -> None:CODE
LOWsrc/peft/tuners/frod/__init__.py22__all__ = ["FrodConfig", "FrodLayer", "FrodModel", "Linear"]CODE
LOWsrc/peft/tuners/trainable_tokens/__init__.py22__all__ = [CODE
LOWsrc/peft/tuners/road/__init__.py26__all__ = [CODE
LOWsrc/peft/tuners/fourierft/__init__.py22__all__ = ["FourierFTConfig", "FourierFTLayer", "FourierFTLinear", "FourierFTModel"]CODE
33 more matches not shown…
Self-Referential Comments26 hits · 76 pts
SeverityFileLineSnippetContext
MEDIUMtests/test_trainable_tokens.py1205 # Create a composite model with two BART sub-modelsCOMMENT
MEDIUMtests/test_lora_ga.py130 # Create a fresh model and load the saved stateCOMMENT
MEDIUMtests/test_helpers.py669 # Create a minimal dummy MoE model with fused 3D weightsCOMMENT
MEDIUMtests/test_custom_models.py4628 # Create a weighted adapter combining both adapters and check that its output is same as setting multipleCOMMENT
MEDIUMmethod_comparison/app_embed.py58 # Create an empty figure.COMMENT
MEDIUMmethod_comparison/app.py57 # Create an empty figure.COMMENT
MEDIUMexamples/boft_controlnet/train_controlnet.py537 # Create the pipeline using using the trained modules and save it.COMMENT
MEDIUMexamples/arrow_multitask/arrow_phi3_mini.py362 # Creating the Arrow modelCOMMENT
MEDIUM…orthogonal_subspace_learning/osf_continual_learning.py57 # Create a simple dataloaderCOMMENT
MEDIUMexamples/deft_dreambooth/train_dreambooth.py1072 # Create the pipeline using using the trained modules and save it.COMMENT
MEDIUMexamples/oft_dreambooth/train_dreambooth.py1079 # Create the pipeline using using the trained modules and save it.COMMENT
MEDIUMexamples/hra_dreambooth/train_dreambooth.sh4# Define the UNIQUE_TOKEN, CLASS_TOKENs, and SUBJECT_NAMESCOMMENT
MEDIUMexamples/stable_diffusion/train_dreambooth.py1239 # Create the pipeline using using the trained modules and save it.COMMENT
MEDIUMexamples/stable_diffusion/convert_sd_adapter_to_peft.py409 # Create a corresponding adapter infoCOMMENT
MEDIUMexamples/lora_dreambooth/train_dreambooth.py1071 # Create the pipeline using using the trained modules and save it.COMMENT
MEDIUMexamples/boft_dreambooth/train_dreambooth.sh5# Define the UNIQUE_TOKEN, CLASS_TOKENs, and SUBJECT_NAMESCOMMENT
MEDIUMexamples/lora_ga_finetuning/lora_ga_finetuning.py167 # Create a simple DataLoader for gradient estimationCOMMENT
MEDIUMsrc/peft/utils/other.py1667 # Create the causal mask with fixed shape in advance, to reduce recompilations. If the function to createCOMMENT
MEDIUMsrc/peft/tuners/tuners_utils.py1858 # Create a reverse lookup for other_module_names to quickly check suffix matchesCOMMENT
MEDIUMsrc/peft/tuners/boft/layer.py178 # Create a mask with 1s for matrices to be replaced with identity and 0s otherwiseCOMMENT
MEDIUMsrc/peft/tuners/waveft/layer.py133 # Create a padded spectrum matrix with additional rows and columnsCOMMENT
MEDIUMsrc/peft/tuners/waveft/layer.py144 # Create the padded dense spectrum matrixCOMMENT
MEDIUMsrc/peft/tuners/waveft/waverec2d.py6# This file contains code derived from PyTorch-Wavelet-Toolbox:COMMENT
MEDIUMsrc/peft/tuners/osf/model.py103 # Create a new or update an existing OSF layer in placeCOMMENT
MEDIUMsrc/peft/tuners/xlora/model.py244 # Create an empty LoraModelCOMMENT
MEDIUMsrc/peft/tuners/adalora/model.py348 """This method is not supported for AdaLoRA, use LoRA instead."""STRING
Excessive Try-Catch Wrapping57 hits · 58 pts
SeverityFileLineSnippetContext
LOWtests/testing_utils.py370 except Exception:CODE
MEDIUMtests/test_initialization.py311def test_lora_init_orthogonal_half_precision_dtype(self, dtype):CODE
LOWtests/test_initialization.py314 except Exception:CODE
LOWtests/test_arrow.py336 except Exception:CODE
LOWtests/test_custom_models.py2500 except Exception:CODE
LOWtests/test_custom_models.py2540 except Exception:CODE
LOWtests/test_custom_models.py2579 except Exception:CODE
LOWtests/test_custom_models.py2618 except Exception:CODE
LOWmethod_comparison/app.py188 except Exception as exc:CODE
LOWmethod_comparison/app.py198 except Exception as exc:CODE
LOWmethod_comparison/app.py232 except Exception as exc:CODE
LOWmethod_comparison/app.py393 except Exception as exc:CODE
LOWmethod_comparison/app.py443 except Exception as exc:CODE
LOWmethod_comparison/app.py496 except Exception as e:CODE
LOWmethod_comparison/app.py518 except Exception as e:CODE
LOWmethod_comparison/image-gen/run.py510 except Exception as exc:CODE
LOWmethod_comparison/image-gen/run.py631 except Exception as exc:CODE
LOWmethod_comparison/image-gen/utils.py302 except Exception as exc:CODE
LOWmethod_comparison/image-gen/utils.py310 except Exception as exc:CODE
LOWmethod_comparison/image-gen/utils.py326 except Exception as exc:CODE
LOWmethod_comparison/image-gen/utils.py334 except Exception as exc:CODE
LOWmethod_comparison/image-gen/utils.py342 except Exception as exc:CODE
LOWmethod_comparison/image-gen/utils.py350 except Exception as exc:CODE
LOWmethod_comparison/image-gen/evaluate.py131 except Exception as exc:CODE
LOWmethod_comparison/image-gen/evaluate.py231 except Exception as exc:CODE
LOWmethod_comparison/text_generation_benchmark/run.py214 except Exception as exc:CODE
LOWmethod_comparison/text_generation_benchmark/run.py299 except Exception as exc:CODE
LOWmethod_comparison/MetaMathQA/run.py386 except Exception as exc:CODE
LOWmethod_comparison/MetaMathQA/utils.py355 except Exception as exc:CODE
LOWmethod_comparison/MetaMathQA/utils.py371 except Exception as exc:CODE
LOWmethod_comparison/MetaMathQA/utils.py379 except Exception as exc:CODE
LOWmethod_comparison/MetaMathQA/utils.py508 except Exception as exc:CODE
LOWmethod_comparison/MetaMathQA/utils.py516 except Exception as exc:CODE
LOWexamples/ephemeral_gpu_offloading/load_with_dora.py75 except Exception as e:CODE
LOWexamples/ephemeral_gpu_offloading/load_with_dora.py80 except Exception as e:CODE
LOWexamples/qalora_finetuning/qalora_gptq_finetuning.py69 except Exception as e:CODE
LOWexamples/adamss_finetuning/test_adamss_quick.py169except Exception as e:CODE
LOWscripts/generate_method_capabilities.py283 except Exception as exc:CODE
LOWscripts/generate_method_capabilities.py303 except Exception as exc:CODE
LOWscripts/generate_method_capabilities.py326 except Exception as exc:CODE
LOWscripts/generate_method_capabilities.py362 except Exception as exc:CODE
LOWscripts/generate_method_capabilities.py394 except Exception as exc:CODE
LOWscripts/generate_method_capabilities.py460 except Exception as exc:CODE
LOWscripts/generate_method_capabilities.py514 except Exception as exc:CODE
LOWscripts/generate_method_capabilities.py580 except Exception as exc:CODE
LOWscripts/generate_method_capabilities.py588 except Exception as exc:CODE
MEDIUMscripts/generate_method_capabilities.py352def run(self) -> Finding:CODE
LOWsrc/peft/config.py116 except Exception:STRING
LOWsrc/peft/config.py258 except Exception as exc:STRING
LOWsrc/peft/config.py322 except Exception:STRING
MEDIUMsrc/peft/peft_model.py176def active_adapters(self) -> list[str]:CODE
LOWsrc/peft/peft_model.py1160 except Exception: # something went wrong, roll backCODE
LOWsrc/peft/mixed_model.py242 except Exception: # something went wrong, roll backCODE
LOWsrc/peft/helpers.py162 except Exception:CODE
LOWsrc/peft/utils/other.py1476 except Exception as e:CODE
LOWsrc/peft/tuners/boft/layer.py97 except Exception as e:CODE
LOWsrc/peft/tuners/adamss/layer.py180 except Exception as e:CODE
Decorative Section Separators17 hits · 57 pts
SeverityFileLineSnippetContext
MEDIUMtests/test_arrow.py30# ─── Fixtures ──────────────────────────────────────────────────────────COMMENT
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py19# ==========================================COMMENT
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py21# ==========================================COMMENT
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py47# ==========================================COMMENT
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py49# ==========================================COMMENT
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py146# ==========================================COMMENT
MEDIUMexamples/KappaTune/experiments_kappatune_peft.py148# ==========================================COMMENT
MEDIUM…etuning/sequence_classification_finetune_monteclora.py21# ----------------------------------------------------------------------------COMMENT
MEDIUM…etuning/sequence_classification_finetune_monteclora.py23# ----------------------------------------------------------------------------COMMENT
MEDIUM…etuning/sequence_classification_finetune_monteclora.py29# ----------------------------------------------------------------------------COMMENT
MEDIUM…etuning/sequence_classification_finetune_monteclora.py31# ----------------------------------------------------------------------------COMMENT
MEDIUM…etuning/sequence_classification_finetune_monteclora.py42# ----------------------------------------------------------------------------COMMENT
MEDIUM…etuning/sequence_classification_finetune_monteclora.py44# ----------------------------------------------------------------------------COMMENT
MEDIUM…etuning/sequence_classification_finetune_monteclora.py162# ----------------------------------------------------------------------------COMMENT
MEDIUM…etuning/sequence_classification_finetune_monteclora.py164# ----------------------------------------------------------------------------COMMENT
MEDIUMsrc/peft/tuners/lora/layer.py863# ------------------------------------------------------------------------------------------COMMENT
MEDIUMsrc/peft/tuners/lora/layer.py866# ------------------------------------------------------------------------------------------COMMENT
AI Structural Patterns59 hits · 56 pts
SeverityFileLineSnippetContext
LOWtests/testing_utils.py286CODE
LOWtests/test_lora_variants.py73CODE
LOWtests/test_torch_compile.py146CODE
LOWmethod_comparison/text_generation_benchmark/run_base.py122CODE
LOWmethod_comparison/text_generation_benchmark/utils.py279CODE
LOWexamples/boft_controlnet/utils/pipeline_controlnet.py166CODE
LOWexamples/boft_controlnet/utils/unet_2d_condition.py38CODE
LOWexamples/waveft_finetuning/waveft_finetuning.py30CODE
LOWexamples/hira_finetuning/hira_finetuning.py26CODE
LOWexamples/glora_finetuning/glora_finetuning.py26CODE
LOWexamples/olora_finetuning/olora_finetuning.py30CODE
LOWexamples/shira_finetuning/shira_finetuning.py31CODE
LOWexamples/corda_finetuning/datautils.py95CODE
LOWscripts/train_memory.py106CODE
LOWsrc/peft/peft_model.py1870CODE
LOWsrc/peft/peft_model.py2053CODE
LOWsrc/peft/peft_model.py2397CODE
LOWsrc/peft/peft_model.py2724CODE
LOWsrc/peft/peft_model.py2954CODE
LOWsrc/peft/peft_model.py3025CODE
LOWsrc/peft/utils/incremental_pca.py46CODE
LOWsrc/peft/tuners/hra/layer.py268CODE
LOWsrc/peft/tuners/hra/layer.py458CODE
LOWsrc/peft/tuners/loha/layer.py244CODE
LOWsrc/peft/tuners/lokr/layer.py314CODE
LOWsrc/peft/tuners/vera/layer.py289CODE
LOWsrc/peft/tuners/delora/layer.py267CODE
LOWsrc/peft/tuners/boft/layer.py651CODE
LOWsrc/peft/tuners/boft/layer.py994CODE
LOWsrc/peft/tuners/waveft/layer.py289CODE
LOWsrc/peft/tuners/c3a/layer.py202CODE
LOWsrc/peft/tuners/frod/layer.py346CODE
LOWsrc/peft/tuners/road/layer.py397CODE
LOWsrc/peft/tuners/fourierft/layer.py191CODE
LOWsrc/peft/tuners/vblora/layer.py253CODE
LOWsrc/peft/tuners/gralora/layer.py387CODE
LOWsrc/peft/tuners/adaption_prompt/layer.py139CODE
LOWsrc/peft/tuners/unilora/layer.py252CODE
LOWsrc/peft/tuners/tinylora/layer.py414CODE
LOWsrc/peft/tuners/miss/layer.py367CODE
LOWsrc/peft/tuners/ia3/layer.py319CODE
LOWsrc/peft/tuners/xlora/layer.py131CODE
LOWsrc/peft/tuners/xlora/layer.py236CODE
LOWsrc/peft/tuners/pvera/layer.py312CODE
LOWsrc/peft/tuners/lora/variants.py246CODE
LOWsrc/peft/tuners/lora/variants.py345CODE
LOWsrc/peft/tuners/lora/variants.py434CODE
LOWsrc/peft/tuners/lora/variants.py889CODE
LOWsrc/peft/tuners/lora/variants.py1218CODE
LOWsrc/peft/tuners/lora/eva.py655CODE
LOWsrc/peft/tuners/lora/layer.py740CODE
LOWsrc/peft/tuners/lora/layer.py2153CODE
LOWsrc/peft/tuners/randlora/layer.py346CODE
LOWsrc/peft/tuners/oft/awq.py69CODE
LOWsrc/peft/tuners/oft/gptq.py67CODE
LOWsrc/peft/tuners/oft/layer.py687CODE
LOWsrc/peft/tuners/oft/layer.py940CODE
LOWsrc/peft/tuners/deft/layer.py345CODE
LOWsrc/peft/tuners/poly/layer.py161CODE
Redundant / Tautological Comments28 hits · 46 pts
SeverityFileLineSnippetContext
LOWtests/test_xlora.py317 # Set it to 2 and make sure it actually isCOMMENT
LOWtests/test_xlora.py322 # Set it to None and make sure it is 1/nCOMMENT
LOWtests/test_lorafa.py212 # Check if lora_A weights have not changedCOMMENT
LOWtests/test_lorafa.py217 # Check if lora_B weights are non-zeroCOMMENT
LOWtests/test_lorafa.py243 # Check if lora_A weights have not changedCOMMENT
LOWtests/test_lorafa.py248 # Check if lora_B weights are non-zero and if they follow the expected relationCOMMENT
LOWtests/test_lorafa.py280 # Check if all non-LoRA params also follow the expected relationCOMMENT
LOWtests/test_config.py438 # Check if the user supplied timing values that will certainly fail because it breaksSTRING
LOWmethod_comparison/MetaMathQA/utils.py440 # Check if the string represents a fraction.COMMENT
LOWexamples/waveft_finetuning/waveft_finetuning.py50 # Set device_map to the right place when enabling DDP.COMMENT
LOWexamples/olora_finetuning/olora_finetuning.py51 # Set device_map to the right place when enabling DDP.COMMENT
LOWexamples/alora_finetuning/alora_finetuning.py186 # Print resultsCOMMENT
LOWexamples/qalora_finetuning/qalora_gptq_finetuning.py50 # Check if the model has GPTQ quantization attributesCOMMENT
LOWexamples/qalora_finetuning/qalora_gptq_finetuning.py78 # Check if we already have a cached quantized versionCOMMENT
LOWexamples/shira_finetuning/shira_finetuning.py49 # Set device_map to the right place when enabling DDP.COMMENT
LOWexamples/sft/utils.py194 # Check if the model is quantizedCOMMENT
LOW…s/int8_training/peft_adalora_whisper_large_training.py707 # Check if rank_pattern exists before calling update_and_allocateCOMMENT
LOWsrc/peft/utils/other.py1574 # Check if this is the embedding layer (use endswith to allow flexible matching)COMMENT
LOWsrc/peft/utils/other.py1579 # Check if this target layer matches any tied module (considering nested structures)COMMENT
LOWsrc/peft/utils/other.py1587 # Check if all tied layers have the same indicesCOMMENT
LOWsrc/peft/tuners/tuners_utils.py1875 # Check if adding this suffix covers the itemCOMMENT
LOWsrc/peft/tuners/adamss/model.py98 # Check if already an Adamss layerCOMMENT
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)CODE
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)CODE
LOWsrc/peft/tuners/adalora/config.py94 # Check if 'r' has been set to a non-default valueCOMMENT
LOWsrc/peft/tuners/lora/loraga.py136 # Check if any supported layers were foundCOMMENT
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)CODE
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)CODE
AI Slop Vocabulary16 hits · 35 pts
SeverityFileLineSnippetContext
MEDIUMtests/test_trainable_tokens.py664 # for this we can leverage the fact that emb_out(1/emb_in(x)) is embed_dim on theCOMMENT
MEDIUMtests/test_trainable_tokens.py701 # for this we can leverage the fact that emb_out(1/emb_in(x)) is embed_dim on theCOMMENT
MEDIUMtests/test_trainable_tokens.py762 # for this we can leverage the fact that emb_out(1/emb_in(x)) is embed_dim on theCOMMENT
MEDIUMtests/test_gpu_examples.py5806 # increase the scale of the LoRA weights so that the difference between adapters is more pronounced, making COMMENT
MEDIUMtests/test_initialization.py1556 # some arguments don't work in conjunction with lora_bias and should raiseCOMMENT
LOWtests/test_decoder_models.py522 # a malicious prompt tuning model. This is because PEFT would just pass the on the tokenizer_kwargs defined inCOMMENT
LOWtests/test_other.py409 # aware that some of the passing tests may just pass owing to randomness.COMMENT
LOWexamples/dora_finetuning/dora_finetuning.py73 use_dora=use_dora, # to use Dora OR compare to Lora just set the --use_doraCODE
MEDIUMsrc/peft/peft_model.py1046 # TODO: consider replacing this patching of methods with a more robust mechanism: setting a flag andCOMMENT
LOWsrc/peft/utils/other.py1764 # technically it would be sufficient to just return candidates since that contains all the keys ofCOMMENT
LOWsrc/peft/utils/transformers_weight_conversion.py493 # If, for any reason, we cannot apply conversion, we just return the PEFT config as is.COMMENT
MEDIUMsrc/peft/tuners/tuners_utils.py875 # TODO: check if this the most robust waySTRING
LOWsrc/peft/tuners/tuners_utils.py301 # model, just add a `peft_config` dict attribute to your model.STRING
LOWsrc/peft/tuners/adamss/layer.py395 # so just call base_layer directly (no adapter delta needed).COMMENT
LOWsrc/peft/tuners/lora/conversion.py329 # effective rank is the same and target_modules are a set, just add the nameCOMMENT
MEDIUMsrc/peft/tuners/lora/layer.py387 # check without importing bitsandbytes and robust to bnb_4bit_quant_storage=float*COMMENT
Docstring Block Structure6 hits · 30 pts
SeverityFileLineSnippetContext
HIGHexamples/boft_controlnet/utils/pipeline_controlnet.py196 Function invoked when calling the pipeline for generation. Args: prompt (`str` or `List[stSTRING
HIGHexamples/qalora_finetuning/qalora_gptq_finetuning.py109 Tokenize text data and prepare it for language modeling. Args: examples: Dataset examples with 'text' STRING
HIGHsrc/peft/peft_model.py3213Get the status of each adapter layer in the model. This function returns a list of `TunerLayerStatus` dataclass insSTRING
HIGHsrc/peft/peft_model.py3347Get the status of tuners of the model. This function returns a `TunerModelStatus` dataclass instance, which containSTRING
HIGHsrc/peft/tuners/tuners_utils.py364 A private method to prepare the adapter config. For transformers based models, if `peft_config.target_STRING
HIGHsrc/peft/tuners/tuners_utils.py1806Find the minimal set of target modules that is sufficient to separate them from the other modules. Sometimes, a verSTRING
Structural Annotation Overuse13 hits · 27 pts
SeverityFileLineSnippetContext
LOWtests/test_adamss_asa.py107 # Step 1: train so B becomes non-zeroCOMMENT
LOWtests/test_adamss_asa.py113 # Step 2: now gradients for A should be non-zeroCOMMENT
LOWtests/test_adamss_asa.py123 # Step 3: another update should change scores via EMACOMMENT
LOWtests/test_adamss_asa.py166 # Step 0: train to make B non-zeroCOMMENT
LOWexamples/lora_ga_finetuning/README.md38# Step 1: Create LoRA-GA configCOMMENT
LOWexamples/lora_ga_finetuning/README.md54# Step 2: Preprocess with LoRA-GA to estimate gradientsCOMMENT
LOWexamples/lora_ga_finetuning/README.md57# Step 3: Create PEFT model with LoRA-GA initializationCOMMENT
LOWexamples/lora_ga_finetuning/README.md60# Step 4: Train normallyCOMMENT
LOWexamples/lora_ga_finetuning/README.md68# Step 5: Save the trained adapterCOMMENT
LOWexamples/lora_ga_finetuning/README.md211### Step 1: Estimate gradients with full-precision modelCOMMENT
LOWexamples/lora_ga_finetuning/README.md250### Step 2: Load quantized model and apply LoRA-GACOMMENT
LOWsrc/peft/tuners/adamss/model.py193 # Step 1: accumulate importance EVERY step during warmupCOMMENT
LOWsrc/peft/tuners/adamss/model.py198 # Step 2: at mask intervals → schedule, global mask, then resetCOMMENT
Verbosity Indicators7 hits · 15 pts
SeverityFileLineSnippetContext
LOWtests/test_adamss_asa.py107 # Step 1: train so B becomes non-zeroCOMMENT
LOWtests/test_adamss_asa.py113 # Step 2: now gradients for A should be non-zeroCOMMENT
LOWtests/test_adamss_asa.py123 # Step 3: another update should change scores via EMACOMMENT
LOWtests/test_adamss_asa.py166 # Step 0: train to make B non-zeroCOMMENT
LOWsrc/peft/import_utils.py96 # We need to check if `xla_device` can be found, will raise a RuntimeError if notCOMMENT
LOWsrc/peft/tuners/adamss/model.py193 # Step 1: accumulate importance EVERY step during warmupCOMMENT
LOWsrc/peft/tuners/adamss/model.py198 # Step 2: at mask intervals → schedule, global mask, then resetCOMMENT
Cross-Language Confusion5 hits · 12 pts
SeverityFileLineSnippetContext
HIGHsrc/peft/peft_model.py1795 trainable params: 370178 || all params: 108680450 || trainable%: 0.3406113979101117STRING
HIGHsrc/peft/peft_model.py2043 trainable params: 1843200 || all params: 775873280 || trainable%: 0.23756456724479544STRING
HIGHsrc/peft/peft_model.py2384 trainable params: 884736 || all params: 223843584 || trainable%: 0.3952474242013566STRING
HIGHsrc/peft/peft_model.py2653 trainable params: 370178 || all params: 108680450 || trainable%: 0.3406113979101117STRING
HIGHsrc/peft/peft_model.py2883 trainable params: 592900 || all params: 108312580 || trainable%: 0.5473971721475013STRING
Slop Phrases7 hits · 10 pts
SeverityFileLineSnippetContext
LOWtests/regression/test_regression.py189 model output, and load_base_model(name) to load the base model. Don't forget to fix the seed in load_base_model.STRING
MEDIUMexamples/beft_finetuning/beft_finetuning.py68# you can try target_modules=["v"], target_modules=["q"], target_modules=["k"]COMMENT
LOW…ture_extraction/peft_lora_embedding_semantic_search.py157 # make sure to pop weight so that corresponding model is not saved againCOMMENT
MEDIUMexamples/arrow_multitask/arrow_phi3_mini.py57This script is mainly meant for demonstration purposes and lightweight evaluation,STRING
MEDIUMexamples/alora_finetuning/alora_finetuning.py168 Purely for demonstration purposes. See the [paper](https://huggingface.co/papers/2504.12397)STRING
LOW…s/int8_training/peft_adalora_whisper_large_training.py325 # make sure to pop weight so that corresponding model is not saved againCOMMENT
LOWsrc/peft/tuners/lora/intruders.py115 # we're not modifying the weights since there are no intruders but we make sure to copy theCOMMENT
TODO Padding4 hits · 5 pts
SeverityFileLineSnippetContext
LOWtests/testing_common.py1829 # TODO: add tests to check if disabling adapters works after calling merge_adapterSTRING
LOWsrc/peft/tuners/xlora/layer.py114 # TODO: implement X-LoRA with Lora+Dora layersCOMMENT
LOWsrc/peft/tuners/xlora/layer.py165 # TODO: implement X-LoRA with Lora+Dora layersCOMMENT
LOWsrc/peft/tuners/xlora/layer.py219 # TODO: implement X-LoRA with Lora+Dora layersCOMMENT
Fake / Example Data1 hit · 1 pts
SeverityFileLineSnippetContext
LOWdocs/source/package_reference/lora.md742invocation_string = "placeholder"CODE