Standardize Resource Analysis JSON Format - #3076
Open
sengthai wants to merge 33 commits into
Open
Conversation
sengthai
marked this pull request as ready for review
July 28, 2026 21:19
jzaia18
reviewed
Aug 3, 2026
jzaia18
reviewed
Aug 3, 2026
jzaia18
reviewed
Aug 3, 2026
jzaia18
reviewed
Aug 3, 2026
jzaia18
reviewed
Aug 3, 2026
Comment on lines
+181
to
+185
| // try to insert nQubits first, if not then create empty json object. | ||
| auto [it, _] = | ||
| quantumOperationObject.try_emplace(std::to_string(nQubits), llvm::json::Object{}); | ||
| (*it->getSecond().getAsObject())[opName] = countToJson(count); | ||
| } |
Contributor
There was a problem hiding this comment.
Instead of overwriting, it might be safer to sum. Right now if we somehow have 2 operators with the same name and number of wires but different number of args they will not be counted correctly. Unsure if we actually support varadic ops, but we should account for this case anyway to be safe in case we need to support them in the future
Contributor
Author
There was a problem hiding this comment.
Make sense, now i sum instead of overwrite them.
catalyst/mlir/lib/Catalyst/Analysis/ResourceResult.cpp
Lines 175 to 192 in eae737d
sengthai
force-pushed
the
ex-re/resource-extension
branch
from
August 3, 2026 20:59
9504a69 to
c05bef1
Compare
sengthai
force-pushed
the
ex-re/reshape-json
branch
from
August 3, 2026 20:59
42948ae to
ca4cebc
Compare
sengthai
force-pushed
the
ex-re/reshape-json
branch
from
August 4, 2026 21:30
eae737d to
13a8b0c
Compare
jzaia18
reviewed
Aug 5, 2026
sengthai
commented
Aug 5, 2026
Contributor
Author
There was a problem hiding this comment.
reminder: revert this before merge.
jzaia18
approved these changes
Aug 5, 2026
Co-authored-by: David Ittah <dime10@users.noreply.github.com>
Co-authored-by: Hong-Sheng Zheng <mathan0203@gmail.com>
This reverts commit f11271a.
Co-authored-by: Jake Zaia <23638795+jzaia18@users.noreply.github.com>
Co-authored-by: Jake Zaia <23638795+jzaia18@users.noreply.github.com>
Co-authored-by: Jake Zaia <23638795+jzaia18@users.noreply.github.com>
sengthai
force-pushed
the
ex-re/reshape-json
branch
from
August 5, 2026 20:49
cb5434a to
bd6fae7
Compare
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.
Context:
Currently, the resource analysis pass emits a JSON result when run with
output-json=true, which is then consumed by the PL frontend and shown back to the user. This JSON output has grown organically: flat top-level keys, gate name encoded strings, separatefunction_calls(static) /var_function_calls(dynamic) fields, and PBC depth attached in the pass. This makes the format harder to parse and extend.This PR standardizes the JSON schema in line with this ADR. Moreover, PBC depth is now contributed via the
ResourceExtensionframework instead of being populated separately in the pass.Description of the Change:
PBCDepthAnalysisand register it viaResourceExtensionRegistryBefore → After (example):
[sc-124298]