Repository navigation
[Draft] Add internal MatMulNBits core operation-count estimator - #33467
Draft
Tommaso Adani (tadani3) wants to merge 14 commits into
Draft
Tommaso Adani (tadani3) wants to merge 14 commits into
Tommaso Adani (tadani3) wants to merge 14 commits into
Conversation
…components and counting categories
Forward the actual workload collector through eight GPT beam/greedy and T5/Whisper calls. Preserve the T5 encoder/decoder MatMulNBits regression sequences while covering collector propagation. Validation: CPU Debug builds successful; 25 collector tests passed with 1 LUT skipped; 26 search regression tests passed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds an internal, metadata-only estimator for the core dense-equivalent operation
count of
com.microsoft::MatMulNBits(schema version 1).This is an initial foundation for contrib-op compute estimation, not a complete
user-facing FLOP-reporting feature.
The implementation:
2 × M × N × K, whereMis the product of the input's leadingdimensions and multiply-add counts as two operations.
unsupported operators/versions, or overflow.
The count covers only the logical matrix-multiplication core. It excludes bias,
dequantization, packing, conversions, padding, and route-specific extra work.
For this quantized operator, the result is dense-equivalent operations, not
a count of actual floating-point instructions executed.
Out of scope: graph-wide reporting, runtime instrumentation, public APIs,
execution timing, FLOP/s, and changes to dispatch, placement, or allocation.
Validation
CPU Debug build passed:
cmake --build build\Windows\FlopEstimate --config Debug --target onnxruntime_provider_test --parallel 2From the build output directory, the following passed 25 tests:
.\onnxruntime_provider_test.exe --gtest_filter="MatMulNBitsComputeEstimate*:MatMulNBits.Float32_4b_Accuracy0:MatMulNBits.Float32_4b_Accuracy4_Batch:MatMulNBits.LegacyShape_4b"The 8 pure estimator tests also passed in a standalone build with
ORT_MINIMAL_BUILDandORT_NO_EXCEPTIONSenabled.Lint checks passed for the new sources;
git diff --checkpassed.CUDA validation was not run; the estimator has no CUDA dependency.
Motivation and Context
Establish a small, testable counting contract before adding model-wide reports
or measured throughput. This gives later reporting work a shared formula and
explicit handling of unavailable estimates, without changing inference behavior.
The design draws on the separation of metadata adapters and estimation arithmetic
used by the memory-estimation work tracked in #29775. Compute counts remain
independent of memory accounting and budget enforcement; this PR does not
implement or close that roadmap.
Draft review feedback requested: