Skip to content

Remove onnxruntime-easy dependency, inline its code - #32

Open
xadupre with Copilot wants to merge 6 commits into
mainfrom
copilot/remove-onnxruntime-easy-dependency
Open

Remove onnxruntime-easy dependency, inline its code#32
xadupre with Copilot wants to merge 6 commits into
mainfrom
copilot/remove-onnxruntime-easy-dependency

Conversation

Copilot AI commented Mar 24, 2026

Copy link
Copy Markdown
Contributor
  • Inline relevant code from onnxruntime-easy into src/mobius/_testing/ort_inference.py
  • Remove onnxruntime-easy from pyproject.toml testing dependencies, add onnxruntime and ml_dtypes instead
  • Use onnx.TensorProto constants instead of hardcoded ONNX element type integers
  • Run tests to verify nothing is broken (514 tests pass)
Original prompt

This section details on the original issue you should resolve

<issue_title>remove dependency on onnxruntime-easy, import the code if necessary</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI changed the title [WIP] Remove dependency on onnxruntime-easy and import code if necessary Remove onnxruntime-easy dependency, inline its code Mar 24, 2026
Copilot AI requested a review from xadupre March 24, 2026 16:51
Comment thread src/mobius/_testing/ort_inference.py Outdated
Comment thread src/mobius/_testing/ort_inference.py Outdated
Comment thread src/mobius/_testing/ort_inference.py Outdated
Comment thread src/mobius/_testing/ort_inference.py Outdated
…nditional

Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Agent-Logs-Url: https://github.com/onnxruntime/mobius/sessions/feb5cf18-6cf6-432e-8ef5-ac0224beb18a

Copilot AI commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • huggingface.co
    • Triggering command: /usr/bin/python /usr/bin/python -u -c import sys;exec(eval(sys.stdin.readline())) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-actions

github-actions Bot commented Mar 24, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Model Sub-model Changes Status

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@github-actions

github-actions Bot commented Mar 24, 2026

Copy link
Copy Markdown

Performance Comparison

Model Metric Baseline Current Delta
falcon model_size_bytes 364 KB 364 KB +0.0%
falcon num_nodes 66 66 +0.0%
gemma2 model_size_bytes 428 KB 428 KB +0.0%
gemma2 num_nodes 109 107 -1.8%
gpt2 model_size_bytes 388 KB 388 KB +0.0%
gpt2 num_nodes 60 60 +0.0%
llama model_size_bytes 425 KB 425 KB +0.0%
llama num_nodes 68 68 +0.0%
llama (static-cache-text-generation) model_size_bytes 425 KB 425 KB +0.0%
llama (static-cache-text-generation) num_nodes 58 58 +0.0%
phi3 model_size_bytes 421 KB 421 KB +0.0%
phi3 num_nodes 68 68 +0.0%
phi3 (static-cache-text-generation) model_size_bytes 421 KB 421 KB +0.0%
phi3 (static-cache-text-generation) num_nodes 58 58 +0.0%
qwen2 model_size_bytes 425 KB 425 KB +0.0%
qwen2 num_nodes 68 68 +0.0%
qwen2 (static-cache-text-generation) model_size_bytes 425 KB 425 KB +0.0%
qwen2 (static-cache-text-generation) num_nodes 58 58 +0.0%

No performance regressions.

@xadupre
xadupre marked this pull request as ready for review March 25, 2026 10:05
@xadupre
xadupre requested review from a team and Copilot March 25, 2026 10:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the onnxruntime-easy test dependency by inlining equivalent ORT session/dtype handling logic into the repo’s internal testing utilities, simplifying the dependency graph while keeping ONNX Runtime inference available for tests/examples.

Changes:

  • Replaced onnxruntime-easy usage with a direct onnxruntime.InferenceSession wrapper and OrtValue conversion utilities.
  • Added onnxruntime and ml_dtypes to the testing optional dependencies and removed onnxruntime-easy.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/mobius/_testing/ort_inference.py Inlines ORT session creation + OrtValue conversion to replace onnxruntime-easy.
pyproject.toml Updates testing extras to depend on onnxruntime + ml_dtypes instead of onnxruntime-easy.

Comment thread src/mobius/_testing/ort_inference.py
Comment on lines +22 to +38
def _to_ort_value(value: np.ndarray, device: str = "cpu") -> ort.OrtValue:
"""Convert a numpy array to an OrtValue, handling special ml_dtypes dtypes."""
# Use DLPack when available (e.g. torch tensors or non-zero-size arrays)
if hasattr(value, "__dlpack__"):
is_zero_size = hasattr(value, "size") and value.size == 0
if not is_zero_size:
return ort.OrtValue(_ort_c.OrtValue.from_dlpack(value.__dlpack__(), False), value)
if isinstance(value, np.ndarray):
try:
onnx_type = ir.DataType.from_numpy(value.dtype)
except TypeError:
pass
else:
return ort.OrtValue.ortvalue_from_numpy_with_onnx_type(
value, onnx_element_type=onnx_type.value
)
return ort.OrtValue.ortvalue_from_numpy(np.asarray(value), device)

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_to_ort_value(..., device=...) only uses device in the final fallback path; the DLPack and ortvalue_from_numpy_with_onnx_type branches ignore it. Either remove the parameter to avoid a misleading API, or ensure the chosen OrtValue creation path respects the requested device (especially if this is intended to support CUDA inputs).

Copilot uses AI. Check for mistakes.
@justinchuby

Copy link
Copy Markdown
Member

We need to run the tests locally because the CIs are currently broken. Otherwise lgtm.

@justinchuby

Copy link
Copy Markdown
Member

Is this ready?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove dependency on onnxruntime-easy, import the code if necessary

5 participants