Detect the LoRA format of a given key. Args: key: The weight key to check lora_weights: The full LoRA weights dictionary Returns: Tuple of (LoRAFormat, detected_suffix) if format detected, None otherwise
(self, key: str, lora_weights: Dict)
| 109 | } |
| 110 | |
| 111 | def detect_format(self, key: str, lora_weights: Dict) -> Optional[Tuple[LoRAFormat, str]]: |
| 112 | """ |
| 113 | Detect the LoRA format of a given key. |
| 114 | |
| 115 | Args: |
| 116 | key: The weight key to check |
| 117 | lora_weights: The full LoRA weights dictionary |
| 118 | |
| 119 | Returns: |
| 120 | Tuple of (LoRAFormat, detected_suffix) if format detected, None otherwise |
| 121 | """ |
| 122 | for format_type, pattern in self.patterns.items(): |
| 123 | if key.endswith(pattern.up_suffix): |
| 124 | return (format_type, pattern.up_suffix) |
| 125 | return None |
| 126 | |
| 127 | def extract_lora_pair( |
| 128 | self, |
no test coverage detected