Skip to content
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

🧞 Fix genai exporter arguments bug and add Genai phi2 example #1061

Merged
merged 3 commits into from
Apr 9, 2024

Conversation

trajepl
Copy link
Contributor

@trajepl trajepl commented Apr 9, 2024

Describe your changes

  1. With the latest onnxruntime-genai, there are a few bugs:
    a. precision can only accept string value(int4, fp16, fp32) but not the
    image
    b. execution_provider accept ep value but not device value
    c. the pass of GenAIModelExporter is not EP agnostic. For cuda int4, the input shape is changed to fp16, but for cpu int4, it is still fp32.

  2. Add phi2 example.

  • CUDA: v100
    image
  • CPU: Intel(R) Xeon(R) CPU E5-2698
    image
  1. Update genai generation example in README of llama2/phi2.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.
  • Is this PR including examples changes? If yes, please remember to update example documentation in a follow-up PR.

(Optional) Issue link

@trajepl trajepl requested a review from shaahji April 9, 2024 06:42
examples/phi2/phi2.py Fixed Show fixed Hide fixed
examples/phi2/phi2.py Fixed Show fixed Hide fixed
examples/phi2/phi2.py Fixed Show fixed Hide fixed
shaahji
shaahji previously approved these changes Apr 9, 2024
@guotuofeng
Copy link
Collaborator

    INT4 = "int4"

I think add __str__ could fix the str(Precision.FP32) issue.


Refers to: olive/passes/onnx/genai_model_exporter.py:31 in b5f1e71. [](commit_id = b5f1e71, deletion_comment = True)


@staticmethod
def is_accelerator_agnostic(accelerator_spec: AcceleratorSpec) -> bool:
return False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, hardware dependent means need create InferenceSession and need run on target.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, like Mike says, a search point can be invalid for a particular ep while the pass is accelerator agnostic.

Pass is only non-agnostic if the output of the pass changes based on the accelerator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, line 81 depends on the accelerator_spec so it satisfies the requirement.

Copy link
Contributor Author

@trajepl trajepl Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems, we need an extra pass config like target_ep. Then the is_accelerator_agnostic can be True.
Synced with Mike, the accelerator_spec here is target device so current change is fine.

For genai exporter, the output will be different for different ep.
For cuda int4, the input shape is changed to fp16, but for cpu int4, it is still fp32.

@guotuofeng
Copy link
Collaborator

    INT4 = "int4"

I think add __str__ could fix the str(Precision.FP32) issue.

Refers to: olive/passes/onnx/genai_model_exporter.py:31 in b5f1e71. [](commit_id = b5f1e71, deletion_comment = True)

Please make sure the search point is always Enum. If there are any possibility to use str for precision, we'd better add __str__

@trajepl trajepl merged commit 960d387 into main Apr 9, 2024
33 checks passed
@trajepl trajepl deleted the jiapli/genai_export_fix branch April 9, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants