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

.Net: Bug: Crash in OnnxRuntimeGenAIChatCompletionService #9709

Open
lilhoser opened this issue Nov 14, 2024 · 1 comment
Open

.Net: Bug: Crash in OnnxRuntimeGenAIChatCompletionService #9709

lilhoser opened this issue Nov 14, 2024 · 1 comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code triage

Comments

@lilhoser
Copy link

Describe the bug
Application crashes with "bad allocation" nebulous message when iterating over vector search results:

var searchResult = await collection.VectorizedSearchAsync(searchVector, searchOptions);
await foreach (var item in searchResult.Results)
{
    return item.Record.Description;
}
return string.Empty;

Call stack:

   at Microsoft.ML.OnnxRuntimeGenAI.Result.VerifySuccess(IntPtr nativeResult)
   at Microsoft.ML.OnnxRuntimeGenAI.Generator..ctor(Model model, GeneratorParams generatorParams)
   at Microsoft.SemanticKernel.Connectors.Onnx.OnnxRuntimeGenAIChatCompletionService.<RunInferenceAsync>d__13.MoveNext() in /home/vsts/work/1/s/semantic-kernel/dotnet/src/Connectors/Connectors.Onnx/OnnxRuntimeGenAIChatCompletionService.cs:line 99
   at Microsoft.SemanticKernel.Connectors.Onnx.OnnxRuntimeGenAIChatCompletionService.<RunInferenceAsync>d__13.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.SemanticKernel.Connectors.Onnx.OnnxRuntimeGenAIChatCompletionService.<GetStreamingChatMessageContentsAsync>d__12.MoveNext() in /home/vsts/work/1/s/semantic-kernel/dotnet/src/Connectors/Connectors.Onnx/OnnxRuntimeGenAIChatCompletionService.cs:line 82
   at Microsoft.SemanticKernel.Connectors.Onnx.OnnxRuntimeGenAIChatCompletionService.<GetStreamingChatMessageContentsAsync>d__12.MoveNext() in /home/vsts/work/1/s/semantic-kernel/dotnet/src/Connectors/Connectors.Onnx/OnnxRuntimeGenAIChatCompletionService.cs:line 82
   at Microsoft.SemanticKernel.Connectors.Onnx.OnnxRuntimeGenAIChatCompletionService.<GetStreamingChatMessageContentsAsync>d__12.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.SemanticKernel.KernelFunctionFromPrompt.<InvokeStreamingCoreAsync>d__7`1.MoveNext() in /home/vsts/work/1/s/semantic-kernel/dotnet/src/SemanticKernel.Core/Functions/KernelFunctionFromPrompt.cs:line 304
   at Microsoft.SemanticKernel.KernelFunctionFromPrompt.<InvokeStreamingCoreAsync>d__7`1.MoveNext() in /home/vsts/work/1/s/semantic-kernel/dotnet/src/SemanticKernel.Core/Functions/KernelFunctionFromPrompt.cs:line 304
   at Microsoft.SemanticKernel.KernelFunctionFromPrompt.<InvokeStreamingCoreAsync>d__7`1.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.SemanticKernel.KernelFunction.<InvokeStreamingAsync>d__30`1.MoveNext() in /home/vsts/work/1/s/semantic-kernel/dotnet/src/SemanticKernel.Abstractions/Functions/KernelFunction.cs:line 418
   at Microsoft.SemanticKernel.KernelFunction.<InvokeStreamingAsync>d__30`1.MoveNext() in /home/vsts/work/1/s/semantic-kernel/dotnet/src/SemanticKernel.Abstractions/Functions/KernelFunction.cs:line 430
   at Microsoft.SemanticKernel.KernelFunction.<InvokeStreamingAsync>d__30`1.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)

Image

Repro steps might be a little complicated because the data set is large.

@lilhoser lilhoser added the bug Something isn't working label Nov 14, 2024
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Nov 14, 2024
@github-actions github-actions bot changed the title Bug: Crash in OnnxRuntimeGenAIChatCompletionService .Net: Bug: Crash in OnnxRuntimeGenAIChatCompletionService Nov 14, 2024
@f2bo
Copy link

f2bo commented Nov 14, 2024

I don't know if your issue is the same, but my experience of the "bad allocation" error message with ONNX is when failing to specify MaxTokens in the OnnxRuntimeGenAIPromptExecutionSettings. If the model you are using supports a large context length, (e.g. 128K), it will attempt to allocate too much memory and fail.

I reported the issue about the "nebulous message" in the ONNX runtime genai repo (microsoft/onnxruntime-genai#980). There's a PR in progress that makes the message slightly less obscure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code triage
Projects
None yet
Development

No branches or pull requests

3 participants