Skip to content

Migrating to One-Shot Bufferization #1027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 192 commits into from
Closed
Changes from all commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
6af3eef
Setup latest dependency for new bufferization passes
tzunghanjuang Aug 15, 2024
951ef36
enableRegionSimplification accepts GreedySimplifyRegionLevel type ins…
tzunghanjuang Aug 15, 2024
21e5933
translateModuleToLLVMIR needs an extra disableVerification parameter
tzunghanjuang Aug 15, 2024
c8336bd
Replace equals with compare for llvm::StringRef
tzunghanjuang Aug 15, 2024
9e6ae3f
Keep using jax 0.4.28 but update llvm (from jax 0.4.29)
tzunghanjuang Aug 16, 2024
0cf462b
Roll back EnzymeStatic to 19
tzunghanjuang Aug 16, 2024
39b2537
Use == instead of compare
tzunghanjuang Aug 16, 2024
5bad741
Roll back enableRegionSimplification type
tzunghanjuang Aug 16, 2024
4e9cc28
Comment out retired bufferization passes
tzunghanjuang Aug 16, 2024
ad22787
Temporarily disable finalizing-bufferization for debugging
tzunghanjuang Aug 20, 2024
add7ddd
Merge remote-tracking branch 'origin/main' into bufferization-update
tzunghanjuang Aug 20, 2024
be8c968
Merge remote-tracking branch 'origin/main' into bufferization-update
tzunghanjuang Aug 20, 2024
0852bcc
Reformat compiler.py
tzunghanjuang Aug 20, 2024
ffcd4d3
Remove all passes and use one-shot-bufferize only
tzunghanjuang Aug 20, 2024
8b45ae8
Add new buffer passes except for the deallocation pipeline
tzunghanjuang Aug 21, 2024
4d20def
Temporarily set side effect of InitOp and FinalizeOp as zero
tzunghanjuang Aug 21, 2024
d9b38ba
Disable deallocation pipeline for debugging
tzunghanjuang Aug 21, 2024
676053f
Draft Quantum Impl of BufferizableOpInterface
tzunghanjuang Aug 21, 2024
3febbf7
Add empty one-shot-bufferize for quantum::ExtractOp
tzunghanjuang Aug 21, 2024
a354e3f
Temporarily get rid of memory error
tzunghanjuang Aug 26, 2024
7de0d80
Register new one-shot bufferization pass
tzunghanjuang Aug 26, 2024
af6f65a
Fix include typos
tzunghanjuang Aug 26, 2024
1edbcd2
Replace ExtractOP with StateOp for the first bufferization example
tzunghanjuang Aug 26, 2024
f94dcf7
Test StateOp bufferization
tzunghanjuang Aug 27, 2024
a3816a6
Use replaceOpWithBufferizedValues to get rid of segmentation fault
tzunghanjuang Aug 27, 2024
fc46399
Set buffer write for StateOp as false
tzunghanjuang Aug 28, 2024
f028709
Add new bufferization pass for ProbsOp
tzunghanjuang Aug 28, 2024
dc631a7
Add new bufferization interface for CountsOp
tzunghanjuang Aug 28, 2024
b8181b8
Correct the read flag for StateOp like operations
tzunghanjuang Aug 28, 2024
849e884
Add new set_state bufferization
tzunghanjuang Aug 28, 2024
39f1757
Add SetBasisStateOp bufferization
tzunghanjuang Aug 28, 2024
b5157ff
Add QubitUnitary Bufferization
tzunghanjuang Aug 28, 2024
5556493
Add hermitian bufferization
tzunghanjuang Aug 28, 2024
c3bf61a
Add Hamiltonian bufferization
tzunghanjuang Aug 28, 2024
a9ed44b
Remove redundant scope resolutions
tzunghanjuang Aug 28, 2024
b54c104
Add SampleOp bufferization
tzunghanjuang Aug 28, 2024
440b926
Draft bufferization templates for Catalyst and Gradient IRs
tzunghanjuang Aug 29, 2024
159057c
Add printOp Bufferization
tzunghanjuang Aug 29, 2024
81394ae
Fix indentation
tzunghanjuang Aug 29, 2024
e6df804
Remove redundant imclude from QuantumDialect
tzunghanjuang Aug 29, 2024
980b0db
Fix the other indentations
tzunghanjuang Aug 29, 2024
01df77e
Add CustomCall bufferization
tzunghanjuang Aug 29, 2024
4a90eef
Set write flag of custom call as false
tzunghanjuang Aug 29, 2024
c4547ae
Tentatively add CallbackCallOp bufferization
tzunghanjuang Aug 29, 2024
0c2eea8
Still create a new type converter in CallbackCallOp pass
tzunghanjuang Aug 29, 2024
71fa5d7
Use replaceOpWithBufferizedValues at the end of CallbackCallOp
tzunghanjuang Aug 29, 2024
4295bfc
Add new passes to quantum-opt
tzunghanjuang Aug 30, 2024
c01dd1f
Add AdjointOp bufferization
tzunghanjuang Aug 30, 2024
45581c7
Use BufferizeTypeConverter in new pass
tzunghanjuang Aug 30, 2024
9ba2cd9
Make CallbackOp use Unstructured Control Flow Bufferizable OpInterface
tzunghanjuang Sep 3, 2024
58a0bed
Add tentative patch for moduleOp bufferization
tzunghanjuang Sep 3, 2024
f0a10bf
Update patch script
tzunghanjuang Sep 3, 2024
03bee24
Reformatting
tzunghanjuang Sep 4, 2024
ba85b20
Update llvm patch
tzunghanjuang Sep 4, 2024
1c730d2
Stick with old llvm version for now
tzunghanjuang Sep 4, 2024
31c9139
Rollback llvvm fix
tzunghanjuang Sep 4, 2024
525422b
Reformatting
tzunghanjuang Sep 4, 2024
d7c236d
Update patch
tzunghanjuang Sep 4, 2024
ac4fc89
Correct AdjointOpInterface
tzunghanjuang Sep 4, 2024
4428eec
Fix bufferization in AjointOp
tzunghanjuang Sep 4, 2024
dde8e68
Add backpropOp bufferization
tzunghanjuang Sep 5, 2024
af0da0c
Add restrict to ToTensorOp
tzunghanjuang Sep 5, 2024
cae09e0
Correct bufferized args in backpropOp
tzunghanjuang Sep 5, 2024
1182aca
Use identity-layout-map
tzunghanjuang Sep 6, 2024
67d1d6a
Update llvm patch with new ReturnLike mechanism
tzunghanjuang Sep 6, 2024
c6d834c
Cleanup
tzunghanjuang Sep 6, 2024
f8a1a8f
Include convert-elementwise-to-linalg back to bufferization pass
tzunghanjuang Sep 6, 2024
9a1a791
Add ForwardOp Bufferization
tzunghanjuang Sep 6, 2024
3aead9c
Add reverseOp Bufferization
tzunghanjuang Sep 6, 2024
418f122
Correct bufferization interface registration
tzunghanjuang Sep 6, 2024
576ebe6
Rebuild MemRefType without memory layout for BackpropOp
tzunghanjuang Sep 9, 2024
3c4056c
Add back convert-arraylist-to-memref
tzunghanjuang Sep 9, 2024
68d6233
Include scf-for-preprocessing from LLVM PR#87594
tzunghanjuang Sep 9, 2024
31b1dc9
Add scf-loop-bufferization-preprocessing into bufferization pass
tzunghanjuang Sep 9, 2024
81f0a86
Make llvm patches apply to directory
tzunghanjuang Sep 9, 2024
ee9b78d
Remove functionOpInterface workaround for no ReturnLike from the patch
tzunghanjuang Sep 10, 2024
b9f0e9c
Make CopyGlobalMemRef create memref without memory layout and then ca…
tzunghanjuang Sep 10, 2024
c522097
Use allow-return-allocs-from-loops to avoid scf.for/while errors
tzunghanjuang Sep 11, 2024
553ed3e
Make ForwardOp and ReverseOp compatible with ModuleOpBufferize
tzunghanjuang Sep 12, 2024
c418792
Make ForwardOp and ReverseOp update signature
tzunghanjuang Sep 12, 2024
1e5f96c
Do not bufferize ForwarOp if its implementation if not bufferized
tzunghanjuang Sep 12, 2024
a2af457
Update ReverseOp
tzunghanjuang Sep 12, 2024
723fa11
Update conditions for ForwardOp and ReverseOp
tzunghanjuang Sep 12, 2024
49b197b
Remove ForwardOp and ReverseOp workarounds
tzunghanjuang Sep 12, 2024
0d4bfbd
Create templates for ForwardOp and ReverseOp preprocessing
tzunghanjuang Sep 12, 2024
79ce24e
Use preprocessing steps to add Func.call in ForwardOp and ReverseOp
tzunghanjuang Sep 12, 2024
7d5fc1f
Remove llvm scf patch
tzunghanjuang Sep 16, 2024
997b674
Merge branch 'main' into bufferization-update
Sep 17, 2024
6a24347
CI warning cleanup
tzunghanjuang Sep 17, 2024
73bef19
Update llvm patch
tzunghanjuang Sep 17, 2024
66e7b06
Make gradient.ReturnOp ReturnLike
tzunghanjuang Sep 17, 2024
ea4f2d7
Draft new ForwardOp bufferization
tzunghanjuang Sep 17, 2024
accf60a
Add getBufferType method to ForwardOp and ReverseOp Interface
tzunghanjuang Sep 17, 2024
99c517a
Cleanup unused read-write flag in ForwardOp and ReverseOp
tzunghanjuang Sep 17, 2024
c7768be
Copy methods from FuncOp to ForwardOp and ReverseOp
tzunghanjuang Sep 17, 2024
42d224a
Draft new ReverseOp Interface and fix its getBufferType
tzunghanjuang Sep 18, 2024
fedd668
Make ForwardOp and ReverseOp follow FuncOp bufferization steps
tzunghanjuang Sep 18, 2024
0473d72
Make gradient-preprocess happen before eliminate-empty-tensors to pas…
tzunghanjuang Sep 18, 2024
f5c4da0
Reformatting
tzunghanjuang Sep 18, 2024
d42b123
Update llvm patch with FunctionArgTypeConverterFn
tzunghanjuang Sep 18, 2024
86eeb4e
Preserve unused return types during bufferization
tzunghanjuang Sep 18, 2024
de97c6b
Use identity-layout-map to prevent unused returns from being removed
tzunghanjuang Sep 18, 2024
42b3870
revert identiy-layout-map
tzunghanjuang Sep 18, 2024
ee02d7e
Restore ReserseOp's signature if it is optimized away by one-shot-buf…
tzunghanjuang Sep 19, 2024
df63f1a
Use replaceOpWithNewBufferizedOp for quantum.unitary
tzunghanjuang Sep 19, 2024
8a1c49a
Use old dealloaction steps
tzunghanjuang Sep 19, 2024
160a0ed
Cleanup
tzunghanjuang Sep 19, 2024
3f6eaf2
Fix var names in mlir debug test
tzunghanjuang Sep 19, 2024
f42b861
Test removing stride from memreftype in customCall
tzunghanjuang Sep 19, 2024
3c4f0ca
Use SubView for allocCopyMemrefDyn if CastOP is not supported
tzunghanjuang Sep 20, 2024
0eb6cbf
Use subview to handle memref with strides and offset
tzunghanjuang Sep 20, 2024
d7a0019
Use identity map and cleanup
tzunghanjuang Sep 20, 2024
0a915b5
Add CallOp bufferization patch
tzunghanjuang Sep 20, 2024
52fd238
Revert changes in frontend/test/pytest/test_debug.py
tzunghanjuang Sep 20, 2024
18b2762
Add inline back to bufferization
tzunghanjuang Sep 20, 2024
266ba24
Add functionOPInterface patch for mhlo
tzunghanjuang Sep 23, 2024
b915cff
Merge branch 'main' into bufferization-update
Sep 23, 2024
9d5fc4d
Correct bufferizeToMemoryWrite for setState and setBasisState
tzunghanjuang Sep 24, 2024
0e10abb
Update linux-x86_64 wheel
tzunghanjuang Sep 24, 2024
a1dd5d5
Update macos-arm64 wheel
tzunghanjuang Sep 24, 2024
4718c14
Update macos-x86-64 wheel
tzunghanjuang Sep 24, 2024
64aa9ff
Update linux_arm64 scripts
tzunghanjuang Sep 24, 2024
cf56867
add lcurses flag to compile_executable
tzunghanjuang Sep 24, 2024
6862700
Add copy-before-write only for async tests
tzunghanjuang Sep 24, 2024
de0b559
Merge branch 'main' into bufferization-update
Sep 24, 2024
ee47a0c
Clear subview work around in cg_global_bufferize
tzunghanjuang Sep 24, 2024
b858cde
Reformatting
tzunghanjuang Sep 24, 2024
e8eb51c
Try fixing wheel
tzunghanjuang Sep 24, 2024
da68883
Debug wheel
tzunghanjuang Sep 24, 2024
f0364ef
Try getting rid of exports
tzunghanjuang Sep 24, 2024
0155585
Debug llvm path
tzunghanjuang Sep 24, 2024
08b4493
Try different paths
tzunghanjuang Sep 24, 2024
a6281e0
Update patch paths in wheel scripts
tzunghanjuang Sep 24, 2024
df1c23f
Apply patch when getting LLVM and MHLO sources
tzunghanjuang Sep 30, 2024
b5b3876
Revert "Apply patch when getting LLVM and MHLO sources"
tzunghanjuang Sep 30, 2024
0e0406b
Patch LLVM again before building wheel
tzunghanjuang Sep 30, 2024
98fb3db
Apply patches right before building MLIR Dialects
tzunghanjuang Sep 30, 2024
9401b97
Construct BUFFERIZATION_ASYNC_PASS in a concise way
tzunghanjuang Sep 30, 2024
c4b7b5e
Patch LLVM when building dialects in all the other wheel scripts
tzunghanjuang Sep 30, 2024
c36e160
Create cache with patches' hash
tzunghanjuang Sep 30, 2024
2e6324a
Update patch and its name
tzunghanjuang Sep 30, 2024
975b280
Reapply patch when building MLIR dialects
tzunghanjuang Sep 30, 2024
ddc0b41
Merge branch 'main' into bufferization-update
Sep 30, 2024
3e68cd8
Update changelog
tzunghanjuang Sep 30, 2024
661a1d5
Add patch hash to macos-arm64
tzunghanjuang Sep 30, 2024
9d5d117
Add patch hash to linux-arm64 wheel
tzunghanjuang Oct 1, 2024
170d211
Make x86_64 use patch hash
tzunghanjuang Oct 1, 2024
386f274
Install ncurses for linux-arm64 wheels
tzunghanjuang Oct 3, 2024
17c94d6
Add top-level comments for bufferization
Oct 4, 2024
d58a215
Add comment that explains RestoreReverseOp
Oct 4, 2024
b438e4d
Update mlir/lib/Catalyst/Transforms/BufferizableOpInterfaceImpl.cpp
Oct 7, 2024
cf4018c
Update mlir/include/Gradient/Transforms/BufferizableOpInterfaceImpl.h
Oct 7, 2024
71abe78
Update mlir/include/Catalyst/Transforms/BufferizableOpInterfaceImpl.h
Oct 7, 2024
c138452
Use compare instead of ==
Oct 7, 2024
e8322ac
Add TODO reminder for removing patches after updating jax
Oct 7, 2024
761aaf7
Update mlir/Makefile
Oct 7, 2024
26c56d5
Add another TODO comment
Oct 7, 2024
d7cb22a
Merge branch 'main' into bufferization-update
Oct 7, 2024
0296eb9
Cleanup
Oct 7, 2024
c27fd57
Set bufferizesToMemoryWrite for CustomCallOp as true
Oct 7, 2024
b2879cf
Make CustomCallOp not return failure if its operands are not bufferizble
Oct 7, 2024
b69dd2a
Make CustomCallOp not return failure if its results are not bufferizble
Oct 7, 2024
9069ca8
Remove unused CustomCallOp members
Oct 7, 2024
9c93c2a
Implement bufferizesToAllocation for CallbackCallOp and CustomCallOp
Oct 7, 2024
323b093
Tentatively revert CustomCallOp bufferizesToMemoryWrite to false
Oct 7, 2024
009929b
Test disable lcurses
Oct 8, 2024
e327479
Remove lcurses installation
Oct 8, 2024
aa9f69c
Cleanup
Oct 8, 2024
87be1d3
Add comment to CallbackOp's bufferizesToMemoryWrite
Oct 8, 2024
143ba55
Add table of bufferizable ops
Oct 9, 2024
8d0324d
Small fix
Oct 9, 2024
6dc98b9
Small correction
Oct 9, 2024
44d4597
Set supportsUnstructuredControlFlow for CallBackOp as False
Oct 10, 2024
3cecfaf
Remove uncontrolflow from CallBackOp
Oct 10, 2024
2cb30e3
Bufferization comments (#1197)
erick-xanadu Oct 10, 2024
812bf7f
Entirely remove all unstructure control flow
Oct 10, 2024
c76698a
Reformatting
Oct 10, 2024
5b488b2
Revert "Entirely remove all unstructure control flow"
Oct 10, 2024
3646328
set supportsUnstructuredControlFlow for forwardOp and reverseOp to false
Oct 10, 2024
938df91
Update mlir/lib/Quantum/Transforms/BufferizableOpInterfaceImpl.cpp
Oct 11, 2024
6c77916
Update mlir/lib/Quantum/Transforms/BufferizableOpInterfaceImpl.cpp
Oct 11, 2024
dfbe2a9
Merge branch 'main' into bufferization-update
erick-xanadu Oct 15, 2024
d1c0bde
wip
erick-xanadu Oct 10, 2024
12bf618
Comments
erick-xanadu Oct 11, 2024
3c0bb0a
f
erick-xanadu Oct 11, 2024
619bf3d
More comments
erick-xanadu Oct 15, 2024
b49881e
Fix comments
erick-xanadu Oct 15, 2024
9bda879
Remove unnecessary code
erick-xanadu Oct 15, 2024
227c08e
style
erick-xanadu Oct 15, 2024
b179e70
Fix
erick-xanadu Oct 15, 2024
e4235d7
line length
erick-xanadu Oct 15, 2024
e0f6846
Merge branch 'main' into bufferization-update
erick-xanadu Nov 6, 2024
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
18 changes: 9 additions & 9 deletions .github/workflows/build-wheel-linux-arm64.yaml
Original file line number Diff line number Diff line change
@@ -63,15 +63,15 @@ jobs:
uses: actions/cache@v4
with:
path: mlir/llvm-project
key: llvm-${{ needs.constants.outputs.llvm_version }}-default-source
key: llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-default-source
enableCrossOsArchive: True

- name: Cache MHLO Source
id: cache-mhlo-source
uses: actions/cache@v4
with:
path: mlir/mlir-hlo
key: mhlo-${{ needs.constants.outputs.mhlo_version }}-default-source
key: mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-default-source
enableCrossOsArchive: True

- name: Cache Enzyme Source
@@ -112,14 +112,14 @@ jobs:
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-wheel-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build

- name: Restore MHLO Build
id: cache-mhlo-build
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
lookup-only: True

- name: Restore Enzyme Build
@@ -160,7 +160,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: llvm-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-wheel-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build

- name: Build MHLO Dialect
if: steps.cache-mhlo-build.outputs.cache-hit != 'true'
@@ -179,7 +179,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: mhlo-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build

- name: Build Enzyme
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
@@ -240,7 +240,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-wheel-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
fail-on-cache-miss: True

- name: Get Cached MHLO Source
@@ -257,7 +257,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ matrix.container_name }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
fail-on-cache-miss: True

- name: Get Cached Enzyme Source
@@ -334,7 +334,7 @@ jobs:
uses: actions/cache@v4
with:
path: llvm-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-wheel-build
key: ${{ matrix.container_name }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
fail-on-cache-miss: True

- name: Run Python Pytest Tests
25 changes: 18 additions & 7 deletions .github/workflows/build-wheel-linux-x86_64.yaml
Original file line number Diff line number Diff line change
@@ -118,14 +118,14 @@ jobs:
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-${{matrix.python_version}}-wheel-build

- name: Restore MHLO Build
id: cache-mhlo-build
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
lookup-only: True

- name: Restore Enzyme Build
@@ -172,6 +172,11 @@ jobs:
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
run: |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH

# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch; fi

cmake -S mlir/llvm-project/llvm -B llvm-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_BUILD_EXAMPLES=OFF \
@@ -198,17 +203,18 @@ jobs:
uses: actions/cache/save@v4
with:
path: llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-${{matrix.python_version}}-wheel-build

- name: Build MHLO Dialect
if: steps.cache-mhlo-build.outputs.cache-hit != 'true'
# building with LLD is a strong requirement for mhlo
run: |
# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH

export TARGET_FILE=mlir/mlir-hlo/mhlo/transforms/CMakeLists.txt
export PATCH_FILE=mlir/patches/mhlo-Add-PassesIncGen-in-transforms-CMakeList.patch
if patch --dry-run -p1 -N $TARGET_FILE $PATCH_FILE > /dev/null 2>&1; then patch -p1 $TARGET_FILE $PATCH_FILE; fi
if patch --dry-run -p1 -N --directory=mlir/mlir-hlo < mlir/patches/FunctionOpInterface-mhlo.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/mlir-hlo < mlir/patches/FunctionOpInterface-mhlo.patch; fi

cmake -S mlir/mlir-hlo -B mhlo-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
@@ -228,7 +234,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: mhlo-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build

- name: Build Enzyme
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
@@ -296,7 +302,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-3.10-wheel-build
key: ${{ matrix.container_img }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-3.10-wheel-build
fail-on-cache-miss: True

- name: Get Cached MHLO Source
@@ -313,7 +319,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ matrix.container_img }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
fail-on-cache-miss: True

- name: Get Cached Enzyme Source
@@ -363,7 +369,12 @@ jobs:
# Build Quantum and Gradient Dialects
- name: Build MLIR Dialects
run: |
# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/mlir-hlo < mlir/patches/FunctionOpInterface-mhlo.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/mlir-hlo < mlir/patches/FunctionOpInterface-mhlo.patch; fi

cmake -S mlir -B quantum-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
23 changes: 17 additions & 6 deletions .github/workflows/build-wheel-macos-arm64.yaml
Original file line number Diff line number Diff line change
@@ -105,14 +105,14 @@ jobs:
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-${{matrix.python_version}}-wheel-build

- name: Restore MHLO Build
id: cache-mhlo-build
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
lookup-only: True

- name: Restore Enzyme Build
@@ -137,6 +137,10 @@ jobs:
- name: Build LLVM / MLIR
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
run: |
# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch; fi

cmake -S mlir/llvm-project/llvm -B llvm-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_BUILD_EXAMPLES=OFF \
@@ -163,16 +167,18 @@ jobs:
uses: actions/cache/save@v4
with:
path: llvm-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-${{matrix.python_version}}-wheel-build

- name: Build MHLO Dialect
if: steps.cache-mhlo-build.outputs.cache-hit != 'true'
run: |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH

# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
export TARGET_FILE=mlir/mlir-hlo/mhlo/transforms/CMakeLists.txt
export PATCH_FILE=mlir/patches/mhlo-Add-PassesIncGen-in-transforms-CMakeList.patch
if patch --dry-run -p1 -N $TARGET_FILE $PATCH_FILE > /dev/null 2>&1; then patch -p1 $TARGET_FILE $PATCH_FILE; fi
if patch --dry-run -p1 -N --directory=mlir/mlir-hlo < mlir/patches/moduleOp-mhlo.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/mlir-hlo < mlir/patches/moduleOp-mhlo.patch; fi

cmake -S mlir/mlir-hlo -B mhlo-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
@@ -192,7 +198,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: mhlo-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build

- name: Build Enzyme
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
@@ -256,7 +262,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-3.10-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-3.10-wheel-build
fail-on-cache-miss: True

- name: Get Cached MHLO Source
@@ -273,7 +279,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
fail-on-cache-miss: True

- name: Get Cached Enzyme Source
@@ -328,6 +334,11 @@ jobs:
# Build Quantum and Gradient Dialects
- name: Build MLIR Dialects
run: |
# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/mlir-hlo < mlir/patches/moduleOp-mhlo.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/mlir-hlo < mlir/patches/moduleOp-mhlo.patch; fi

cmake -S mlir -B quantum-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
23 changes: 17 additions & 6 deletions .github/workflows/build-wheel-macos-x86_64.yaml
Original file line number Diff line number Diff line change
@@ -103,14 +103,14 @@ jobs:
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-${{matrix.python_version}}-wheel-build

- name: Restore MHLO Build
id: cache-mhlo-build
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
lookup-only: True

- name: Restore Enzyme Build
@@ -133,6 +133,10 @@ jobs:
- name: Build LLVM / MLIR
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
run: |
# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch; fi

cmake -S mlir/llvm-project/llvm -B llvm-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_BUILD_EXAMPLES=OFF \
@@ -159,16 +163,18 @@ jobs:
uses: actions/cache/save@v4
with:
path: llvm-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-${{matrix.python_version}}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-${{matrix.python_version}}-wheel-build

- name: Build MHLO Dialect
if: steps.cache-mhlo-build.outputs.cache-hit != 'true'
run: |
export PATH=$GITHUB_WORKSPACE/llvm-build/bin:$PATH

# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
export TARGET_FILE=mlir/mlir-hlo/mhlo/transforms/CMakeLists.txt
export PATCH_FILE=mlir/patches/mhlo-Add-PassesIncGen-in-transforms-CMakeList.patch
if patch --dry-run -p1 -N $TARGET_FILE $PATCH_FILE > /dev/null 2>&1; then patch -p1 $TARGET_FILE $PATCH_FILE; fi
if patch --dry-run -p1 -N --directory=mlir/mlir-hlo < mlir/patches/FunctionOpInterface-mhlo.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/mlir-hlo < mlir/patches/FunctionOpInterface-mhlo.patch; fi

cmake -S mlir/mlir-hlo -B mhlo-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
@@ -188,7 +194,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: mhlo-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build

- name: Build Enzyme
if: steps.cache-enzyme-build.outputs.cache-hit != 'true'
@@ -246,7 +252,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: llvm-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-3.10-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ needs.constants.outputs.llvm_version }}-patch-${{ hashFiles('mlir/patches/**') }}-3.10-wheel-build
fail-on-cache-miss: True

- name: Get Cached MHLO Source
@@ -263,7 +269,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: mhlo-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-wheel-build
key: ${{ runner.os }}-${{ runner.arch }}-mhlo-${{ needs.constants.outputs.mhlo_version }}-patch-${{ hashFiles('mlir/patches/**') }}-wheel-build
fail-on-cache-miss: True

- name: Get Cached Enzyme Source
@@ -319,6 +325,11 @@ jobs:
# Build Quantum and Gradient Dialects
- name: Build MLIR Dialects
run: |
# TODO: Remove these patches after upgrading Jax (potentailly for 0.4.34 or higher).
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/FunctionOpInterface-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/llvm-project < mlir/patches/callOp-bufferization.patch; fi
if patch --dry-run -p1 -N --directory=mlir/mlir-hlo < mlir/patches/FunctionOpInterface-mhlo.patch > /dev/null 2>&1; then patch -p1 --directory=mlir/mlir-hlo < mlir/patches/FunctionOpInterface-mhlo.patch; fi

cmake -S mlir -B quantum-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
Loading
Loading