-
Notifications
You must be signed in to change notification settings - Fork 52
Update llvm, 2025 Q3 #1916
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
base: main
Are you sure you want to change the base?
Update llvm, 2025 Q3 #1916
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
@@ -35,7 +35,7 @@ static Value genSelectiveShift(PatternRewriter &rewriter, Location loc, Value pa | |||
} | |||
|
|||
// Make sure all active iteration variables match the selectors. | |||
Value shiftCondition = rewriter.create<arith::ConstantIntOp>(loc, true, 1); | |||
Value shiftCondition = rewriter.create<arith::ConstantIntOp>(loc, 1, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: there are 3 arith::ConstantInt
buidler calls in the mhlo patched passes. We might need to update those too.
This comment was marked as outdated.
This comment was marked as outdated.
@@ -97,6 +97,11 @@ mhlo: | |||
@if cd mlir-hlo; git apply --check $(MK_DIR)/patches/mhlo-add-back-necessary-passes.patch; then \ | |||
git apply $(MK_DIR)/patches/mhlo-add-back-necessary-passes.patch; \ | |||
fi | |||
|
|||
# Patch a MHLO bug with std::sort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to patch this in github wheels scripts too
- sort(r->nodes, &r->deltab); | ||
- sort(r->nodes, &r->deltaf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is equivalent:
diff --git a/utils/cycle_detector.cc b/utils/cycle_detector.cc
index e3901ae88..890f39654 100644
--- a/utils/cycle_detector.cc
+++ b/utils/cycle_detector.cc
@@ -199,8 +199,8 @@ static void backwardDfs(GraphCycles::Rep* r, int32_t n, int32_t lowerBound) {
// Recomputes rank assignments to make them compatible with the edges (producer
// has smaller rank than its consumer)
static void reorder(GraphCycles::Rep* r) {
- sort(r->nodes, &r->deltab);
- sort(r->nodes, &r->deltaf);
+ mlir::sort(r->nodes, &r->deltab);
+ mlir::sort(r->nodes, &r->deltaf);
// Adds contents of delta lists to list (backwards deltas first).
r->list.clear();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the same kind of fix as just renaming? as in explicitly forcing the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
As a QoL, also add util to convert python values into mlir attributes
Thank you for pointing this out. I'll try to address these tomorrow in xDSL. |
cc @mehrdad2m |
I think this PR in llvm llvm/llvm-project#138125 is segfaulting all the async tests. |
I have isolated it and this is an upstream bug. I opened an issue in llvm llvm/llvm-project#150441 |
@mehrdad2m @paul0403 PR regarding the transform dialect in xDSL PennyLaneAI/pennylane#7956 |
@@ -165,3 +166,49 @@ def custom_lower_jaxpr_to_module( | |||
worklist += [*op.body.operations] | |||
|
|||
return ctx.module, ctx.context | |||
|
|||
|
|||
def get_mlir_attribute_from_pyval(value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a very nice utility function. Do you think it could belong to the utils
folder or is it too specific to this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a file which contains similar code named types.py. You could also think of upstreaming something like this to the MLIR repo. (which will then be picked up by JAX since they use the Python bindings) Maybe somewhere around this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a very nice utility function. Do you think it could belong to the
utils
folder or is it too specific to this file?
I think this is specific to this file, this is a helper just for lowering jax primitive params (which are pure python values) to mlir attributes, so I thought it naturally belonged in the jax_extras/lowering.py
. This file already is the util file for lowering I think.
@@ -204,6 +219,11 @@ clean-dialects: | |||
clean-llvm: | |||
@echo "clean llvm/mlir build files" | |||
rm -rf $(LLVM_BUILD_DIR) | |||
cd llvm-project; git clean -fd; git checkout . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add the same logic for the other pathed repos (enzyme, mhlo) for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already have this for mhlo. I will add this for enzyme as well.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1916 +/- ##
==========================================
- Coverage 96.81% 96.77% -0.05%
==========================================
Files 87 87
Lines 9682 9715 +33
Branches 899 911 +12
==========================================
+ Hits 9374 9402 +28
- Misses 245 248 +3
- Partials 63 65 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Context:
Update llvm, mhlo and enzyme, 2025 Q3.
The latest pair of good versions, indicated by mhlo, is tensorflow/mlir-hlo@1dd2e71
For Enzyme, we go to the latest release https://github.com/EnzymeAD/Enzyme/releases/tag/v0.0.186
with commit
8c1a596158f6194f10e8ffd56a1660a61c54337e
Description of the Change:
Miscellaneous:
GreedyRewriteConfig.stuff = blah
->GreedyRewriteConfig.setStuff(blah)
[mlir] add a fluent API to GreedyRewriterConfig llvm/llvm-project#137122inbounds
attribute is subsumed under a gep sign wrap enum flag [mlir][llvm] Support nusw and nuw in GEP llvm/llvm-project#137272arith::Constant[Int, Float]Op
builders now have the same argument order as other ops (output type first, then arguments) switch type and value ordering for arithConstant[XX]Op
llvm/llvm-project#144636 (note that Enzyme also noticed this Update to newer llvm EnzymeAD/Enzyme#2379 😆 )lookupOrCreateFn
functions now take in a builder instead of instantiating a new one [mlir][LLVM] AddOpBuilder &
tolookupOrCreateFn
functions llvm/llvm-project#136421getStridedElementPtr
now takes inrewriter
as the first argument (instead of the last), like all the other utils emit inbounds and nuw attributes in memref. llvm/llvm-project#138984LogicalResult
, and will be caught by warnings as errors as-Wunused-result
:func::FuncOp.[insert, erase]Argument(s)
[mlir] allow function type cloning to fail llvm/llvm-project#137130getBackwardSlice()
[MLIR] Change getBackwardSlice to return a logicalresult rather than crash llvm/llvm-project#140961Things related to
transform.apply_registered_pass
op:dynamic_options
[MLIR][Transform] Allow ApplyRegisteredPassOp to take options as a param llvm/llvm-project#142683. We don't need to use this as all our pass options are static.Bufferization:
bufferization.to_memref
op is renamed tobufferization.to_buffer
[mlir][bufferization][NFC] Rename to_memref to to_buffer llvm/llvm-project#137180bufferization.to_tensor
op's builder now needs the result type to be explicit [mlir][bufferization] Support custom types (1/N) llvm/llvm-project#142986. This is also needed by a patched mhlo pass.getBuffer()
methods take in a new arg forBufferizationState
[MLIR] Add bufferization state class to OneShotBufferization pass llvm/llvm-project#141019, [MLIR] Add bufferization state togetBufferType
andresolveConflicts
interface methods llvm/llvm-project#141466UnknownTypeConverterFn
in bufferization options now takes in just a type instead of a full value [mlir][bufferization] Use Type instead of Value in unknown conversion llvm/llvm-project#144658[sc-95176]