-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aafeecc
commit 39c9a02
Showing
5 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
optimum/neuron/distributed/leaf_functions_for_pipeline_parallelism.py
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,18 @@ | ||
import torch | ||
from transformers.modeling_attn_mask_utils import ( | ||
_prepare_4d_causal_attention_mask, | ||
_prepare_4d_causal_attention_mask_for_sdpa, | ||
) | ||
|
||
|
||
leaf_prepare_4d_causal_attention_mask = torch.fx._symbolic_trace._create_wrapped_func( | ||
_prepare_4d_causal_attention_mask | ||
) | ||
|
||
leaf_prepare_4d_causal_attention_mask = torch.fx._symbolic_trace._create_wrapped_func( | ||
_prepare_4d_causal_attention_mask | ||
) | ||
|
||
leaf_prepare_4d_causal_attention_maskfor_sdpa = torch.fx._symbolic_trace._create_wrapped_func( | ||
_prepare_4d_causal_attention_mask_for_sdpa | ||
) |
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,9 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
import re | ||
import sys | ||
from optimum.neuron.utils.optimum_neuron_cc_wrapper import main | ||
|
||
if __name__ == '__main__': | ||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) | ||
sys.exit(main()) |
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,28 @@ | ||
# coding=utf-8 | ||
# Copyright 2024 The HuggingFace Team. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from libneuronxla.neuron_cc_wrapper import main as neuron_cc_wrapper_main | ||
|
||
from .cache_utils import get_hf_hub_cache_repos | ||
from .hub_neuronx_cache import hub_neuronx_cache | ||
|
||
|
||
def main(): | ||
with hub_neuronx_cache(cache_repo_id=get_hf_hub_cache_repos()[0]): | ||
return neuron_cc_wrapper_main() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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