-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(transformers): api(image processor/feature extractor/automodel/pipelines) #802
base: master
Are you sure you want to change the base?
Conversation
冲突可以先解一下 |
|
||
def torch_int(x): | ||
""" | ||
Casts an input to a torch int64 tensor if we are in a tracing context, otherwise to a Python int. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
torch -> mindspore 全局换一下
|
||
logger = logging.get_logger(__name__) | ||
|
||
MODEL_MAPPING_NAMES = OrderedDict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some supported models in mindone/transformers/models
are missing, like llama and gemma2. pls check and add.
("pegasus_x", "PegasusXForConditionalGeneration"), | ||
("plbart", "PLBartForConditionalGeneration"), | ||
("prophetnet", "ProphetNetForConditionalGeneration"), | ||
("qwen2_audio", "Qwen2AudioForConditionalGeneration"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qwen2_audio not implemented
] | ||
) | ||
|
||
MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES = OrderedDict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either comment those models that are not supported or simply assert and claim will be supported in the future
|
||
# Downcast (if necessary) back to V's dtype (if in mixed-precision) -- No-Op if otherwise | ||
if attn_weights.dtype != ms.float32: | ||
raise RuntimeError("Error with upcasting, attn_weights does not have dtype torch.float32") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
torch.float32 -> ms.float32
scale_factor /= float(self.layer_idx + 1) | ||
|
||
# Upcast (turn off autocast) and reorder (Scale K by 1 / root(dk)) | ||
with ms.amp.autocast(query.device.type, enabled=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ms2.4.1 doesn't support amp.autocast or tensor.device. how is it from
|
||
class GPT2SdpaAttention(GPT2Attention): | ||
""" | ||
GPT2 attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update docstring for mindspore
Base class for outputs of models predicting if two sentences are consecutive or not. | ||
|
||
Args: | ||
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same docstring problem here
新增模型加下tests,看下和torch的精度误差 |
What does this PR do?
This PR(based on #748) contains following features:
Image processor and feature extractor would be served as part of VLLM. It could be tested based on PR749 and test scripts
AutoModel could be used to call model existed on mindone.transformers or could be integrated in Pipelines api:
Pipelines part could tested based on following codes:
Expected output:
GPT-2 Model could be tested based on Text Generation Pipe:
Expected Output:
Before submitting
What's New
. Here are thedocumentation guidelines
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@xxx