Support performance warning#3922
Conversation
|
Where is this flag coming from "-Wno-perf-warnings"? |
Can you use remark to emit ptx warnings? Maybe not? |
We shouldn't have tests as tutorials :) Could you create a unit test that exercises the new codepaths and checks for the output on std::cerr? |
|
Thanks for the comments! As described in the summary:
You mean warnings from ptxas, not sure how to get them. But we can emit remarks when lowering from llvm to ptx. CC @joker-eph: if you have any suggestion to some of the questions, that will be great, Thanks! |
My worry was that some warnings might be emitted from ptx to sass. I'm OK with either marks or warnings. I think marks actually seem more informative. |
You could capture the output of ptxas and regex/pattern match the output to catch these and report them as remarks? |
test/unit/warnings.py sounds like a good place
Just to be clear, this should check against stderr |
| out_messages = out_capture.getvalue() | ||
| sys.stderr = sys.__stderr__ | ||
| sys.stdout = sys.__stdout__ | ||
| print(error_messages) |
There was a problem hiding this comment.
This test case is not working currently. I haven't figured out how to capture the stderr in a string yet. Tried to redirect stderr, but it may be captured by pytest? The message shows:
--------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------
python/test/unit/test_warning.py:21:18: remark: Warning: can't use MMA V3 for the dot op
c = tl.dot(a, b)
^
python/test/unit/test_warning.py:21:18: note: see current operation: %46 = tt.dot ...
Will clean up this once it is solved. @htyu Any suggestion here? Thanks!
|
@ptillet About using warning flags -Wno-perf-warnings or -Werror, I feel it is not supported in the python workflow "python test.py", right? So is the suggestion about supplying the flags for triton-opt and still use env variables for the python workflow? |
| srcMgr = llvm.source_mgr() | ||
| diag = ir.source_mgr_diag(srcMgr, mod.context) | ||
| mod.context.printOpOnDiagnostic(True) | ||
| #mod.context.printStackTraceOnDiagnostic(True) |
There was a problem hiding this comment.
Actually I think instead we may want to add an enable_remarks API similar to enable_debug:
Line 1552 in 74ad278
There was a problem hiding this comment.
@htyu Thanks for the review! Sorry for the delay. I tried to wrap things in enable_remarks:
as part of Context
py::class_<MLIRContext>(m, "context", py::module_local())
.def(py::init<>())
+ .def("enable_remark",
+ [](MLIRContext &self) {
+ auto srcMgr = llvm::SourceMgr();
+ auto diag = SourceMgrDiagnosticHandler(srcMgr, &self);
+ self.printOpOnDiagnostic(true);
+ })
or as part of PassManager
py::class_<PassManager>(m, "pass_manager", py::module_local())
.def(py::init<MLIRContext *>())
+ .def("enable_remark",
+ [](PassManager &self) {
+ auto *context = self.getContext();
+ auto srcMgr = llvm::SourceMgr();
+ auto diag = SourceMgrDiagnosticHandler(srcMgr, context);
+ context->printOpOnDiagnostic(true);
+ })
Then call from make_ttgir:
with either
mod.context.enable_remark()
or
pm.enable_remark()
None of these worked. I think it is due to the liveness of SourceMgr and SourceMgrDiagnosticHandler.
There was a problem hiding this comment.
Thanks for giving it a shot. Currently changes look good to me.
|
The tests are failing. I need to only enable the test for H100 with the env variable. |
| cluster_info.clusterDimY = opt.cluster_dims[1] | ||
| cluster_info.clusterDimZ = opt.cluster_dims[2] | ||
| # Set up Diagnostic | ||
| if os.environ.get("MLIR_ENABLE_REMARK", "0") == "1": |
There was a problem hiding this comment.
Can you document in README?
This commit adds a performance warning for not selecting MMA v3 for
tl.dot on Hopper.
For the added test case, we will get:
```
test-warning.py:24:18: remark: Warning: can't use MMA V3 for the dot op
c = tl.dot(a, b)
^
test-warning.py:24:18: note: see current operation: %39 = tt.dot %37, %38, %cst, inputPrecision = tf32 :
```
This commit adds a performance warning for not selecting MMA v3 for tl.dot on Hopper.
For the added test case, we will get: