-
-
Notifications
You must be signed in to change notification settings - Fork 927
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify haldning for newer multipack patches so they can be added in…
… a single place (#1270)
- Loading branch information
Showing
7 changed files
with
46 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""multipack patching for v2 of sample packing""" | ||
|
||
import transformers | ||
from transformers.integrations import is_deepspeed_zero3_enabled | ||
|
||
from axolotl.monkeypatch.mixtral import patch_mixtral_moe_forward_zero3 | ||
from axolotl.monkeypatch.utils import get_unpad_data | ||
|
||
SUPPORTED_MULTIPACK_MODEL_TYPES = ["mixtral", "qwen2", "falcon", "phi"] | ||
|
||
|
||
def patch_for_multipack(model_type): | ||
if model_type == "mixtral": | ||
transformers.models.mixtral.modeling_mixtral._get_unpad_data = ( # pylint: disable=protected-access | ||
get_unpad_data | ||
) | ||
if is_deepspeed_zero3_enabled(): | ||
patch_mixtral_moe_forward_zero3() | ||
elif model_type == "qwen2": | ||
transformers.models.qwen2.modeling_qwen2._get_unpad_data = ( # pylint: disable=protected-access | ||
get_unpad_data | ||
) | ||
elif model_type == "falcon": | ||
transformers.models.falcon.modeling_falcon._get_unpad_data = ( # pylint: disable=protected-access | ||
get_unpad_data | ||
) | ||
elif model_type == "phi": | ||
transformers.models.phi.modeling_phi._get_unpad_data = ( # pylint: disable=protected-access | ||
get_unpad_data | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters