Add support for position_ids
and past_key_values
in OrtBackend
#700
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
ort
inputs are being handled to extend support for optional values such asposition_ids
orpast_key_values
.e.g.
onnx-community/Qwen3-Embedding-0.6B-ONNX
has been now enabled on Text Embeddings Inference (TEI) viaort
thanks to the conditional addition of thepast_key_values
if 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 inmain
it 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
ort
to the latest release candidate whilst v2.0.0 is released, with the following breaking changes:ort::session::Session
is now mutable, so placed in aMutex
try_extract_tensor
is nowtry_extract_array
ort::inputs!
won't accept thendarray
, but rather anort::value
e.g.
ort::value::Tensor
Additionally, it requires to pin
ort-sys
and add thestd
feature 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
ort
release 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
insta
snapshots?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