Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ac23d69
Update LLVM and MLIR-HLO
erick-xanadu Apr 16, 2025
16bc357
Update TopologicalSortUtils.h's location.
erick-xanadu Apr 16, 2025
d81e8d2
Use operator==(StringRef, StringRef)
tzunghanjuang Aug 16, 2024
3b70b9f
Comment out deprecated bufferization pipelines
erick-xanadu Apr 16, 2025
c037c72
Add disableVerification to translateModuleToLLVMIR
tzunghanjuang Apr 16, 2025
c30269c
Comment out retired bufferization passes
tzunghanjuang Apr 16, 2025
c40c02f
Temporarily disable finalizing-bufferization for debugging
tzunghanjuang Aug 20, 2024
10ec118
Remove all passes and use one-shot-bufferize only
tzunghanjuang Aug 20, 2024
84da76b
Add new buffer passes except for the deallocation pipeline
tzunghanjuang Aug 21, 2024
0e1b5fe
Temporarily set side effect of InitOp and FinalizeOp as zero
tzunghanjuang Aug 21, 2024
8d49feb
Draft Quantum Impl of BufferizableOpInterface
tzunghanjuang Aug 21, 2024
0e70f99
Add empty one-shot-bufferize for quantum::ExtractOp
tzunghanjuang Aug 21, 2024
8283274
unused variable
erick-xanadu Apr 22, 2025
ec95417
revert llvm/mhlo version to current;
paul0403 Apr 28, 2025
65642ba
.dep_versions EOF new line
paul0403 Apr 28, 2025
823e23f
revert TopologicalSortUtils.h location
paul0403 Apr 28, 2025
a0de280
restore llvm and mhlo version: source files
paul0403 Apr 28, 2025
26e6e24
restore another topological sort location
paul0403 Apr 28, 2025
7005ed9
restore `disableVerification` in CompilerDriver.cpp
paul0403 Apr 28, 2025
a5a99d1
add buffer interface for quantum.set_state op
paul0403 Apr 28, 2025
fee74cd
add buffer_play.mlir playground for exhibition
paul0403 Apr 28, 2025
c006d6a
add bufferization for set_basis_state
paul0403 Apr 28, 2025
cf08821
do stateop
paul0403 Apr 28, 2025
108f5be
probs op
paul0403 Apr 28, 2025
93b25d3
sample op
paul0403 Apr 28, 2025
a61a151
counts op
paul0403 Apr 28, 2025
1ad56d9
remove buffer_play playground
paul0403 Apr 28, 2025
c00cc8c
quantum bufferization lit test uses --one-shot-bufferize
paul0403 Apr 28, 2025
9c2638d
restore pipelines
paul0403 Apr 28, 2025
ab6b525
Merge remote-tracking branch 'origin/main' into eochoa/2025-04-16/upd…
paul0403 Apr 28, 2025
29d2dd8
register quantum dialect bufferization interface for the main catalys…
paul0403 Apr 28, 2025
bfdac15
revert `NoMemoryEffect` in quantum.init/finalize
paul0403 Apr 28, 2025
77d4544
change quantum-bufferize in py pipeline to one-shot bufferize with fi…
paul0403 Apr 28, 2025
b963ed7
qubit unitary op
paul0403 Apr 29, 2025
1f5662b
license
paul0403 Apr 29, 2025
5015f76
hermitian op
paul0403 Apr 29, 2025
f14b450
hamiltonian op
paul0403 Apr 29, 2025
064ca44
I accidentally ran clang-format on test.mlir
paul0403 Apr 29, 2025
ebf6b10
format
paul0403 Apr 29, 2025
7524f35
remove old quantum bufferization pass
paul0403 Apr 29, 2025
89bdc03
add one shot quantum bufferize to cpp pipeline
paul0403 Apr 29, 2025
d45d859
changelog
paul0403 Apr 29, 2025
5e13151
remove BufferizationPatterns.cpp from cmakelists
paul0403 Apr 30, 2025
974122c
Merge branch 'main' into eochoa/2025-04-16/updating-to0jaxv0.4.29.0
erick-xanadu Apr 30, 2025
05e9a83
Merge remote-tracking branch 'origin/eochoa/2025-04-16/updating-to0ja…
paul0403 May 1, 2025
ddde955
remove extra comments
paul0403 May 1, 2025
6ddcb80
add Tzunghan's origin PR to changelog
paul0403 May 1, 2025
9e38dc0
Merge remote-tracking branch 'origin/main' into eochoa/2025-04-16/upd…
paul0403 May 1, 2025
78d1b4c
Update mlir/lib/Quantum/Transforms/BufferizableOpInterfaceImpl.cpp
paul0403 May 1, 2025
6c9e70e
format
paul0403 May 1, 2025
6154409
Turn on bufferizesToAllocation for sample, counts, probs and state.
paul0403 May 1, 2025
4fc788b
Merge remote-tracking branch 'origin/main' into eochoa/2025-04-16/upd…
paul0403 May 1, 2025
cdea054
changelog line too long
paul0403 May 1, 2025
3f2fa2d
remove quantum_bufferize.cpp from cmakelists
paul0403 May 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
* The utility function `EnsureFunctionDeclaration` is refactored into the `Utils` of the `Catalyst` dialect, instead of being duplicated in each individual dialect.
[(#1683)](https://github.com/PennyLaneAI/catalyst/pull/1683)

* The bufferization of custom catalyst dialects has been migrated to the new one-shot bufferization interface in mlir. The new mlir bufferization interface is required by jax 0.4.29 or higher.
[(#1686)](https://github.com/PennyLaneAI/catalyst/pull/1686)

<h3>Documentation 📝</h3>

<h3>Contributors ✍️</h3>
Expand All @@ -80,6 +83,7 @@ This release contains contributions from (in alphabetical order):
Joey Carter,
Sengthai Heng,
David Ittah,
Tzung-Han Juang,
Christina Lee,
Erick Ochoa Lopez,
Paul Haochen Wang.
2 changes: 1 addition & 1 deletion frontend/catalyst/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def get_bufferization_stage(_options: CompileOptions) -> List[str]:
"catalyst-bufferize", # Must be run before -- func.func(linalg-bufferize)
"func.func(linalg-bufferize)",
"func.func(tensor-bufferize)",
"quantum-bufferize",
"one-shot-bufferize{dialect-filter=quantum}",
"func-bufferize",
"func.func(finalizing-bufferize)",
"canonicalize", # Remove dead memrefToTensorOp's
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/Quantum/IR/QuantumOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ def NamedObservableAttr : EnumAttr<QuantumDialect, NamedObservable, "named_obser

class Quantum_Op<string mnemonic, list<Trait> traits = []> : Op<QuantumDialect, mnemonic, traits>;

def InitializeOp : Quantum_Op<"init"> {
def InitializeOp : Quantum_Op<"init"> { //, [NoMemoryEffect]> {
let summary = "Initialize the quantum runtime.";

let assemblyFormat = [{
attr-dict
}];
}

def FinalizeOp : Quantum_Op<"finalize"> {
def FinalizeOp : Quantum_Op<"finalize"> { //, [NoMemoryEffect]> {
let summary = "Teardown the quantum runtime.";

let assemblyFormat = [{
Expand Down
27 changes: 27 additions & 0 deletions mlir/include/Quantum/Transforms/BufferizableOpInterfaceImpl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2024-2025 Xanadu Quantum Technologies Inc.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

using namespace mlir;

namespace catalyst {

namespace quantum {

void registerBufferizableOpInterfaceExternalModels(mlir::DialectRegistry &registry);

}

} // namespace catalyst
11 changes: 0 additions & 11 deletions mlir/include/Quantum/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@

include "mlir/Pass/PassBase.td"

def QuantumBufferizationPass : Pass<"quantum-bufferize"> {
let summary = "Bufferize tensors in quantum operations.";

let dependentDialects = [
"bufferization::BufferizationDialect",
"memref::MemRefDialect"
];

let constructor = "catalyst::createQuantumBufferizationPass()";
}

def QuantumConversionPass : Pass<"convert-quantum-to-llvm"> {
let summary = "Perform a dialect conversion from Quantum to LLVM (QIR).";

Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Catalyst/Transforms/AsyncUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ std::optional<LLVM::LLVMFuncOp> AsyncUtils::getCalleeSafe(LLVM::CallOp callOp)
bool AsyncUtils::isFunctionNamed(LLVM::LLVMFuncOp funcOp, llvm::StringRef expectedName)
{
llvm::StringRef observedName = funcOp.getSymName();
return observedName.equals(expectedName);
return observedName == expectedName;
}

bool AsyncUtils::isMlirAsyncRuntimeCreateValue(LLVM::LLVMFuncOp funcOp)
Expand Down
1 change: 0 additions & 1 deletion mlir/lib/Catalyst/Transforms/RegisterAllPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ void catalyst::registerAllCatalystPasses()
mlir::registerPass(catalyst::createMemrefToLLVMWithTBAAPass);
mlir::registerPass(catalyst::createMitigationLoweringPass);
mlir::registerPass(catalyst::createQnodeToAsyncLoweringPass);
mlir::registerPass(catalyst::createQuantumBufferizationPass);
mlir::registerPass(catalyst::createQuantumConversionPass);
mlir::registerPass(catalyst::createRegisterInactiveCallbackPass);
mlir::registerPass(catalyst::createRemoveChainedSelfInversePass);
Expand Down
4 changes: 4 additions & 0 deletions mlir/lib/Driver/CompilerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include "Mitigation/Transforms/Passes.h"
#include "QEC/IR/QECDialect.h"
#include "Quantum/IR/QuantumDialect.h"
#include "Quantum/Transforms/BufferizableOpInterfaceImpl.h"
#include "Quantum/Transforms/Passes.h"

#include "Enzyme.h"
Expand Down Expand Up @@ -962,6 +963,9 @@ int QuantumDriverMainFromCL(int argc, char **argv)
registerAllCatalystDialects(registry);
registerLLVMTranslations(registry);

// Register bufferization interfaces
catalyst::quantum::registerBufferizableOpInterfaceExternalModels(registry);

// Register and parse command line options.
std::string inputFilename, outputFilename;
std::string helpStr = "Catalyst Command Line Interface options. \n"
Expand Down
5 changes: 4 additions & 1 deletion mlir/lib/Driver/Pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Catalyst/Transforms/Passes.h"
#include "Gradient/Transforms/Passes.h"
#include "Mitigation/Transforms/Passes.h"
#include "Quantum/IR/QuantumDialect.h"
#include "Quantum/Transforms/Passes.h"
#include "mhlo/transforms/passes.h"
#include "mlir/InitAllDialects.h"
Expand Down Expand Up @@ -79,7 +80,9 @@ void createBufferizationPipeline(OpPassManager &pm)
pm.addPass(catalyst::createCatalystBufferizationPass());
pm.addNestedPass<mlir::func::FuncOp>(mlir::createLinalgBufferizePass());
pm.addNestedPass<mlir::func::FuncOp>(mlir::tensor::createTensorBufferizePass());
pm.addPass(catalyst::createQuantumBufferizationPass());
mlir::bufferization::OneShotBufferizationOptions quantum_buffer_options;
quantum_buffer_options.opFilter.allowDialect<catalyst::quantum::QuantumDialect>();
pm.addPass(mlir::bufferization::createOneShotBufferizePass(quantum_buffer_options));
pm.addPass(mlir::func::createFuncBufferizePass());
pm.addNestedPass<mlir::func::FuncOp>(mlir::bufferization::createFinalizingBufferizePass());
pm.addPass(mlir::createCanonicalizerPass());
Expand Down
5 changes: 3 additions & 2 deletions mlir/lib/QEC/Transforms/CommuteCliffordPastPPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
// limitations under the License.

#define DEBUG_TYPE "merge_ppr_ppm"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"

#include "mlir/Analysis/SliceAnalysis.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
//#include "mlir/Analysis/TopologicalSortUtils.h" // enable when updating llvm
#include "mlir/Transforms/TopologicalSortUtils.h"

#include "QEC/IR/QECDialect.h"
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/QEC/Transforms/CommuteCliffordTPPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define DEBUG_TYPE "commute_ppr"

#include "llvm/Support/Debug.h"

//#include "mlir/Analysis/TopologicalSortUtils.h" // enable when updating llvm
#include "mlir/Transforms/TopologicalSortUtils.h"

#include "QEC/IR/QECDialect.h"
Expand Down
5 changes: 5 additions & 0 deletions mlir/lib/Quantum/IR/QuantumDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
#include "mlir/IR/DialectImplementation.h" // needed for generated type parser
#include "llvm/ADT/TypeSwitch.h" // needed for generated type parser

Expand Down Expand Up @@ -43,6 +44,10 @@ void QuantumDialect::initialize()
#define GET_OP_LIST
#include "Quantum/IR/QuantumOps.cpp.inc"
>();

declarePromisedInterfaces<bufferization::BufferizableOpInterface, QubitUnitaryOp, HermitianOp,
HamiltonianOp, SampleOp, CountsOp, ProbsOp, StateOp, SetStateOp,
SetBasisStateOp>();
}

//===----------------------------------------------------------------------===//
Expand Down
Loading