diff --git a/.github/workflows/check-catalyst.yaml b/.github/workflows/check-catalyst.yaml index 07c2c0120f..de8dd1b64b 100644 --- a/.github/workflows/check-catalyst.yaml +++ b/.github/workflows/check-catalyst.yaml @@ -479,7 +479,7 @@ jobs: echo "OQC_LIB_DIR=$(pwd)/oqc-build" >> $GITHUB_ENV echo "OQD_LIB_DIR=$(pwd)/oqd-build" >> $GITHUB_ENV echo "CATALYST_BIN_DIR=$(pwd)/quantum-build/bin" >> $GITHUB_ENV - chmod +x $(pwd)/quantum-build/bin/catalyst-cli # artifact upload does not preserve permissions + chmod +x $(pwd)/quantum-build/bin/catalyst # artifact upload does not preserve permissions - name: Run Python Lit Tests run: | @@ -559,7 +559,7 @@ jobs: echo "MLIR_LIB_DIR=$(pwd)/llvm-build/lib" >> $GITHUB_ENV echo "OQD_LIB_DIR=$(pwd)/oqd-build" >> $GITHUB_ENV echo "CATALYST_BIN_DIR=$(pwd)/quantum-build/bin" >> $GITHUB_ENV - chmod +x $(pwd)/quantum-build/bin/catalyst-cli # artifact upload does not preserve permissions + chmod +x $(pwd)/quantum-build/bin/catalyst # artifact upload does not preserve permissions - name: Run Python Pytest Tests (backend=lightning.kokkos) run: | @@ -616,7 +616,7 @@ jobs: echo "RUNTIME_LIB_DIR=$(pwd)/runtime-build/lib" >> $GITHUB_ENV echo "MLIR_LIB_DIR=$(pwd)/llvm-build/lib" >> $GITHUB_ENV echo "CATALYST_BIN_DIR=$(pwd)/quantum-build/bin" >> $GITHUB_ENV - chmod +x $(pwd)/quantum-build/bin/catalyst-cli # artifact upload does not preserve permissions + chmod +x $(pwd)/quantum-build/bin/catalyst # artifact upload does not preserve permissions - name: Run Python Pytest Tests run: | diff --git a/.github/workflows/check-pl-compat.yaml b/.github/workflows/check-pl-compat.yaml index 468e1a5994..cfca35c8d5 100644 --- a/.github/workflows/check-pl-compat.yaml +++ b/.github/workflows/check-pl-compat.yaml @@ -161,7 +161,7 @@ jobs: echo "RUNTIME_LIB_DIR=$(pwd)/runtime-build/lib" >> $GITHUB_ENV echo "MLIR_LIB_DIR=$(pwd)/llvm-build/lib" >> $GITHUB_ENV echo "CATALYST_BIN_DIR=$(pwd)/quantum-build/bin" >> $GITHUB_ENV - chmod +x $(pwd)/quantum-build/bin/catalyst-cli # artifact upload does not preserve permissions + chmod +x $(pwd)/quantum-build/bin/catalyst # artifact upload does not preserve permissions - name: Run Frontend Tests run: | diff --git a/Makefile b/Makefile index 5f2d4de540..f49aee89d3 100644 --- a/Makefile +++ b/Makefile @@ -205,7 +205,7 @@ wheel: cp $(COPY_FLAGS) $(DIALECTS_BUILD_DIR)/python_packages/quantum/mlir_quantum/dialects/*$${file}* $(MK_DIR)/frontend/mlir_quantum/dialects ; \ done mkdir -p $(MK_DIR)/frontend/catalyst/bin - cp $(COPY_FLAGS) $(DIALECTS_BUILD_DIR)/bin/catalyst-cli $(MK_DIR)/frontend/catalyst/bin + cp $(COPY_FLAGS) $(DIALECTS_BUILD_DIR)/bin/catalyst $(MK_DIR)/frontend/catalyst/bin find $(MK_DIR)/frontend -type d -name __pycache__ -exec rm -rf {} + $(PYTHON) -m pip wheel --no-deps . -w dist diff --git a/doc/catalyst-cli/catalyst-cli.rst b/doc/catalyst-cli/catalyst-cli.rst index d11fe3aa50..2336af8861 100644 --- a/doc/catalyst-cli/catalyst-cli.rst +++ b/doc/catalyst-cli/catalyst-cli.rst @@ -1,7 +1,7 @@ Catalyst Command Line Interface =============================== -Catalyst includes a standalone command-line-interface compiler tool ``catalyst-cli`` that +Catalyst includes a standalone command-line tool, ``catalyst``, that compiles quantum programs written in our MLIR dialects into an object file, independent of the Catalyst Python frontend. @@ -13,47 +13,47 @@ This compiler tool combines three stages of compilation: `LLVM IR `_. #. ``llc``: Performs lower-level optimizations on the LLVM IR input and creates the object file. -``catalyst-cli`` runs all three stages under the hood by default, but it also has the ability to run -each stage individually. For example: +The ``catalyst`` tool will run all three stages under the hood by default, but it also has the +ability to run each stage individually. For example: .. code-block:: console # Creates both the optimized IR and an object file - catalyst-cli input.mlir -o output.o + catalyst input.mlir -o output.o # Only performs MLIR optimizations and translates to LLVM dialect - catalyst-cli --tool=opt input.mlir -o llvm-dialect.mlir + catalyst --tool=opt input.mlir -o llvm-dialect.mlir # Only lowers LLVM dialect input to LLVM IR - catalyst-cli --tool=translate llvm-dialect.mlir -o llvm-ir.ll + catalyst --tool=translate llvm-dialect.mlir -o llvm-ir.ll # Only performs lower-level optimizations and creates object file (object.o) - catalyst-cli --tool=llc llvm-ir.ll -o output.ll --module-name object + catalyst --tool=llc llvm-ir.ll -o output.ll --module-name object .. note:: - If Catalyst is built from source, the ``catalyst-cli`` executable will be located in + If Catalyst is built from source, the ``catalyst`` executable will be located in the ``mlir/build/bin/`` directory relative to the root of your Catalyst source directory. - If Catalyst is installed via pip or from wheels, the executable will be located - in the ``catalyst/bin/`` directory relative to the environment’s installation directory. + If Catalyst is installed via pip or from wheels, the executable will be located + in the ``catalyst/bin/`` directory relative to the environment's installation directory. Usage ----- .. code-block:: console - catalyst-cli [options] + catalyst [options] -Calling ``catalyst-cli`` without any options runs the three compilation stages (``quantum-opt``, +Calling ``catalyst`` without any options runs the three compilation stages (``quantum-opt``, ``mlir-translate`` and ``llc``) using all default configurations, and outputs by default an object -file named ``catalyst_module.o``. The name of the output file can be set by changing the output +file named ``catalyst_module.o``. The name of the output file can be set by changing the output module name using the ``--module-name`` option (the default module name is ``catalyst_module``). Command line options ^^^^^^^^^^^^^^^^^^^^ -The complete list of options for the Catalyst CLI tool can be displayed by running ``catalyst-cli --help``. +The complete list of options for the Catalyst CLI tool can be displayed by running ``catalyst --help``. As this list contains *all* available options, including those for configuring LLVM, the options most relevant to the usage of the Catalyst CLI tool are covered in more detail below. @@ -111,7 +111,7 @@ name. Currently, the following pipelines are available: ``hlo_lowering-pipeline``, ``quantum-compilation-pipeline``, ``bufferization-pipeline``, -``llvm-dialect-lowring-pipeline``, and finally +``llvm-dialect-lowering-pipeline``, and finally ``default-catalyst-pipeline`` which encompasses all the above as the default pipeline used by the Catalyst CLI tool if no pass option is specified. @@ -138,7 +138,7 @@ applies the pass ``inline-nested-module``, we would specify this pipeline config The workspace directory where intermediate files are saved. The default is the current working directory. -Note that the workspace directory must exist before running ``catalyst-cli`` with this option. +Note that the workspace directory must exist before running ``catalyst`` with this option. ``--module-name=`` """""""""""""""""""""""" @@ -210,7 +210,7 @@ pass that is applied, and the ``-o`` option to set the name of the output IR fil .. code-block:: - catalyst-cli my_circuit.mlir \ + catalyst my_circuit.mlir \ --tool=opt \ --catalyst-pipeline="pipe(remove-chained-self-inverse;merge-rotations)" \ --mlir-print-ir-after-all \ @@ -259,14 +259,14 @@ optimized MLIR. For a list of transformation passes currently available in Catalyst, see the :ref:`catalyst-s-transformation-library` documentation. The available passes are also listed in the -``catalyst-cli --help`` message. +``catalyst --help`` message. MLIR Plugins ------------ ``mlir-opt``-like tools are able to take plugins as inputs. These plugins are shared objects that include dialects and passes written by third parties. -This means that you can write dialects and passes that can be used with ``catalyst-cli`` and ``quantum-opt``. +This means that you can write dialects and passes that can be used with ``catalyst`` and ``quantum-opt``. As an example, the `LLVM repository includes a very simple plugin `_. To build it, simply run ``make plugin`` and the standalone plugin @@ -274,8 +274,8 @@ will be built in the root directory of the Catalyst project. With this, you can now run your own passes by using the following flags: -``catalyst-cli --load-dialect-plugin=$YOUR_PLUGIN --load-pass-plugin=$YOUR_PLUGIN $YOUR_PASS_NAME file.mlir`` +``catalyst --load-dialect-plugin=$YOUR_PLUGIN --load-pass-plugin=$YOUR_PLUGIN $YOUR_PASS_NAME file.mlir`` Concretely for the example plugin, you can use the following command: -``catalyst-cli --tool=opt --load-pass-plugin=standalone/build/lib/StandalonePlugin.so --load-dialect-plugin=standalone/build/lib/StandalonePlugin.so --pass-pipeline='builtin.module(standalone-switch-bar-foo)' a.mlir`` +``catalyst --tool=opt --load-pass-plugin=standalone/build/lib/StandalonePlugin.so --load-dialect-plugin=standalone/build/lib/StandalonePlugin.so --pass-pipeline='builtin.module(standalone-switch-bar-foo)' a.mlir`` diff --git a/doc/dev/plugins.rst b/doc/dev/plugins.rst index efa9b98c46..34473d3929 100644 --- a/doc/dev/plugins.rst +++ b/doc/dev/plugins.rst @@ -1,7 +1,7 @@ MLIR Plugins ============ -This page outlines documentation on how to start developping an MLIR plugin that can work with Catalyst. +This page outlines documentation on how to start developing an MLIR plugin that can work with Catalyst. An MLIR plugin is a shared object that implements a compilation pass compatible with the MLIR framework. Catalyst is built on top of MLIR, this means that MLIR plugins work with Catalyst. This can enable anyone to build quantum compilation passes and new dialects as well. @@ -20,7 +20,7 @@ It is intended to show how one would build an MLIR plugin, rather than showing a You can use the ``StandalonePlugin.so`` plugin -* with either ``quantum-opt`` or ``catalyst-cli``, +* with either ``quantum-opt`` or ``catalyst``, * load it from Python and transform a quantum program. For example, if you are interested in using it from the command line interface, you can use the following flags to load the standalone plugin: @@ -257,7 +257,7 @@ One also needs to link the MLIRQuantum library and change the plugin tool to cat LINK_LIBS MLIRStandalone -Please note that if you are using the Catalyst or Gradient dialects, you should also add MLIRCatalyst and MLIRGradient to the list of dependences and libraries to be linked. +Please note that if you are using the Catalyst or Gradient dialects, you should also add MLIRCatalyst and MLIRGradient to the list of dependencies and libraries to be linked. 4. Modify the standalone plugin to modify quantum operations. @@ -325,7 +325,7 @@ The next step is changing the contents of the function itself: And then we can run ``make all`` again. The shared object of the standalone plugin should be available in ``mlir/build/lib/StandalonePlugin.so``. -This shared object can be used with ``catalyst-cli`` and ``quantum-opt``. +This shared object can be used with both the ``catalyst`` and ``quantum-opt`` tools. From here, you can change the name of the pass, change the name of the shared object, and implement more complex transformations. diff --git a/frontend/catalyst/compiler.py b/frontend/catalyst/compiler.py index 45dc82afb8..bc410545ad 100644 --- a/frontend/catalyst/compiler.py +++ b/frontend/catalyst/compiler.py @@ -267,7 +267,7 @@ def __init__(self, options: Optional[CompileOptions] = None): @debug_logger def get_cli_command(self, tmp_infile_name, output_ir_name, module_name, workspace): - """Prepare the command for catalyst-cli to compile the file. + """Prepare the command to run the Catalyst CLI to compile the file. Args: module_name (str): Module name to use for naming @@ -275,9 +275,9 @@ def get_cli_command(self, tmp_infile_name, output_ir_name, module_name, workspac Returns: cmd (str): The command to be executed. """ - cli_build_path = get_bin_path("cli", "CATALYST_BIN_DIR") + "/catalyst-cli" + cli_build_path = get_bin_path("cli", "CATALYST_BIN_DIR") + "/catalyst" if not path.isfile(cli_build_path): - raise FileNotFoundError("catalyst-cli executable was not found.") # pragma: nocover + raise FileNotFoundError("catalyst executable was not found.") # pragma: nocover cmd = [cli_build_path] cmd += [tmp_infile_name, "-o", output_ir_name] cmd += ["--module-name", module_name, "--workspace", str(workspace)] @@ -356,9 +356,7 @@ def run_from_ir(self, ir: str, module_name: str, workspace: Directory): if result.stderr: print(result.stderr.strip(), file=self.options.logfile) except subprocess.CalledProcessError as e: # pragma: nocover - raise CompileError( - f"catalyst-cli failed with error code {e.returncode}: {e.stderr}" - ) from e + raise CompileError(f"catalyst failed with error code {e.returncode}: {e.stderr}") from e with open(output_ir_name, "r", encoding="utf-8") as f: out_IR = f.read() diff --git a/frontend/catalyst/pipelines.py b/frontend/catalyst/pipelines.py index 4336010600..3678ec5a7f 100644 --- a/frontend/catalyst/pipelines.py +++ b/frontend/catalyst/pipelines.py @@ -18,9 +18,9 @@ .. note:: - for DEFAULT_PIPELINES pipeline and the pipelines in DEFAULT_ASYNC_PIPELINES, + For DEFAULT_PIPELINES pipeline and the pipelines in DEFAULT_ASYNC_PIPELINES, any change should be reflected in the mlir/lib/Driver/Pipelines.cpp files as well. - This is to ensure that the command line tool catalyst-cli default pipelines are + This is to ensure that Catalyst's command line tool default pipelines are in sync with the pipelines defined in the Python frontend. """ diff --git a/frontend/test/lit/test_instrumentation_console.py b/frontend/test/lit/test_instrumentation_console.py index aec33e984d..33d8eb50ae 100644 --- a/frontend/test/lit/test_instrumentation_console.py +++ b/frontend/test/lit/test_instrumentation_console.py @@ -75,7 +75,7 @@ def circuit(weights): # CHECK-NEXT: [DIAGNOSTICS] Running device_release # CHECK-SAME: walltime: {{[0-9\.]+}} ms{{\s*}} cputime: {{[0-9\.]+}} ms # CHECK: [DIAGNOSTICS] > Total run -# COM: As the output below is generated by catalyst-cli, checking the correct order may cause flaky results. +# COM: As the output below is generated by the Catalyst CLI, checking the correct order may cause flaky results. # CHECK: [DIAGNOSTICS] Running parseMLIRSource # CHECK-SAME: walltime: {{[0-9\.]+}} ms{{\s*}} cputime: {{[0-9\.]+}} ms{{\s*}} programsize: {{[0-9]+}} lines # CHECK: [DIAGNOSTICS] Running {{[a-zA-Z]+}}Pass diff --git a/mlir/README.rst b/mlir/README.rst index 5c32b9a94f..f903e9da4f 100644 --- a/mlir/README.rst +++ b/mlir/README.rst @@ -46,9 +46,8 @@ directory structure generally follows the recommended practices from the upstrea - `tools `_: A collection of stand-alone executables built by the project. Currently includes the - ``catalyst-cli`` compiler tool for orchestrating different stages of compilation, - the ``quantum-opt`` tool to run passes on ``.mlir`` files, and - ``quantum-lsp-server``, a language - server for MLIR with support for the quantum and gradient dialect. + ``catalyst`` CLI compiler tool for orchestrating different stages of compilation, + the ``quantum-opt`` tool to run passes on ``.mlir`` files, and ``quantum-lsp-server``, + a language server for MLIR with support for the quantum and gradient dialect. .. mlir-end-inclusion-marker-do-not-remove diff --git a/mlir/lib/Driver/CompilerDriver.cpp b/mlir/lib/Driver/CompilerDriver.cpp index 04078b4703..e52b39f8ba 100644 --- a/mlir/lib/Driver/CompilerDriver.cpp +++ b/mlir/lib/Driver/CompilerDriver.cpp @@ -701,7 +701,7 @@ LogicalResult QuantumDriverMain(const CompilerOptions &options, CompilerOutput & if (runOpt && (inType == InputType::MLIR)) { TimingScope optTiming = timing.nest("Optimization"); // TODO: The enzymeRun flag will not travel correctly in the case where different - // stages of compilation are executed independently via the catalyst-cli executable. + // stages of compilation are executed independently via the Catalyst CLI. // Ideally, It should be added to the IR via an attribute. enzymeRun = containsGradients(*mlirModule); if (failed(runLowering(options, &ctx, *mlirModule, output, optTiming))) { @@ -865,7 +865,7 @@ int QuantumDriverMainFromCL(int argc, char **argv) // --------- // Any modifications made to the command-line interface should be documented in // doc/catalyst-cli/catalyst-cli.rst - cl::OptionCategory CatalystCat("Catalyst-cli Options", ""); + cl::OptionCategory CatalystCat("Catalyst CLI Options", ""); cl::opt WorkspaceDir("workspace", cl::desc("Workspace directory"), cl::init("."), cl::cat(CatalystCat)); cl::opt ModuleName("module-name", cl::desc("Module name"), diff --git a/mlir/patches/test-plugin-with-catalyst.patch b/mlir/patches/test-plugin-with-catalyst.patch index 07652f4e77..fc3c4c2bd3 100644 --- a/mlir/patches/test-plugin-with-catalyst.patch +++ b/mlir/patches/test-plugin-with-catalyst.patch @@ -12,7 +12,7 @@ diff -ruN standalone_unmodified/test/lit.cfg.py standalone/test/lit.cfg.py "standalone-capi-test", "standalone-opt", "standalone-translate", -+ "catalyst-cli", ++ "catalyst", ] llvm_config.add_tool_substitutions(tools, tool_dirs) diff --git a/mlir/test/cli/DumpAfterFailure.mlir b/mlir/test/cli/DumpAfterFailure.mlir index 64863a7f7c..979ae445d7 100644 --- a/mlir/test/cli/DumpAfterFailure.mlir +++ b/mlir/test/cli/DumpAfterFailure.mlir @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// RUN: not catalyst-cli --tool=opt %s --catalyst-pipeline="pipeline(llvm-dialect-lowring-pipeline)" --mlir-print-ir-after-failure --verify-diagnostics 2>&1 | FileCheck %s +// RUN: not catalyst --tool=opt %s --catalyst-pipeline="pipeline(llvm-dialect-lowring-pipeline)" --mlir-print-ir-after-failure --verify-diagnostics 2>&1 | FileCheck %s func.func @foo(%arg0: tensor) { "catalyst.print"(%arg0) : (tensor) -> () diff --git a/mlir/test/cli/DumpBeforeAfterPass.mlir b/mlir/test/cli/DumpBeforeAfterPass.mlir index abb47813df..6d2ae41fb3 100644 --- a/mlir/test/cli/DumpBeforeAfterPass.mlir +++ b/mlir/test/cli/DumpBeforeAfterPass.mlir @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -// RUN: catalyst-cli --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-ir-before-all --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE -// RUN: catalyst-cli --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-ir-after-all --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER -// RUN: catalyst-cli --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-ir-before=inline-nested-module --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE-ONE -// RUN: catalyst-cli --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-ir-after=inline-nested-module --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER-ONE -// RUN: catalyst-cli --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-op-generic --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-GENERIC +// RUN: catalyst --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-ir-before-all --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE +// RUN: catalyst --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-ir-after-all --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER +// RUN: catalyst --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-ir-before=inline-nested-module --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-BEFORE-ONE +// RUN: catalyst --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-ir-after=inline-nested-module --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-AFTER-ONE +// RUN: catalyst --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --mlir-print-op-generic --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-GENERIC func.func @foo() { return diff --git a/mlir/test/cli/DumpPipeline.mlir b/mlir/test/cli/DumpPipeline.mlir index b485e42786..0995df2040 100644 --- a/mlir/test/cli/DumpPipeline.mlir +++ b/mlir/test/cli/DumpPipeline.mlir @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -// RUN: catalyst-cli %s --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s -// RUN: catalyst-cli --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-CUSTOM -// RUN: catalyst-cli --tool=opt %s -cse --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-ONE-PASS -// RUN: not catalyst-cli --tool=opt %s -cse --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL +// RUN: catalyst %s --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s +// RUN: catalyst --tool=opt %s --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-CUSTOM +// RUN: catalyst --tool=opt %s -cse --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-ONE-PASS +// RUN: not catalyst --tool=opt %s -cse --catalyst-pipeline="pipe1(split-multiple-tapes;apply-transform-sequence),pipe2(inline-nested-module)" --dump-catalyst-pipeline --verify-diagnostics 2>&1 | FileCheck %s --check-prefix=CHECK-FAIL func.func @foo() { return diff --git a/mlir/test/cli/DumpTiming.mlir b/mlir/test/cli/DumpTiming.mlir index c84779e626..7fd3f27945 100644 --- a/mlir/test/cli/DumpTiming.mlir +++ b/mlir/test/cli/DumpTiming.mlir @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// RUN: catalyst-cli %s --mlir-timing --verify-diagnostics 2>&1 | FileCheck %s +// RUN: catalyst %s --mlir-timing --verify-diagnostics 2>&1 | FileCheck %s func.func @foo() { return diff --git a/mlir/test/cli/WrongInput.mlir b/mlir/test/cli/WrongInput.mlir index 3069ea0a9c..429e06f325 100644 --- a/mlir/test/cli/WrongInput.mlir +++ b/mlir/test/cli/WrongInput.mlir @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// RUN: not catalyst-cli %s --tool=llc --verify-diagnostics 2>&1 | FileCheck %s -check-prefix=CHECK-LLC -// RUN: not catalyst-cli %s --tool=translate --verify-diagnostics 2>&1 | FileCheck %s -check-prefix=CHECK-TRANSLATE +// RUN: not catalyst %s --tool=llc --verify-diagnostics 2>&1 | FileCheck %s -check-prefix=CHECK-LLC +// RUN: not catalyst %s --tool=translate --verify-diagnostics 2>&1 | FileCheck %s -check-prefix=CHECK-TRANSLATE func.func @foo() { diff --git a/mlir/tools/catalyst-cli/CMakeLists.txt b/mlir/tools/catalyst-cli/CMakeLists.txt index 8af878533b..617f9eff5e 100644 --- a/mlir/tools/catalyst-cli/CMakeLists.txt +++ b/mlir/tools/catalyst-cli/CMakeLists.txt @@ -47,3 +47,4 @@ target_link_libraries(catalyst-cli PRIVATE ${LIBS}) llvm_update_compile_flags(catalyst-cli) mlir_check_all_link_libraries(catalyst-cli) export_executable_symbols_for_plugins(catalyst-cli) +set_target_properties(catalyst-cli PROPERTIES OUTPUT_NAME catalyst) diff --git a/runtime/Makefile b/runtime/Makefile index 37ca5d8cea..6d2b620842 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -48,7 +48,7 @@ configure: -DCMAKE_CXX_COMPILER_LAUNCHER=$(COMPILER_LAUNCHER) \ -DENABLE_OPENQASM=$(ENABLE_OPENQASM) \ -DENABLE_CODE_COVERAGE=$(CODE_COVERAGE) \ - -DPython_EXECUTABLE=$(PYTHON) \ + -DPython_EXECUTABLE=$(PYTHON) \ -DENABLE_ADDRESS_SANITIZER=$(ENABLE_ASAN) .PHONY: runtime diff --git a/setup.py b/setup.py index 704e89029c..2ef75fb9fa 100644 --- a/setup.py +++ b/setup.py @@ -319,6 +319,15 @@ def run(self): # - `ops`: Path to the compiler operations module. # - `qjit`: Path to the JIT compiler decorator provided by the compiler. +# Install the `catalyst` binary into the user's Python environment so it is accessible on the PATH. +# Does not work with editable installs. Requires the Catalyst mlir module to be built. +if os.path.exists("frontend/catalyst/bin/catalyst"): + catalyst_cli = ["frontend/catalyst/bin/catalyst"] +elif os.path.exists("mlir/build/bin/catalyst"): + catalyst_cli = ["mlir/build/bin/catalyst"] +else: + catalyst_cli = [] + setup( classifiers=classifiers, name="PennyLane-Catalyst", @@ -338,6 +347,9 @@ def run(self): ), package_dir={"": "frontend"}, include_package_data=True, + data_files=[ + ("bin", catalyst_cli), + ], ext_modules=ext_modules, cmdclass=cmdclass, **description,