|
21 | 21 | from executorch.extension.llm.export.config.llm_config import LlmConfig |
22 | 22 | from torchao.utils import TorchAOBaseTensor |
23 | 23 |
|
24 | | -try: |
25 | | - from .fairseq2 import convert_to_llama_checkpoint |
26 | | - |
27 | | -except ImportError: |
28 | | - |
29 | | - def convert_to_llama_checkpoint(**kwargs): |
30 | | - raise NotImplementedError( |
31 | | - "Please install fairseq2 with `pip install fairseq2`." |
32 | | - ) |
33 | | - |
34 | | - |
35 | 24 | from ..model_base import EagerModelBase |
36 | 25 |
|
37 | 26 |
|
@@ -70,33 +59,10 @@ def __init__(self, llm_config: Optional[LlmConfig] = None): |
70 | 59 | checkpoint = {} |
71 | 60 | if checkpoint_path: |
72 | 61 | checkpoint = torch.load(checkpoint_path, map_location=device, mmap=True) |
73 | | - |
74 | | - # If given checkpoint is fairseq, convert to llama checkpoint. |
75 | | - fairseq2_checkpoint = self.llm_config.base.fairseq2 |
76 | | - if fairseq2_checkpoint: |
77 | | - print("Using fairseq2 checkpoint") |
78 | | - checkpoint = convert_to_llama_checkpoint(checkpoint=checkpoint) |
79 | 62 | if "model" in checkpoint: |
80 | 63 | # NB: some checkpoint contains a "model" field, which is the actual weights dict |
81 | 64 | checkpoint = checkpoint["model"] |
82 | 65 |
|
83 | | - # Check if user gave a fairseq2 checkpoint unknowingly without specifying --fairseq2. |
84 | | - if (not fairseq2_checkpoint) and checkpoint.get( |
85 | | - "final_proj.weight", None |
86 | | - ) is not None: |
87 | | - raise ValueError( |
88 | | - """ |
89 | | -************************************************************ |
90 | | -This looks like a Fairseq2 checkpoint (based on the presence |
91 | | -of `final_proj.weight`. |
92 | | -
|
93 | | -You can import Fairseq2 checkpoints using the --fairseq2 |
94 | | -option, but --fairseq2 was not specified. Please verify |
95 | | -the checkpoint format to avoid generating faulty models. |
96 | | -************************************************************ |
97 | | -""" |
98 | | - ) |
99 | | - |
100 | 66 | # Get optional params. |
101 | 67 | params = {} |
102 | 68 | if params_path: |
|
0 commit comments