Onnx enable tasks for supported models (part 2)#14700
Conversation
LysandreJik
left a comment
There was a problem hiding this comment.
Hey! Thanks for this, this is impressive work.
I wonder if it would be possible to upstream some of the content written in generate_dummy_inputs in the raw OnnxConfig object? It seems like a lot of the code can be reused among other models.
If it cannot be done, could you mention what are the current blockers so that we may study what needs to be done? For example, a clear separation between what models are encoder-decoders, which need past key value handling, etc.
Overall I'd argue that having very self-contained methods, that don't hop between different files, is a big plus in terms of readability. Having those be very explicit in the parent ONNX configuration and called with explicit method names in the downstream model-specific ONNX configuration would be a huge plus in terms of readability, in my opinion.
|
Gently pinging @LysandreJik for his blessing on the latest round of changes :) |
|
Does this ONNX conversion support |
Hi @sorenmc, no, you'll have to implement your own |
c8cc572 to
600e5f2
Compare
LysandreJik
left a comment
There was a problem hiding this comment.
Thanks for the update! I'm starting to think that even these ONNX changes could potentially live in optimum and that we could have a requirement on optimum if we wanted to use ONNX anywhere in the library - but I understand this might be a bit complex to maintain in the long run.
I think this adds a lot of complexity but I understand why it's needed for goo ONNX support. Ok to merge it like this but would like to revisit this at some point in the near future to discuss the separation of ONNX features in optimum/transformers
…d models (huggingface#14358)" (huggingface#14679)" This reverts commit 0f4e39c.
…onverting multiple models sequentially
1d873a3 to
b35705e
Compare
|
hi,
` config = AutoConfig.from_pretrained(model_name) I am trying a few export options and non of the gives me the output from the decoder. option 1:
output 1:huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks... ` options = SessionOptions() session = InferenceSession( session.disable_fallback() outputs = [i.name for i in session.get_outputs()] feed_dict = summarizer.tokenizer(text) for i, p in enumerate(pred): printout -0 logits (1, 228, 50265)
what i get -gives me back the input text, which basically means logits is simply the input_ids and I am guessing from the shape that 1209 is the encoded vectors for all tokens in the text input. if that is in fact the case, HOW DO I EXPORT THE base_model.decoder ? option 2:` convert(framework="pt", model=summarizer.model, output=Path(f"onnx/lidiya_bart1.onnx"), this results in the following error -using framework PyTorch: 1.10.2
|
import graph.onnx
convert { err }convert (framework="pt", model::summarize ,r.model,output=Path( f:\ onnx
\ lidiya_bart1.onnx"), opset=11,tokenizer=summarize, r.tokenize , r,pipeline_name: "summarization")
// envs/py39/lib/python3.9/site_packages/transformers/convert_graph_to_onnx.py:395,
in convert(framework, model, output, opset,tokenizer, use_external_format, pipeline_name,** model_kwargs)
# Export the graph framework == "pt": --> convert_pytorch
(nlp, opset,
output,
use_external_format) else: convert_tensorflow
(nlp, opset, output) envs/py39/lib/python3.9/site-packages/transformers/convert_graph_to_onnx.py: convert_py.torch(n - lp, opset,
output, use_external_format) # PyTorch
enable_onnx_checker use_external_data_format
arguments in v1.11,# py.torch version bakwards compatibile {x.x.x} parse(torch.version) <= parse("1.10 |
What does this PR do?
This PR reapplies the reverted PR #14358, and solves the issues that caused the revert.
What does this PR do?
This PR adds support for almost all the features available for already supported models.
Main contributions:
OnnxSeq2SeqConfigWithPast: a new class inheriting fromOnnxConfigWithPastdesigned specifically for seq2seq models, this should make things easier for the community to contribute.past_key_values), that have been requested by the community (check the list of supported feautres below)Features now supported: