michaelfeil / michaelfeil/infinity

Pass parameter "providers=['CUAExecutionProvider','TensorrtExecutionProvider'] " to "optimum" Engine

Open
#639 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
206
PR merge metrics
No merged PRs in 30d

Description

### Feature request

```
# Define sentences for embedding
sentences = ["Embed this sentence via Infinity.", "Paris is in France."]
# Initialize the embedding engine with model specifications
array = AsyncEngineArray.from_args([
**EngineArgs(
model_name_or_path=r"./models/bce-embedding-base_v1",
served_model_name="bce-embedding-base_v1",
lengths_via_tokenize=True,
engine=InferenceEngine("optimum")
)**]
)

async def embed_image(engine: AsyncEmbeddingEngine):
await engine.astart() # initializes the engine
job1 = asyncio.create_task(engine.embed(sentences=sentences))
# submit a second job in parallel
job2 = asyncio.create_task(engine.embed(sentences=["Hello world"]))
# usage is total token count according to tokenizer.
embeddings, usage = await job1
embeddings2, usage2 = await job2
# Embeddings are now available for use - they ran in the same batch.
print(f"for {sentences}, generated embeddings {len(embeddings)} with tot_tokens={usage}")
await engine.astop()

asyncio.run(
embed_image(array["bce-embedding-base_v1"])
)
```
`*************** EP Error ***************
EP Error D:\a\_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:505 onnxruntime::python::RegisterTensorRTPluginsAsCustomOps Please install TensorRT libraries as mentioned in the GPU requirements page, make sure they're in the PATH or LD_LIBRARY_PATH, and that your GPU is supported.
when using ['TensorrtExecutionProvider']
Falling back to ['CPUExecutionProvider'] and retrying.
****************************************`

If onnx failed to use TensorrtExecutionProvider,it will fall back to CPUExecutionProvider,cause slower inference.So we need a param in AsyncEmbeddingEngine to pass parameter "providers=['CUAExecutionProvider','TensorrtExecutionProvider'] " to "optimum" Engine to use only GPU.

### Motivation

to prevent optimum from using CPUExecutionProvider.

### Your contribution

no

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at AsyncEmbeddingEngine and the InferenceEngine("optimum") configuration shown in the issue, then trace how execution providers are passed to the underlying engine. Done means the requested provider list can be supplied and CPUExecutionProvider is not used as a fallback; add or run the relevant embedding-engine tests if present.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.