Add support for position_ids and past_key_values in OrtBackend
#700
+305
−76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR updates how the
ortinputs are being handled to extend support for optional values such asposition_idsorpast_key_values.e.g.
onnx-community/Qwen3-Embedding-0.6B-ONNXhas been now enabled on Text Embeddings Inference (TEI) viaortthanks to the conditional addition of thepast_key_valuesif amongst the inputs, to leverage the optimized Multi-head Attention (MHA) nodes that do require those inputs, so now one could run the following (whereas with the version inmainit would fail with missing inputs onpast_key_values):Note
On a subsequent PR, both the input building and the pooling strategies for ONNX need to be updated to use the correct padding side, as it defaults to right padding which tends to be the norm, but there are models such as e.g. https://huggingface.co/onnx-community/Qwen3-Embedding-0.6B-ONNX, that use left padding instead.
Besides that this PR also bumps
ortto the latest release candidate whilst v2.0.0 is released, with the following breaking changes:ort::session::Sessionis now mutable, so placed in aMutextry_extract_tensoris nowtry_extract_arrayort::inputs!won't accept thendarray, but rather anort::valuee.g.
ort::value::TensorAdditionally, it requires to pin
ort-sysand add thestdfeature toort. More information in the release notes at https://github.com/pykeio/ort/releases/tag/v2.0.0-rc.10.Warning
As per the breaking changes above, and considering that the
ortrelease is just a release candidate and not a stable version, that will most likely not land yet on Text Embeddings Inference (TEI), but still leaving the history in the PR just in case.Before submitting
instasnapshots?Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@Narsil