Skip to content

improve mlir & mlir_opt property documentation#2975

Open
kipawaa wants to merge 5 commits into
mainfrom
qjit-mlir-docs
Open

improve mlir & mlir_opt property documentation#2975
kipawaa wants to merge 5 commits into
mainfrom
qjit-mlir-docs

Conversation

@kipawaa

@kipawaa kipawaa commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Context:
The QJIT.mlir property is relatively poorly documented. The return type is unclear and unspecified, and the docstring provides little clarification.

Description of the Change:
Adds type hints and updates docstring.

Benefits:
clearer mlir and mlir_opt properties.

Possible Drawbacks:

Related GitHub Issues:

[sc-123089]

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.97%. Comparing base (b65dd49) to head (a98893b).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2975   +/-   ##
=======================================
  Coverage   96.97%   96.97%           
=======================================
  Files         166      166           
  Lines       19209    19209           
  Branches     1788     1788           
=======================================
  Hits        18628    18628           
  Misses        429      429           
  Partials      152      152           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@isaacdevlugt isaacdevlugt 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.

Just needs a changelog entry :heh:

Otherwise, nice 🚀

@kipawaa kipawaa requested a review from isaacdevlugt June 25, 2026 13:33

@isaacdevlugt isaacdevlugt 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.

🚀

Comment thread doc/releases/changelog-dev.md
Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com>
Comment thread frontend/catalyst/jit.py Outdated

Returns:
str: The textual MLIR module after applying user passes and the default pipeline.
None: If compilation has not yet occurred.

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.

This statement is a bit tricky. Technically, accessing this property triggers the "compilation" (at least compilation in the MLIR / core Catalyst compiler sense), but what needed to have happened before is that the capture and generate_ir stages of the QJIT object needed to have been run, whether via AOT compilation, JIT compilation, or some other way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! It's kind of difficult to convey all of that concisely, what about something like None: If MLIR cannot be generated for the circuit. and we can explain further in the core of the docstring?

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.

Yeah that makes sense! Maybe a slight modification, since the MLIR having been generated is the criteria, and our programs are more general than circuits:
None: If the MLIR has not yet been generated for this program

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How does f145021 sound?

@dime10 dime10 Jun 29, 2026

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.

If optimized MLIR has not yet been generated for the program.

The condition for both properties is the same actually, because they take the jax-generated mlir (.mlir_module) as input to produce their output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess I was trying to get at the required success of running the requested pipeline to generate .mlir_opt, whereas .mlir_module is sufficient for .mlir.

@dime10 dime10 Jun 29, 2026

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.

If there is a failure in the pipeline an error should be raised. The None result is produced precisely when the input IR isn't available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, added in a98893b

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.

3 participants