Skip to content

Commit 8f24220

Browse files
pytorchbotGithub Executorchlucylq
authored andcommitted
Introduce MultimethodLoraConfig (pytorch#17455)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: pytorch#17230 by @lucylq ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/lucylq/133/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/lucylq/133/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/lucylq/132/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/lucylq/133/orig Differential Revision: [D92315627](https://our.internmc.facebook.com/intern/diff/D92315627/) @diff-train-skip-merge --------- Co-authored-by: Github Executorch <github_executorch@arm.com> Co-authored-by: lucylq <lfq@meta.com>
1 parent f6f368f commit 8f24220

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

extension/llm/export/config/llm_config.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import re
2323
from dataclasses import dataclass, field
2424
from enum import Enum
25-
from typing import ClassVar, List, Optional
25+
from typing import ClassVar, Dict, List, Optional
2626

2727

2828
################################################################################
@@ -287,6 +287,37 @@ class DebugConfig:
287287
verbose: bool = False
288288

289289

290+
################################################################################
291+
############################## MultimethodLoraConfig ###########################
292+
################################################################################
293+
294+
295+
@dataclass
296+
class MultimethodLoraConfig:
297+
"""Configuration for exporting multiple methods to a single .pte file.
298+
299+
Maps method names to optional LoRA configurations. A None value means
300+
the method uses base model weights.
301+
302+
Attributes:
303+
methods: Dict mapping method names to optional LoRA configs.
304+
Empty dict disables multimethod export.
305+
306+
Example:
307+
MultimethodLoraConfig(methods={
308+
"forward": None, # base model
309+
"lora_forward": lora_config, # LoRA variant
310+
})
311+
"""
312+
313+
methods: Dict[str, Optional[LoraConfig]] = field(default_factory=dict)
314+
315+
@property
316+
def enabled(self) -> bool:
317+
"""Returns True if multimethod_lora export is configured."""
318+
return len(self.methods) > 0
319+
320+
290321
################################################################################
291322
############################# QuantizationConfig ###############################
292323
################################################################################
@@ -543,6 +574,9 @@ class LlmConfig:
543574
model: ModelConfig = field(default_factory=ModelConfig)
544575
export: ExportConfig = field(default_factory=ExportConfig)
545576
debug: DebugConfig = field(default_factory=DebugConfig)
577+
multimethod_lora: MultimethodLoraConfig = field(
578+
default_factory=MultimethodLoraConfig
579+
)
546580
quantization: QuantizationConfig = field(default_factory=QuantizationConfig)
547581
backend: BackendConfig = field(default_factory=BackendConfig)
548582

0 commit comments

Comments
 (0)