Skip to content

PennyLaneAI/jeff-mlir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An MLIR dialect for the jeff exchange format

This repository is contains an MLIR dialect for the jeff exchange format. The purpose is to facilitate conversion to and from jeff for MLIR-based quantum compilers, and reuse certain components like the jeff serialization & deserialization.

Right now, the project only contains the dialect definitions, (de)serialization is missing. Conversion rules to and from standard MLIR dialects could also be added.

Build instructions

The dialect sources can be incorporated directly into an existing project (in-tree), or built separately (out-of-tree). At the moment, the CMake script supports building the dialect as a standalone project which generates a custom opt tool.

To do so, make sure you have an existing MLIR build.

If you don't ...

You can get pre-built binaries from the munich-quantum-software/portable-mlir-toolchain project via the installers from munich-quantum-software/setup-mlir:

On Linux and macOS, use the following Bash command:

curl -LsSf https://github.com/munich-quantum-software/setup-mlir/releases/latest/download/setup-mlir.sh | bash -s -- -v 21.1.8 -p /path/to/installation

On Windows, use the following PowerShell command:

powershell -ExecutionPolicy ByPass -c "& ([scriptblock]::Create((irm https://github.com/munich-quantum-software/setup-mlir/releases/latest/download/setup-mlir.ps1))) -llvm_version 21.1.8 -install_prefix /path/to/installation"

Replace /path/to/installation with the path to your preferred installation directory. Then, set MLIR_DIR to /path/to/installation/lib/cmake/mlir in your CMake configuration step. The project hosts a variety of pre-built binaries for different platforms and LLVM versions. Check out the project page for more details.

Alternatively, you can build MLIR from source following the instructions in the MLIR documentation, which are summarized below. First, clone the repository:

git clone https://github.com/llvm/llvm-project.git external/llvm-project

Then, build and run the MLIR test suite:

cd external/llvm-project
cmake -B build -S . -G Ninja            \
      -DCMAKE_BUILD_TYPE=Release        \
      -DLLVM_ENABLE_PROJECTS="mlir"     \
      -DLLVM_BUILD_EXAMPLES=OFF         \
      -DLLVM_ENABLE_ASSERTIONS=ON       \
      -DMLIR_ENABLE_BINDINGS_PYTHON=OFF
cmake --build build --target check-mlir

Finally, you can point the MLIR_DIR variable to external/llvm-project/build/lib/cmake/mlir in your CMake configuration step.


From here, we can build the jeff dialect simply via:

cmake -Bbuild -S. -GNinja && cmake --build build

If CMake can't find the MLIR build, it can be specified via -DMLIR_DIR=... during the config step, which must point to the cmake files in the build or installation directory, for example /path/to/installation/lib/cmake/mlir.

The jeff-opt tool will be located in the build directory under ./build/lib/opt/jeff-opt.

TODO: Add instructions for setting up the dialect as an MLIR plugin.

License

This jeff dialect is free and open source, released under the Apache License, Version 2.0.

About

An MLIR dialect for the *jeff* exchange format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •