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

feat: support custom onnx file and update model signatures #761

Merged
merged 52 commits into from
Jul 12, 2022
Merged

Conversation

ZiniuYu
Copy link
Member

@ZiniuYu ZiniuYu commented Jun 27, 2022

This PR allows the user to set filepath for pretrained custom onnx model and unify the signature of tensorrt, onnx, and huggingface clip runtime.
We also add md5 verification to make sure users download the latest and correct models.
Since tensorrt models are extremely picky for many dependencies, we no longer support tensorrt model hosting, which means that it will first download the latest onnx model and convert to trt during runtime and save for it later use.

TODO:

  • Add parameters to allow user select custom pretrained onnx model
  • Convert existing models to have updated signatures
  • Modify other executors to be compatible with the new structure
  • Add MD5 verification for downloaded model

@codecov
Copy link

codecov bot commented Jun 27, 2022

Codecov Report

Merging #761 (94008ac) into main (ed1b92d) will increase coverage by 0.71%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #761      +/-   ##
==========================================
+ Coverage   78.31%   79.03%   +0.71%     
==========================================
  Files          17       17              
  Lines        1213     1240      +27     
==========================================
+ Hits          950      980      +30     
+ Misses        263      260       -3     
Flag Coverage Δ
cas 79.03% <100.00%> (+0.71%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/clip_server/executors/clip_torch.py 87.03% <ø> (ø)
server/clip_server/executors/clip_onnx.py 85.48% <100.00%> (ø)
server/clip_server/executors/helper.py 100.00% <100.00%> (ø)
server/clip_server/model/clip.py 65.60% <100.00%> (+6.31%) ⬆️
server/clip_server/model/clip_onnx.py 96.96% <100.00%> (+0.96%) ⬆️
server/clip_server/model/clip_trt.py 92.10% <100.00%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed1b92d...94008ac. Read the comment docs.

server/clip_server/model/clip_onnx.py Outdated Show resolved Hide resolved
server/clip_server/executors/clip_onnx.py Outdated Show resolved Hide resolved
server/clip_server/model/clip_onnx.py Outdated Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
server/clip_server/model/clip_onnx.py Outdated Show resolved Hide resolved
server/clip_server/model/clip_onnx.py Show resolved Hide resolved
server/clip_server/model/clip_onnx.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/m and removed size/s labels Jul 1, 2022
server/clip_server/model/clip_onnx.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
@@ -335,6 +336,7 @@ def tokenize(
eot_token = _tokenizer.encoder['<|endoftext|>']
all_tokens = [[sot_token] + _tokenizer.encode(text) + [eot_token] for text in texts]
result = torch.zeros(len(all_tokens), context_length, dtype=torch.long)
attention_masks = torch.zeros(len(all_tokens), context_length, dtype=torch.long)
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to support variable input length here.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is blocked

server/clip_server/model/model.py Outdated Show resolved Hide resolved
server/clip_server/executors/helper.py Outdated Show resolved Hide resolved
server/clip_server/model/clip_onnx.py Outdated Show resolved Hide resolved
server/clip_server/model/clip_onnx.py Show resolved Hide resolved
server/clip_server/model/clip_trt.py Show resolved Hide resolved
server/clip_server/model/clip_trt.py Show resolved Hide resolved
server/clip_server/model/clip_trt.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/executors/helper.py Outdated Show resolved Hide resolved
server/clip_server/executors/helper.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip_trt.py Show resolved Hide resolved
server/clip_server/tensorrt-flow.yml Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/l and removed size/m labels Jul 7, 2022
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip.py Outdated Show resolved Hide resolved
server/clip_server/model/clip_onnx.py Outdated Show resolved Hide resolved
server/clip_server/model/clip_trt.py Show resolved Hide resolved
server/clip_server/model/clip_trt.py Show resolved Hide resolved
server/clip_server/model/clip_trt.py Show resolved Hide resolved
@numb3r3 numb3r3 closed this Jul 11, 2022
@numb3r3 numb3r3 reopened this Jul 11, 2022
@github-actions
Copy link

📝 Docs are deployed on https://ft-improve_onnx--jina-docs.netlify.app 🎉

@numb3r3 numb3r3 merged commit ee7da10 into main Jul 12, 2022
@numb3r3 numb3r3 deleted the improve_onnx branch July 12, 2022 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants