-
Notifications
You must be signed in to change notification settings - Fork 537
Add ONNX support for InternLM2 #2244
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
base: main
Are you sure you want to change the base?
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
LGTM! Thanks a lot for the addition @gmf14
@@ -2414,7 +2414,7 @@ class ORTModelForCausalLMIntegrationTest(ORTModelTestMixin): | |||
|
|||
# TODO: fix "mpt" for which inference fails for transformers < v4.41 | |||
if is_transformers_version(">=", "4.41"): | |||
SUPPORTED_ARCHITECTURES.extend(["phi3", "mpt"]) | |||
SUPPORTED_ARCHITECTURES.extend(["phi3", "mpt", "internlm2"]) |
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.
Could you add a test using a tiny random model like katuni4ka/tiny-random-internlm2 ?
You can add it in respectively PYTORCH_EXPORT_MODELS_TINY
and MODEL_NAME
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.
Hi @echarlaix! Thanks a lot for your answer. I've added the tests in both PYTORCH_EXPORT_MODELS_TINY and MODEL_NAME.
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.
you will have to pass trust_remote_code=True for this model since huggingface/transformers#29667 was not merged
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.
I'm figuring out what the best way to pass the trust_remote_code = True
parameter to main_export() is for the text_export.py and text_export_cli.py files, for instance. Are there any other models that require this to true? A shallow approach (later can be abstracted) would be to simply add e.g. here something like:
# Check for models that require remote code execution
if "internlm2" in model_name:
trust_remote_code = True
Something similar would apply for ORTModelForCausalLM in test_modeling.py.
Thanks a lot for your feedback @echarlaix @IlyasMoutawwakil!
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.
@gmf14 for now we don't support many (any ?) of remote code models (because they are usually hard to maintain).
let's simply use if model_type in ["internlm2"]: trust_remote_code = True
in both export and modeling tests.
What does this PR do?
Adds support for ONNX export of InternLM2 model for text generation tasks (#2240).
Note: I checked the ONNX contribution guide and it seems I cannot find an updated version to add the tests, hence I haven't committed them yet. I would like to kindly ask what steps to take in order to add the tests correctly.
Before submitting
Who can review?
@fxmarty, @echarlaix, @JingyaHuang, @michaelbenayoun