From 04c079fead28410203e185f5d37c513d0a1d23a3 Mon Sep 17 00:00:00 2001 From: River McCubbin Date: Wed, 24 Jun 2026 16:13:50 -0400 Subject: [PATCH 1/5] improve mlir & mlir_opt property documentation --- frontend/catalyst/jit.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/frontend/catalyst/jit.py b/frontend/catalyst/jit.py index 8d137a8268..3e4900a548 100644 --- a/frontend/catalyst/jit.py +++ b/frontend/catalyst/jit.py @@ -614,8 +614,13 @@ def _get_effective_capture_mode(self): return capture_option @property - def mlir(self): - """Obtain the MLIR representation after canonicalization""" + def mlir(self) -> str | None: + """The canonicalized MLIR representation of the QJIT object after lowering, if available. + + Returns: + str: The textual MLIR module for the QJIT object. + None: If compilation has not yet occurred. + """ # Canonicalize the MLIR since there can be a lot of redundancy coming from JAX. if not self.mlir_module: return None @@ -626,8 +631,13 @@ def mlir(self): return canonicalize(stdin=stdin, options=self.compile_options) @property - def mlir_opt(self): - """Obtain the MLIR representation after optimization""" + def mlir_opt(self) -> str | None: + """The MLIR representation of the QJIT object after optimization, if available. + + Returns: + str: The textual MLIR module after applying user passes and the default pipeline. + None: If compilation has not yet occurred. + """ if not self.mlir_module: return None using_python_compiler = self.compiler.is_using_python_compiler(self.mlir_module) From 2d016f1be99120e5346b72713986afa3aceb44df Mon Sep 17 00:00:00 2001 From: River McCubbin Date: Thu, 25 Jun 2026 09:33:42 -0400 Subject: [PATCH 2/5] changelog --- doc/releases/changelog-dev.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index c990c2ad88..3a8092f9b5 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -351,6 +351,8 @@ * A broken link was removed in the [Compiler Core](https://docs.pennylane.ai/projects/catalyst/en/stable/modules/mlir.html) documentation page. The link referred to where precompiled decomposition rules were implemented, which has since been refactored. [(#2913)](https://github.com/PennyLaneAI/catalyst/pull/2913) +* The documentation for `QJIT.mlir` and `QJIT.mlir_opt` was updated with type hints and docstrings that better reflect the compilation-dependent nature of the properties. +

Contributors ✍️

This release contains contributions from (in alphabetical order): From e2962579d633aa215654a04090b317cdb669796c Mon Sep 17 00:00:00 2001 From: River McCubbin Date: Fri, 26 Jun 2026 09:29:14 -0400 Subject: [PATCH 3/5] Update doc/releases/changelog-dev.md Co-authored-by: Isaac De Vlugt <34751083+isaacdevlugt@users.noreply.github.com> --- doc/releases/changelog-dev.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 3a8092f9b5..a2d5ef050c 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -352,6 +352,7 @@ [(#2913)](https://github.com/PennyLaneAI/catalyst/pull/2913) * The documentation for `QJIT.mlir` and `QJIT.mlir_opt` was updated with type hints and docstrings that better reflect the compilation-dependent nature of the properties. + [(#2975)](https://github.com/PennyLaneAI/catalyst/pull/2975)

Contributors ✍️

From f14502167bf6e1077e74494b31c3d1345e9aaae4 Mon Sep 17 00:00:00 2001 From: River McCubbin Date: Mon, 29 Jun 2026 09:44:16 -0400 Subject: [PATCH 4/5] clarify --- frontend/catalyst/jit.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/catalyst/jit.py b/frontend/catalyst/jit.py index 3e4900a548..feb1adcfee 100644 --- a/frontend/catalyst/jit.py +++ b/frontend/catalyst/jit.py @@ -617,9 +617,12 @@ def _get_effective_capture_mode(self): def mlir(self) -> str | None: """The canonicalized MLIR representation of the QJIT object after lowering, if available. + The MLIR for a program can only be generated once `capture` and `generate_ir` have been run, + typically via AOT or JIT compilation. + Returns: str: The textual MLIR module for the QJIT object. - None: If compilation has not yet occurred. + None: If the MLIR has not yet been generated for the program. """ # Canonicalize the MLIR since there can be a lot of redundancy coming from JAX. if not self.mlir_module: @@ -634,9 +637,12 @@ def mlir(self) -> str | None: def mlir_opt(self) -> str | None: """The MLIR representation of the QJIT object after optimization, if available. + The optimized MLIR for a program can only be generated once `capture` and `generate_ir` have + been run, typically via AOT or JIT compilation. + Returns: - str: The textual MLIR module after applying user passes and the default pipeline. - None: If compilation has not yet occurred. + str: The textual MLIR module after applying the QJIT object's pipelines. + None: If optimized MLIR has not yet been generated for the program. """ if not self.mlir_module: return None From a98893b3357d0e79433362b84b49c6709b8a3f2b Mon Sep 17 00:00:00 2001 From: River McCubbin Date: Mon, 29 Jun 2026 12:02:06 -0400 Subject: [PATCH 5/5] update mlir_opt --- frontend/catalyst/jit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/catalyst/jit.py b/frontend/catalyst/jit.py index feb1adcfee..f64544fd4c 100644 --- a/frontend/catalyst/jit.py +++ b/frontend/catalyst/jit.py @@ -642,7 +642,7 @@ def mlir_opt(self) -> str | None: Returns: str: The textual MLIR module after applying the QJIT object's pipelines. - None: If optimized MLIR has not yet been generated for the program. + None: If MLIR has not yet been generated for the program. """ if not self.mlir_module: return None