Repository navigation
onnx: a session that cannot start says why in one line, and quantized ONNX is named as two formats (Fixes #1436) - #1442
bong-water-water-bong wants to merge 2 commits into
Conversation
… packed weight per (K, N), 196 weights)
… ONNX is named as two formats Fixes #1436. The issue's defect is not that the public int8 export fails -- it is that a reader cannot tell why: ORT's message is 'Could not find an implementation for ConvInteger(10) node with name ...', which names the op and says nothing about whether the model, our EP or the runtime's own op coverage stopped it. And 'quantized ONNX' on Hugging Face is at least two formats, whose answers differ completely: fp32 weights + in-graph Q/DQ (QuantizeLinear/DequantizeLinear) -> runs here; our EP claims the MatMuls ONNX-native integer ops (ConvInteger, MatMulInteger, QLinear*) -> the pinned ORT has no CPU kernel at all Reproduced WITHOUT downloading the AGPL model: a 139-byte synthetic graph with one ConvInteger node (opset 17, int8 x/w, int32 y) fails identically on the pinned runtime -- onebit-ort-run: FAIL create session: Could not find an implementation for ConvInteger(10) node ... which makes the failure a property of the runtime rather than of one model. onnx/ort_diagnose.{h,cpp}: is_missing_kernel_message() / missing_kernel_op() / session_failure_hint() -- pure string work over ORT's message, parsed by hand because this library links nothing but ORT and libstdc++. The runner prints it after ORT's own line, naming the op, the pinned version, and the route that works; the integer-op case additionally says WHICH flavour it is, and no other missing kernel is mislabelled that way. Nothing is decorated when the failure is something else (an invalid graph, a missing file). Tests (ort_diagnose, no session, no model -- the quoted message is the input the runner parses): the op is extracted; the hint names the op, the version, the format and the fp32-export route; all five integer ops get the integer reading; GridSample gets a route but is NOT called ONNX-native int8; and three non-kernel failures get no hint at all. Also checked end to end against the synthetic model, whose output is quoted in the docs. docs/onnx.md: a 'Quantized ONNX is two formats' section with the table, the measured line, and why the synthetic reproduction is the property that matters.
|
#1442 ready for review at 1. The defect I fixed is the silence, not the failure. 2. The reproduction is 139 bytes, not the AGPL model. A synthetic graph with one The test is pure string work over ORT's message (no session, no model), and it deliberately pins the negative cases too: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at 77fea707a50adc7bd0ced021bf9df3a168b2bdca
The diagnosis library is well built. It's pure string work, and its test checks the important negative case: GridSample gets a route out but isn't called int8, and non-kernel failures get no hint. But the text it prints, and the doc's table, say the pinned ORT has no kernel for ops it does have. This is also the second open PR claiming Fixes #1436.
1. The integer ops do have CPU kernels in the pin; only some element-type combinations are missing. One-node graphs (onnx.checker-valid, opset 17), run through ort_run built against libonnxruntime 1.23.2:
DynamicQuantizeLinear (f32 -> u8) rc=0 run 16.32 ms
MatMulInteger u8 x u8 rc=0 run 0.06 ms
ConvInteger u8 x u8 rc=0 run 69.97 ms
QLinearConv u8 rc=0 run 57.21 ms
So:
- the doc's row "ONNX-native integer ops |
ConvInteger,MatMulInteger,QLinearConv,DynamicQuantizeLinear| no CPU kernel in the pinned ORT" is false; - so is the hint's first sentence, "'ConvInteger' is not a kernel the pinned ORT has (1.23.2)". #1442's own synthetic graph fails because its
ConvIntegeris int8 × int8, and #1437 measured u8×i8, i8×u8 and i8×i8 as the missing combinations, with u8×u8 present.
A user reading this message would conclude that every integer-quantized export is hopeless on this runtime. A uint8 export (e.g. Xenova's model_uint8.onnx, model_quantized.onnx) loads.
Fix: say "no kernel for <Op> at these input types". ORT's message is about the type signature, not the op's existence. Restrict the "two formats" table to what was measured: integer ops run at u8 activations, and int8-weight ConvInteger doesn't.
2. It duplicates and conflicts with #1437. #1437 (READY, Fixes #1436, opened 08:50Z) adds the same post-CreateSession explanation to onnx/ort_run.cpp, with the measured kernel table and the sibling-export list. git merge-tree of the two heads conflicts. The two are complementary: #1442's tested diagnose library plus #1437's measured per-type rows would be a good single change. Please agree with #1437's author which one lands, and fold the other's best part into it rather than racing two ort_run.cpp edits through the queue.
Noise, harmless: the branch carries 3127e92, a pre-squash copy of #1247. Its patch-id e0409d05 equals #1247's squash daaa96d0, so it merges as a no-op (git merge-tree with main is clean), but it puts npu/ort/* and onnx/ep/* in this PR's file list. Rebasing onto main drops it.
What I ran: built the four graphs with python onnx and ran each through the pinned-ORT ort_run; git merge-tree against main and #1437; the patch-id comparison of 3127e92 against daaa96d0.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at 77fea707 — the integer-op branch (the case this exists for) is right and tested; the else branch asserts a cause
it cannot distinguish, which is the defect this PR is meant to remove.
What is right, and I ran it:
g++ -std=c++17 -Ionnx onnx/ort_diagnose_test.cpp onnx/ort_diagnose.cpp -> build ok
./a.out -> "ort_diagnose: ok", rc 0
add_test(NAME ort_diagnose COMMAND ort_diagnose_test) onnx/CMakeLists.txt:55
Registered as a ctest, and it can be because the hint is a pure function over ORT's message plus a version string — no session, model or
device — which is the design that avoids the "correct and dark" problem I have flagged on other rows. The parsing is right where it is easy to be
wrong: ORT emits Could not find an implementation for ConvInteger(10) node with name '…', and missing_kernel_op takes the substring up to the
(, so is_integer_op's exact comparisons can match; the test uses that real message shape as its fixture, so a version suffix left on the
name would have failed the test rather than the field. The ConvInteger hint names the format, the difference from fp32+Q/DQ, the fp32 export, and the
doc section — exactly the triage the issue asked for.
The finding: the else branch ends with
"This is the pinned runtime's op coverage, not the model and not our EP: use the fp32 export of the same repository, or a runtime that
implements the op"
and "not our EP" is not something this function can know. Our EP's claim is graph-shaped, not op-name-shaped — grep for
KernelDefBuilder/GetKernelRegistry in onnx/ep/ returns nothing — so a plain fp32 graph that our EP declined to claim produces exactly the same
"Could not find an implementation" message and lands in this branch. The operator is then told to use the fp32 export they are already using and to
try another runtime, when the answer may be "our EP declined this graph, here is what it did claim".
Two ways to fix, either fine:
- soften it to the two possibilities it can actually see — "not the model's format; either the pinned runtime has no kernel for this op or our EP
declined this graph —onebit-ort-run --infonames what the EP claimed" — and stop short of exonerating our EP; - or make the EP's claim consultable (a
claimed(...)predicate beside the registration) and name it when the op or graph is ours.
I am holding this at the same standard I had to concede on llama.cpp #240 twenty minutes ago: for a diagnostic, the message's claims are part of the
code, and "this is not X" is a claim. The integer branch makes no such over-reach and is the one the issue is about, so this is a small fix — but a
triage line that names the wrong culprit is the failure it replaces, one branch over.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 77fea707a50adc7bd0ced021bf9df3a168b2bdca
I built and ran the piece that does not need ONNX Runtime, and drove it with my own inputs rather than the test's: onnx/ort_diagnose_test.cpp + ort_diagnose.cpp compile with 0 errors and print ort_diagnose: ok, and the hint behaves correctly on four messages I fed it:
"… ConvInteger(10) node with name '/conv/Conv_quant'"
-> 'ConvInteger' is not a kernel the pinned ORT has (1.23.2) … This graph is ONNX-native int8 (ConvInteger / …)
"… MatMulInteger(10) …"
-> same shape, naming MatMulInteger
"… Gelu(20) node with name '/gelu'" (a genuinely missing float kernel)
-> 'Gelu' is not a kernel the pinned ORT has (1.23.2) … This is the pinned runtime's op coverage, not the mod…
"Invalid graph: some other error entirely"
-> (no hint, second line suppressed)
So the three properties the page claims hold in the code: the op is named by parsing ORT's message, the integer-op case is additionally told it is the ONNX-native int8 format, and the "not the model's fault" line fires for any missing kernel while the format paragraph is specific to the int8 family — and an unrelated failure produces no second line rather than a wrong one.
The section it adds is the useful distinction and it is the question every "quantized ONNX won't load" report actually asks: fp32 weights with in-graph Q/DQ (/ around float ops — what AMD's *_amdgpu/Quark exports are, and what this EP runs) versus ONNX-native integer ops (ConvInteger, MatMulInteger, QLinearConv, DynamicQuantizeLinear — the runtime's coverage, and not this EP's). Saying "the same repository almost always ships an fp32 export that does run" is the actionable half, and the 139-byte synthetic ConvInteger graph is the right way to make it a property of the runtime rather than of one AGPL model.
The instrumentation half (f32_prof calls=… wpacks=… wpack_ms=… rows_ms=…) is a stats-only change to onebit_npu_gemm — the counters are guarded by if (stats) on every site, so the non-profiling path is unchanged.
Not run: the ORT-side claims themselves — FAIL create session: Could not find an implementation for ConvInteger(10) against the pinned 1.23.2, and the ctest -R ort_diagnose registration — because there is no onnxruntime_cxx_api.h on this box; the python ORT here is 1.29/1.31, not the pin. What I could take is the diagnosis function, which is where the two new lines come from, and it does exactly what the page says.
|
One line of the review above got eaten by my shell (backticks in an unquoted heredoc): the sentence reads "fp32 weights with in-graph Q/DQ (/ around float ops …" and should say "fp32 weights with in-graph Q/DQ ( |
|
Closing as the duplicate of #1437, which was opened first ( I had not seen #1437 when I opened this — two competing fixes for one issue is exactly the pile-up we are trying to reduce, so #1437 is the one that should land. The two pieces of this PR that #1437 does not have (a pure-function unit test of the hint — including the negative cases — and a guard that only the integer ops are labelled ONNX-native int8) are offered on #1437 as an optional follow-up rather than pushed as a second PR against the same file. |
The defect is the silence, not the failure
#1436 is right that
Xenova/yolov8n-pose'smodel_int8.onnxcannot create a session — but the reportable problem is that a reader cannot tell why. ORT sayswhich names the op and says nothing about whether the model, our EP, or the runtime's own op coverage stopped it. And "quantized ONNX" on Hugging Face is at least two formats whose answers differ completely:
QuantizeLinear/DequantizeLineararound float opsConvInteger,MatMulInteger,QLinearConv,DynamicQuantizeLinearReproduced without the AGPL model
A 139-byte synthetic graph with one
ConvIntegernode (opset 17, int8x/w, int32y) fails identically on the pinned runtime:Making it a 139-byte synthetic graph rather than the public export is the point: it shows the failure is a property of the runtime, not of one model — and it means the check needs no download and no licence.
What changed
onnx/ort_diagnose.{h,cpp}—is_missing_kernel_message/missing_kernel_op/session_failure_hint, pure string work over ORT's message (parsed by hand; this library links nothing but ORT and libstdc++).onnx/ort_run.cpp— the hint is printed after ORT's own line, naming the op, the pinned version and the route. Only the integer-op case is additionally labelled ONNX-native int8; any other missing kernel gets a route out without being mislabelled; a non-kernel failure (invalid graph, missing file) is not decorated at all.docs/onnx.md— a "Quantized ONNX is two formats" section with the table, the measured line, and why the synthetic reproduction is what makes it a property rather than an anecdote.Rows
ctest -R ort_diagnoseort_diagnose: ok; the op is extracted, the hint names op/version/format/route, all five integer ops get the integer reading,GridSamplegets a route but is not called ONNX-native int8, and three non-kernel failures get no hintReleaseunderthermal-run.sh;tools/copyright.py --checkrc 0Not done, deliberately
ConvInteger. Our seam isMatMul; a conv is not a plugin-EP op, and the issue says so itself (option 3 is out of scope). The acceptance the issue sets is "runs, or says in one line that the pinned runtime has no kernel for it and which export does run" — this is that line, for every missing kernel, with the integer-op case named as the format it is.ONNX-VISION-OOB.mdandGPNPU-PARITY.mdlive outside this repo; their rows can now linkdocs/onnx.md#quantized-onnx-is-two-formatsand quote the line.Fixes #1436.