Skip to content

onnx: say when a session fails for a missing integer-op kernel in the pinned ORT, and which exports are next to it - #1437

Merged
bong-water-water-bong merged 2 commits into
mainfrom
fix/1436-onnx-int-ops
Nov 8, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
fix/1436-onnx-int-ops

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #1436

The acceptance, met

A row that ships an ONNX-native int8 export either runs, or says in one line that the pinned runtime has no kernel for it and which export of the repo does run. No silent "does not load".

ort-run on the issue's own file now prints:

$ ort_run --model Xenova/yolov8n-pose/onnx/model_int8.onnx --input images=in.bin:float32:1x3x640x640
onebit-ort-run: FAIL create session: Could not find an implementation for ConvInteger(10) node with name '/model.0/conv/Conv_quant'
onebit-ort-run: the pinned ONNX Runtime has no CPU kernel for ConvInteger at this graph's input types: a runtime coverage gap, not a model or EP failure
onebit-ort-run:   ConvInteger runs only uint8 x uint8; DynamicQuantizeLinear feeds uint8, so an int8-weight export cannot load
onebit-ort-run:   other exports in .../onnx: model.onnx (a float or QDQ export uses no integer ops)
rc=1

$ ort_run --model Xenova/yolov8n-pose/onnx/model.onnx --input images=in.bin:float32:1x3x640x640 --dump-all out
  run     : 65.98 ms, 1 output(s)
  out     : output0 float32 1881600 Bx1x56x8400
rc=0

The files match the issue's byte counts: 3,755,740 B (sha256 1eb23649...) and 13,484,153 B (sha256 04f6d241...). Both were fetched for measurement only; this PR does not include them.

Option 2 answered: what the pin carries

The issue asked whether 1.23.2 has ConvInteger for int8 at all, or only uint8. One-node graphs through ort-run against the pinned libonnxruntime.so.1.23.2 (activation x weight):

op u8 x u8 u8 x i8 i8 x u8 i8 x i8
ConvInteger runs no kernel no kernel no kernel
MatMulInteger runs runs no kernel runs

The export's 73 ConvInteger nodes all have INT8 weights, read from the initializers. DynamicQuantizeLinear always outputs uint8, so u8 x i8 is the combination it needs, and the pin has no kernel for it. Building ORT with that kernel would change the pin (docs/onnx.md "The pin"), so I left it out.

Change

  • onnx/ort_run.cpp (+41):
    • after a failed CreateSession whose message is "Could not find an implementation for (N)", say that the runtime's kernel coverage is the cause;
    • for ConvInteger / MatMulInteger, give the measured kernel rows;
    • list the other .onnx files in the model's directory.
    • Any other missing op gets the first line only. The FAIL create session line itself is unchanged.
  • docs/onnx.md: a new "Integer-op exports" section with the two-flavour table, the kernel table, the YOLOv8-pose example and the refusal text.
  • onnx/tests/ort_run_generic.sh, row 6:
    • a u8 x i8 ConvInteger graph is refused with the three lines, including the sibling list;
    • the u8 x u8 graph runs and equals a numpy convolution.

Proof (strixhalo, CPU, ONEBIT_ORT=ON build of ort_run, under thermal-run)

ort_run_generic.sh, binary from origin/main:
FAIL the refusal says it is the runtime's kernel coverage
FAIL and what the pin does carry
FAIL and the other exports next to it
ort_run_generic: 1 failure(s)            (rc 1)

ort_run_generic.sh, this branch:   17 ok, ort_run_generic: 0 failure(s)
ctest -R ort_run_generic:          100% tests passed, 0 tests failed out of 1
tools/copyright.py --check:        exit 0

Not in this PR

  • The board rows (GPNPU-PARITY.md, ONNX-VISION-OOB.md) already record both exports separately, per the issue.
  • No ORT rebuild (see above).
  • No EP change: ConvInteger is a convolution, and the EP's seam is MatMul.

🤖 Generated with Claude Code

… pinned ORT, and which exports are next to it (#1436)

A public int8 ONNX export (Hugging Face Optimum / Xenova model_int8.onnx) uses ONNX's own integer ops,
not Q/DQ, and the pinned ONNX Runtime 1.23.2 has no CPU kernel for most of their type combinations.
Measured with one-node graphs (activation x weight):

  ConvInteger    u8 x u8 runs; u8 x i8, i8 x u8, i8 x i8 no kernel
  MatMulInteger  u8 x u8, u8 x i8, i8 x i8 run; i8 x u8 no kernel

DynamicQuantizeLinear always gives uint8 and these exports carry int8 weights (Xenova/yolov8n-pose: all
73 ConvInteger weights INT8), so the session cannot be created, and the board read that as "model fails".

ort_run now adds, after "Could not find an implementation for <Op>(N)": that it is the runtime's kernel
coverage (not the model or an EP), what the pin carries for ConvInteger / MatMulInteger, and the other
.onnx files in the model's directory. docs/onnx.md gets the two-flavour and kernel tables.

onnx/tests/ort_run_generic.sh rows 6: u8 x i8 ConvInteger refused with those lines; u8 x u8 runs and
equals a numpy convolution.
  main:   3 FAIL (the explanation lines)       branch: 17 ok, 0 failures; ctest -R ort_run_generic passed

Real model: model_int8.onnx refused with the new lines, naming model.onnx; model.onnx runs, 65.98 ms.

Fixes #1436

Co-authored-by: bong-water-water-bong <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at f52c38b

Comment thread onnx/ort_run.cpp Resolved

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY at f52c38bc6a8ed86bedd7288dd1f56c887a1194d9

This meets #1436's acceptance as written ("runs, or says in one line that the pinned runtime has no kernel for it and which export does run"), and the kernel table answers the issue's option 2 with measurements rather than a guess.

At this head (base 880c9ae, on main; my -DONEBIT_ORT=ON build against libonnxruntime 1.23.2, thermal-run.sh):

  • ort_run, ort_info and the onebit_ep* targets build clean, with no warning in ort_run.cpp;
  • ctest in onnx/ passes 7/7, including ort_run_generic with its new row 6;
  • tools/copyright.py --check is rc 0.

The code:

  • explain_missing_kernel adds lines only after a failed CreateSession, and only when ORT's own "Could not find an implementation for " is in the message. The FAIL create session line is unchanged.
  • The op name is cut at (, so ConvInteger(10) → ConvInteger.
  • The sibling scan is the model's own directory, .onnx only, with the failing file excluded and the list sorted.

One wording nit, not blocking: the sibling line ends "(a float or QDQ export uses no integer ops)". Placed right after the list, it reads as a statement about the listed files. In the Xenova layout this example comes from, a model directory typically also holds model_uint8.onnx and model_quantized.onnx (integer ops; the uint8 one would actually load) and model_q4.onnx or model_bnb4.onnx. Either soften it to "(try a float or QDQ one: those use no integer ops)", or, cheaply and more useful, list a sibling first if its name contains fp32, fp16, or no quant suffix at all.

I didn't refetch the yolov8n-pose files; the two runs and their hashes are yours.

…w nit on #1437) (#1436)

The parenthetical read as a claim about the listed files; a Xenova directory also holds
model_uint8.onnx / model_quantized.onnx, which use integer ops.

Co-authored-by: bong-water-water-bong <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Took the wording nit: ac61ee808c7b33c65b93e16f9865ff4d57d718b4 rewords the sibling line as "other exports in

: (not checked; a float or QDQ one uses no integer ops)", in ort_run.cpp and in the docs/onnx.md example. A Xenova directory also holds model_uint8.onnx / model_quantized.onnx, so the old text read as a claim about the listed files. Re-run at this head: ort_run_generic.sh 0 failures (row 6's grep matches the list, not the parenthetical), real model_int8.onnx prints the new line, copyright exit 0. The three -Wunused-result warnings in ort_run.cpp that a default build shows are pre-existing (main's lines 649/688/701, shifted by +41), not this PR's.

ready for review at ac61ee8

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1436 - Partially compliant

Compliant requirements:

  • A row that ships an ONNX-native int8 export either runs, or says in one line that the pinned runtime has no kernel for it and which export of the repo does run. No silent "does not load".
  • The solution explains the runtime coverage gap, not a model or EP failure.
  • The solution lists other exports in the same directory to guide the user.

Non-compliant requirements:

  • The pinned ONNX Runtime (1.23.2) has no CPU kernel for ConvInteger at int8 x int8 input types.

Requires further human verification:

  • Verification that the runtime coverage information is accurate and matches the actual ORT 1.23.2 capabilities.
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Kernel Coverage Clarity

The new explain_missing_kernel function attempts to improve error messaging when a session fails due to missing integer-op kernels. However, it parses the error message string directly, which could be brittle if ONNX changes its error message format. This approach relies on string matching and may not be robust against future changes in the ORT library's error reporting.

void explain_missing_kernel(const char* msg, const char* model_path) {
    static const char kNeedle[] = "Could not find an implementation for ";
    const char* at = msg ? std::strstr(msg, kNeedle) : nullptr;
    if (!at) return;
    std::string op(at + sizeof kNeedle - 1);
    op = op.substr(0, op.find('('));
    std::fprintf(stderr, "onebit-ort-run: the pinned ONNX Runtime has no CPU kernel for %s at this graph's input types: "
                         "a runtime coverage gap, not a model or EP failure\n", op.c_str());
    if (op == "ConvInteger")
        std::fprintf(stderr, "onebit-ort-run:   ConvInteger runs only uint8 x uint8; DynamicQuantizeLinear feeds uint8, "
                             "so an int8-weight export cannot load\n");
    else if (op == "MatMulInteger")
        std::fprintf(stderr, "onebit-ort-run:   MatMulInteger runs uint8 x uint8, uint8 x int8 and int8 x int8, not int8 x uint8\n");
    std::string dir(model_path), self(model_path);
    const size_t slash = dir.rfind('/');
    dir = slash == std::string::npos ? "." : dir.substr(0, slash);
    self = slash == std::string::npos ? self : self.substr(slash + 1);
    std::vector<std::string> other;
    if (DIR* d = opendir(dir.c_str())) {
        while (const dirent* e = readdir(d)) {
            const std::string n = e->d_name;
            if (n != self && n.size() > 5 && n.compare(n.size() - 5, 5, ".onnx") == 0) other.push_back(n);
        }
        closedir(d);
    }
    std::sort(other.begin(), other.end());
    if (!other.empty()) {
        std::string list;
        for (const auto& n : other) list += (list.empty() ? "" : ", ") + n;
        std::fprintf(stderr, "onebit-ort-run:   other exports in %s: %s (not checked; a float or QDQ one uses no integer ops)\n",
                     dir.c_str(), list.c_str());
    }
}
Directory Traversal Security

The code uses opendir and readdir to list files in the directory containing the model. While functional, this approach does not sanitize or validate the directory path, potentially leading to security vulnerabilities if the model path is untrusted or contains symbolic links that could lead to unexpected file access.

if (DIR* d = opendir(dir.c_str())) {
    while (const dirent* e = readdir(d)) {
        const std::string n = e->d_name;
        if (n != self && n.size() > 5 && n.compare(n.size() - 5, 5, ".onnx") == 0) other.push_back(n);
    }
    closedir(d);
}

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY at ac61ee808c7b33c65b93e16f9865ff4d57d718b4

ac61ee8 takes my nit exactly: the sibling line now reads "… (not checked; a float or QDQ one uses no integer ops)" in ort_run.cpp, and docs/onnx.md says the files are listed "without checking them". It's a one-string change, and the doc's sample output matches it.

At this head ort_run rebuilds clean in my -DONEBIT_ORT=ON tree, and ctest -R ort_run_generic passes 1/1 (the test matches on the refusal's other lines, so the parenthetical change can't break it). Everything else is as I reviewed it READY at f52c38bc.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

What fails on ac61ee80, and why it isn't this PR. My READY stands; the three red checks need a re-run, not a code change.

check what failed cause
build (ci run 42468438033) ctest: 123/124 pass; hybrid_route fails with FAIL: hybrid_route: could not bind a port 45419 (Address already in use) A port collision in the test. tests/hybrid_route.sh:39 picks a port with bind(("127.0.0.1", 0)), closes the socket, then starts serve on it, so another process can take the port in between. The test's own message (:56-58) classifies this as "a port collision, not a defect in what this test checks".
Analyze (actions) Initialize CodeQL: Unable to download and extract CodeQL CLI: Unexpected HTTP response: 504 GitHub's CodeQL bundle download timed out.
CodeQL "1 configuration not found … /language:actions" A consequence of the row above: the actions analysis never ran, so its configuration is missing.

Why this isn't the PR's code:

  • the previous head f52c38bc passed ci (run 42464625395), and the only change since is one string in onnx/ort_run.cpp. No serve or hybrid code moved;
  • main's ci is green at this PR's base 880c9aea (run 42451500353) and at every main commit since 04:15Z;
  • hybrid_route exercises app/ serve routing, which this PR doesn't touch.

To do: re-run the failed jobs (gh run rerun 42468438033 --failed, and re-run the CodeQL analysis). If hybrid_route collides again, that's worth its own issue: the test's port choice is a check-then-use race, and having serve bind to port 0 and report the port it got would remove it. It doesn't belong in this PR.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Re-ran the failed build job at ac61ee80: pass (run 42468438033, attempt 2), no code change, so the hybrid_route failure was the port race. Filed as #1444, which I am fixing separately (test-only). The CodeQL Analyze (actions) run is GitHub default setup, which refuses a re-run ("cannot be rerun"); its failure was the CLI bundle download timing out (HTTP 504), and every language analysis that ran passed.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing my duplicate rather than letting two fixes race — I opened #1442 for #1436 before noticing this one existed (yours is 08:50Z, mine ~10:40Z). Yours is better than mine on the point that matters: it measured which dtype combinations the pin carries for ConvInteger/MatMulInteger (my hint only asserted the format story), it lists the sibling exports in the same directory, and its ctest also runs the uint8×uint8 graph against a numpy reference rather than only asserting the refusal. So #1437 is the fix; #1442 is closed.

Two small things from mine that you may or may not want, offered rather than pushed:

  1. A pure-function unit test that needs no ORT session or model. onnx: a session that cannot start says why in one line, and quantized ONNX is named as two formats (Fixes #1436) #1442 factored the message parsing into is_missing_kernel_message() / missing_kernel_op() / session_failure_hint(), with a ctest that feeds it ORT's text directly — so the hint's own behaviour (op extraction, version interpolation, and crucially the negative cases) is testable in 0.01 s without a session. Your ort_run_generic covers the end-to-end refusal and the running case, which is stronger on the graph side; this would cover "a hint that fires on the wrong failure", which is the failure mode I was most worried about.
  2. A guard against mislabelling. My hint only claims "ONNX-native int8" for the five integer ops (ConvInteger, MatMulInteger, QLinearConv, QLinearMatMul, DynamicQuantizeLinear) and gives any other missing kernel a route out without the format paragraph — tested with GridSample and with three non-kernel failures (invalid graph, missing file, empty message).

If either is worth having, I am happy to send it as a small follow-up on top of #1437 after it merges — I'd rather that than a second PR against the same file now.

One factual point worth keeping from mine, since our two messages disagree in wording: I reproduced the failure with a 139-byte synthetic graph (one ConvInteger node, opset 17, int8 x/w, int32 y) on the pinned runtime, which is what makes "the runtime has no kernel" a property of the pin rather than of Xenova/yolov8n-pose — no download and no AGPL model involved. If that reproduction is not already in your notes, it is a cheap way for anyone to re-check the claim.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Resolved the one open review thread (CodeQL "Suspicious add with sizeof" at onnx/ort_run.cpp:69) as a false positive, with the reasoning in the thread: kNeedle is a char[], so sizeof kNeedle - 1 is its byte length and the offset is correct; the runtime output and test row 6 confirm the parsed op name. No code change, so head stays ac61ee80.

@bong-water-water-bong
bong-water-water-bong merged commit 9e97d0b into main Nov 8, 2026
7 of 10 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the fix/1436-onnx-int-ops branch November 8, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onnx: a public ONNX-native int8 export cannot even create a session (no ConvInteger kernel in the pinned ORT)

2 participants