Skip to content

Upgrade ONNX runtime, ONNX Gen AI runtime, add a new model to test changes#1075

Closed
ammbra wants to merge 3 commits into
openjdk:code-reflectionfrom
ammbra:update-onnx-examples
Closed

Upgrade ONNX runtime, ONNX Gen AI runtime, add a new model to test changes#1075
ammbra wants to merge 3 commits into
openjdk:code-reflectionfrom
ammbra:update-onnx-examples

Conversation

@ammbra

@ammbra ammbra commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

I apologize for such a big PR, but most of its changes are result of regeneration for native bindings, operators, prototufs etc. So, this PR contains many changes that relate to upgrading the ONNX runtime library (1.26.0) and its native GenAI (0.14.0) counterpart:

  • The changes from oracle.code.onnx.foreign are generated via the cr-examples/onnx/opgen/setup.sh script and its helper symbols files to generate only the absolute necessary contents.
  • The operators and protobufs have been generated via their respective Java generators.
  • OnnxProtoBuilder needed to support also shapes because I kept getting this native error once rebuilding Babylon:
:bomb: Program crashed: Bad pointer dereference at 0x0000000000000008

Thread 37 "Java: oracle.code.onnx.llm.LlamaDemo.main()" crashed:

 0 0x000000012aa83f8c Generators::Model::IsPruned() const + 60 in libonnxruntime-genai.dylib
 1 0x000000012aa76cf4 Generators::Logits::Logits(Generators::State&) + 268 in libonnxruntime-genai.dylib
 2 0x000000012aa41848 Generators::DecoderOnly_State::DecoderOnly_State(Generators::DecoderOnly_Model const&, Generators::DeviceSpan<int>, Generators::GeneratorParams const&) + 88 in libonnxruntime-genai.dylib
 3 0x000000012aa4178c Generators::DecoderOnly_Model::CreateState(Generators::DeviceSpan<int>, Generators::GeneratorParams const&) const + 104 in libonnxruntime-genai.dylib
 4 0x000000012aa36e90 Generators::Generator::Generator(Generators::Model const&, Generators::GeneratorParams const&) + 432 in libonnxruntime-genai.dylib
 5 0x000000012aa36c90 Generators::CreateGenerator(Generators::Model const&, Generators::GeneratorParams const&) + 52 in libonnxruntime-genai.dylib
 6 0x000000012aade410 OgaCreateGenerator + 28 in libonnxruntime-genai.dylib
 7 0x000000013f6a2b00
 8 0x000000013f53cbc8
 9 0x000000013f53cbc8
10 0x000000013f53cbc8
11 0x000000013f53ca70
12 0x000000013f53ca70
13 0x000000013807e010
14 0x00007fffffffffff

I managed to identify that the exported model was the source for such an error (both local debug and by also comparing in Netron). To my understanding, Generators::Model::IsPruned() const method checks if the underlying model has been compressed using model pruning. Pruning seems to reduce model size and latency by zeroing out or permanently removing unnecessary weights and parameters, but I think in this case the generated model was aggressively pruned from the beginning of traversing the graph, thus resulting in the error above. The aggressive pruning was performed due the lack of shapes being there. This error occurred only for LLMs, the rest of the ML models being unaffected.

  • I also adjusted the license headers and cleaned a few leftovers in variable or patterns not really used by the library.
  • I updated the LlamaDemo to be more interactive.
  • To test my changes beyond the existing demo, I created a new one. The AllMiniLML6V2EmbeddingModel is inspired by https://huggingface.co/onnx-community/all-MiniLM-L6-v2-ONNX and by running the OnnxLift over its default (model.onnx). As a result, I could obtain a quite good model to start. Then I cleaned it locally based on how the official config.json looked like. The BertTokenizer is just a helper for working with the tokenizer and its constants are from tokenizer_config.json and config.json , while the EmbeddingDemo is just a Java version of the code from the landing page of the model.
babylon

Progress

  • Change must not contain extraneous whitespace

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/babylon.git pull/1075/head:pull/1075
$ git checkout pull/1075

Update a local copy of the PR:
$ git checkout pull/1075
$ git pull https://git.openjdk.org/babylon.git pull/1075/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1075

View PR using the GUI difftool:
$ git pr show -t 1075

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/babylon/pull/1075.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jun 29, 2026

Copy link
Copy Markdown

👋 Welcome back amihalceanu! A progress list of the required criteria for merging this PR into code-reflection will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jun 29, 2026

Copy link
Copy Markdown

@ammbra This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

Upgrade ONNX runtime, ONNX Gen AI runtime, add a new model to test changes

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 6 new commits pushed to the code-reflection branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk Bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 29, 2026
@mlbridge

mlbridge Bot commented Jun 29, 2026

Copy link
Copy Markdown

@openjdk openjdk Bot added ready Pull request is ready to be integrated rfr Pull request is ready for review and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 30, 2026
Reviewed-by: psandoz

Upgrade ONNX runtime, ONNX Gen AI runtime, add a new model to test changes.

Signed-off-by: Ana-Maria Mihalceanu <amihalceanu@openjdk.org>
@ammbra ammbra force-pushed the update-onnx-examples branch from 32241be to 3b8650d Compare June 30, 2026 21:46
@openjdk

openjdk Bot commented Jun 30, 2026

Copy link
Copy Markdown

@ammbra Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

ammbra added 2 commits June 30, 2026 23:47
Signed-off-by: Ana-Maria Mihalceanu <ana-maria.m.mihalceanu@oracle.com>
Signed-off-by: Ana-Maria Mihalceanu <ana-maria.m.mihalceanu@oracle.com>
@ammbra

ammbra commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing this one due to git history mess, development was reloaded in #1085

@ammbra ammbra closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants