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

Support ONNX export on torch.float16 type #749

Merged
merged 18 commits into from
Feb 27, 2023

Conversation

fxmarty
Copy link
Contributor

@fxmarty fxmarty commented Feb 6, 2023

As per title.

Test still missing. Partly fixes https://discuss.huggingface.co/t/convert-gpt-j-to-fp-16-onnx/30294

Copy link
Contributor

@JingyaHuang JingyaHuang left a comment

Choose a reason for hiding this comment

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

Just add two nits, btw is the torch onnx export on fp16 stable?

@fxmarty
Copy link
Contributor Author

fxmarty commented Feb 7, 2023

is the torch onnx export on fp16 stable

I've tried on a single model - and did not try to load into an InferenceSession. I will add a test for it, thanks.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Feb 7, 2023

The documentation is not available anymore as the PR was closed or merged.

@fxmarty fxmarty force-pushed the support-onnx-export-float16 branch from 1ff3ed8 to 2d210a6 Compare February 9, 2023 13:41
Copy link
Contributor

@regisss regisss left a comment

Choose a reason for hiding this comment

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

LGTM!

optional_group.add_argument(
"--fp16",
action="store_true",
help="Experimental option: use half precision during the export. PyTorch-only, requires `--device cuda`.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Experimental because it doesn't work with all models?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd say experimental because I haven't thouroughly tested it with ONNX Runtime + CUDAExecutionProvider / TensorrtExecutionProvider, and neither with native TensorRT (though in the validation itself we call InferenceSession on CUDA EP, so it's a good sign it's fine). But the export itself is thoroughly tested.

@fxmarty fxmarty merged commit 0b71b46 into huggingface:main Feb 27, 2023
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.

5 participants