Skip to content

Commit 918f35c

Browse files
Merge branch 'develop' into dpp-refactor-blockwise-reduce
2 parents 9b206aa + 78c6db3 commit 918f35c

70 files changed

Lines changed: 5055 additions & 1954 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Python Lint and Format Check
1+
name: rocMLIR GitHub Actions
22

33
on:
44
pull_request:
@@ -9,6 +9,8 @@ on:
99
- "mlir/**"
1010
- "external/**"
1111
- "!external/llvm-project/**"
12+
- ".github/workflows/**"
13+
- "pip_requirements.txt"
1214
push:
1315
branches:
1416
- develop
@@ -17,8 +19,11 @@ on:
1719
- "mlir/**"
1820
- "external/**"
1921
- "!external/llvm-project/**"
22+
- ".github/workflows/**"
23+
- "pip_requirements.txt"
2024
jobs:
21-
py-checks:
25+
format-and-lint-checks:
26+
name: Python format and lint checks
2227
runs-on: ubuntu-latest
2328
container:
2429
image: python:3.10
@@ -95,3 +100,30 @@ jobs:
95100
- name: No Python changes in mlir/
96101
if: steps.changes.outputs.files == ''
97102
run: echo "No changed *.py files under mlir/ – skipping."
103+
104+
python-tests:
105+
name: Python performance script tests
106+
runs-on: ubuntu-latest
107+
container:
108+
image: python:3.10
109+
options: --user root
110+
steps:
111+
- uses: actions/checkout@v4
112+
with:
113+
fetch-depth: 0
114+
115+
- name: Fix git ownership
116+
run: |
117+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
118+
119+
- name: Install dependencies
120+
run: |
121+
python -m pip install --upgrade pip
122+
pip install -r pip_requirements.txt
123+
124+
- name: Run performance script tests (no GPU)
125+
run: |
126+
cd mlir/utils/performance && python -m pytest tests/ -v
127+
env:
128+
# Tests mock HIP/GPU; no ROCm or GPU required
129+
PYTHONPATH: ${{ github.workspace }}/mlir/utils/performance
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: Codecov Report
2+
3+
on:
4+
schedule:
5+
# Runs every Monday at 09:00 UTC.
6+
# The job skips odd ISO weeks so the effective cadence is biweekly.
7+
- cron: '0 9 * * 1'
8+
workflow_dispatch:
9+
10+
jobs:
11+
codecov-teams-report:
12+
name: Codecov coverage report to Teams
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
16+
permissions:
17+
contents: read
18+
19+
steps:
20+
- name: Biweekly gate
21+
id: gate
22+
run: |
23+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
24+
echo "skip=false" >> "$GITHUB_OUTPUT"
25+
echo "Manual trigger — always run."
26+
else
27+
WEEK=$(date +%V)
28+
if [ $((10#$WEEK % 2)) -eq 0 ]; then
29+
echo "skip=false" >> "$GITHUB_OUTPUT"
30+
echo "Even ISO week ($WEEK) — running."
31+
else
32+
echo "skip=true" >> "$GITHUB_OUTPUT"
33+
echo "Odd ISO week ($WEEK) — skipping."
34+
fi
35+
fi
36+
37+
- name: Fetch Codecov data and notify Teams
38+
if: steps.gate.outputs.skip != 'true'
39+
env:
40+
MLIR_TEAM_CONVERSATION: ${{ secrets.MLIR_TEAM_CONVERSATION }}
41+
MLIR_CI_CHANNEL: ${{ secrets.MLIR_CI_CHANNEL }}
42+
run: |
43+
set -euo pipefail
44+
45+
OWNER="ROCm"
46+
REPO="rocMLIR"
47+
API="https://api.codecov.io/api/v2/github/${OWNER}/repos/${REPO}"
48+
49+
# ── 1. Fetch repo-level data from Codecov ─────────────────
50+
echo "::group::Repository coverage"
51+
repo_json=$(curl -sf "$API/") \
52+
|| { echo "::error::Failed to fetch repo data from Codecov API"; exit 1; }
53+
echo "$repo_json" | jq .
54+
echo "::endgroup::"
55+
56+
# ── 2. Parse overall totals ─────────────────────────────────
57+
coverage=$(echo "$repo_json" | jq -r '.totals.coverage // "N/A"')
58+
hits=$(echo "$repo_json" | jq -r '.totals.hits // "N/A"')
59+
lines=$(echo "$repo_json" | jq -r '.totals.lines // "N/A"')
60+
misses=$(echo "$repo_json" | jq -r '.totals.misses // "N/A"')
61+
branches=$(echo "$repo_json" | jq -r '.totals.branches // "N/A"')
62+
echo "Overall line coverage: ${coverage}%"
63+
64+
# ── 3. Determine colour for the headline number ─────────────
65+
cov_color=$(echo "$coverage" | jq -Rr '
66+
(tonumber? // 0) as $v |
67+
if $v >= 70 then "Good"
68+
elif $v >= 50 then "Warning"
69+
else "Attention"
70+
end')
71+
72+
TIMESTAMP=$(date -u '+%Y-%m-%d %H:%M UTC')
73+
CODECOV_URL="https://app.codecov.io/gh/${OWNER}/${REPO}"
74+
RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
75+
76+
# ── 4. Assemble the Adaptive Card ───────────────────────────
77+
payload=$(jq -n \
78+
--arg cov "$coverage" \
79+
--arg cov_color "$cov_color" \
80+
--arg hits "$hits" \
81+
--arg lines "$lines" \
82+
--arg misses "$misses" \
83+
--arg branches "$branches" \
84+
--arg ts "$TIMESTAMP" \
85+
--arg cov_url "$CODECOV_URL" \
86+
--arg run_url "$RUN_URL" \
87+
'{
88+
"attachments": [{
89+
"contentType": "application/vnd.microsoft.card.adaptive",
90+
"content": {
91+
"type": "AdaptiveCard",
92+
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
93+
"version": "1.5",
94+
"body": [
95+
{
96+
"type": "TextBlock",
97+
"text": "Codecov Report 📊",
98+
"weight": "bolder",
99+
"size": "extraLarge",
100+
"separator": true
101+
},
102+
{
103+
"type": "TextBlock",
104+
"text": "rocMLIR — \($ts)",
105+
"isSubtle": true
106+
},
107+
{
108+
"type": "ColumnSet",
109+
"columns": [
110+
{
111+
"type": "Column",
112+
"width": "auto",
113+
"items": [{
114+
"type": "TextBlock",
115+
"text": "\($cov)%",
116+
"size": "extraLarge",
117+
"weight": "bolder",
118+
"color": $cov_color
119+
}]
120+
},
121+
{
122+
"type": "Column",
123+
"width": "stretch",
124+
"items": [
125+
{
126+
"type": "TextBlock",
127+
"text": "Overall Line Coverage",
128+
"weight": "bolder"
129+
},
130+
{
131+
"type": "FactSet",
132+
"facts": [
133+
{"title": "Lines", "value": $lines},
134+
{"title": "Hits", "value": $hits},
135+
{"title": "Misses", "value": $misses},
136+
{"title": "Branches", "value": $branches}
137+
]
138+
}
139+
]
140+
}
141+
]
142+
},
143+
{
144+
"type": "TextBlock",
145+
"text": "Generated: \($ts)",
146+
"size": "small",
147+
"isSubtle": true,
148+
"spacing": "medium"
149+
}
150+
],
151+
"actions": [
152+
{"type": "Action.OpenUrl", "url": $cov_url, "title": "Open Codecov Dashboard 📈"},
153+
{"type": "Action.OpenUrl", "url": $run_url, "title": "View Workflow Run 🔗"}
154+
]
155+
}
156+
}]
157+
}')
158+
159+
echo "::group::Teams payload"
160+
echo "$payload" | jq .
161+
echo "::endgroup::"
162+
163+
# ── 5. POST to each configured Teams webhook ────────────────
164+
send_to_teams() {
165+
local url="$1" label="$2"
166+
if [ -z "$url" ]; then
167+
echo "Skipping ${label} (URL not set)."
168+
return 0
169+
fi
170+
resp=$(curl -s -w '\n%{http_code}' -X POST "$url" \
171+
-H 'Content-Type: application/json; charset=utf-8' \
172+
-d "$payload")
173+
http_code=$(echo "$resp" | tail -1)
174+
body=$(echo "$resp" | sed '$d')
175+
echo "Teams webhook (${label}): HTTP ${http_code}${body:+ body=${body}}"
176+
if [ "$http_code" != "200" ] && [ "$http_code" != "202" ]; then
177+
echo "::warning::Teams notification (${label}) may have failed (expected 200/202, got ${http_code})"
178+
return 1
179+
fi
180+
}
181+
182+
send_to_teams "$MLIR_TEAM_CONVERSATION" "MLIR_TEAM_CONVERSATION"
183+
send_to_teams "$MLIR_CI_CHANNEL" "MLIR_CI_CHANNEL"
184+
echo "Done."

mlir/include/mlir/Conversion/MIGraphXToLinalg/MIGraphXToLinalg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ void populateMIGraphXToLinalgBoundaryDialectConversion(
3939
/// migraphx.mlir.as_logical_shape and migraphx.mlir.as_underlying_shape.
4040
void populateMIGraphXFuncBoundaryToLinalgConversionPatterns(
4141
RewritePatternSet &target, TypeConverter &typeConverter);
42+
43+
/// Populates conversion patterns for function boundaries mhal.launcher
44+
void populateMIGraphXToLinalgMHALLauncherConversion(
45+
RewritePatternSet &target, TypeConverter &typeConverter);
4246
} // namespace migraphx
4347
} // namespace mlir
4448

mlir/include/mlir/Conversion/RocMLIRPasses.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def MIGraphXToLinalgPass : Pass<"migraphx-to-linalg", "::mlir::func::FuncOp"> {
144144
}];
145145

146146
let dependentDialects = ["arith::ArithDialect", "tensor::TensorDialect",
147-
"linalg::LinalgDialect"];
147+
"linalg::LinalgDialect", "rock::RockDialect"];
148148
}
149149

150150
//===----------------------------------------------------------------------===//

mlir/include/mlir/Dialect/MIGraphX/IR/MIGraphX.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def MIGraphX_ErfOp :
162162
let description = [{
163163
compute gauss error function
164164
}];
165+
let arguments = (ins MIXRShapedOf<[AnyFloat]>:$inA);
166+
let results = (outs MIXRShapedOf<[AnyFloat]>:$output);
165167
}
166168
def MIGraphX_ExpOp :
167169
MIGraphX_ElementwiseUnaryOp<"exp">;
@@ -184,6 +186,7 @@ def MIGraphX_SigmoidOp :
184186
let description = [{
185187
Sigmoid function, aka 1 / (1 + exp(-x)).
186188
}];
189+
let hasVerifier = 1;
187190
}
188191
def MIGraphX_SqrtOp :
189192
MIGraphX_ElementwiseUnaryOp<"sqrt">;

mlir/include/mlir/Dialect/Rock/IR/MfmaInsnGroup.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ enum class MfmaTypeId : uint32_t {
3131
Fp8Fp8TyId,
3232
Fp8Bf8TyId,
3333
Bf8Fp8TyId,
34-
Bf8Bf8TyId
34+
Bf8Bf8TyId,
35+
// FP8 via scaled MFMA (uses mfma_scale_f32_16x16x128_f8f6f4 with cbsz=0)
36+
// These provide larger K dimension (128 for 16x16, 64 for 32x32)
37+
Fp8Fp8ScaledTyId,
38+
Fp8Bf8ScaledTyId,
39+
Bf8Fp8ScaledTyId,
40+
Bf8Bf8ScaledTyId
3541
};
3642

3743
struct MfmaInsnInfo {
@@ -71,7 +77,8 @@ class MfmaInsn {
7177
MfmaInsnAttr getAttr() const;
7278
Type getArgTypeFor(Type elementTypeA);
7379
VectorType getRetType(Type elementType);
74-
bool isCoherentWithK(int64_t kPack, int64_t kPerBlock);
80+
bool isCoherentWithK(int64_t kPack, int64_t kPerBlock,
81+
int64_t scheduleVersion);
7582
};
7683

7784
template <typename T>
@@ -138,7 +145,8 @@ class MfmaInsnGroup {
138145
public:
139146
static FailureOr<MfmaInsnGroup> select(Type elementTypeA, Type elementTypeB,
140147
StringRef arch, int64_t mnPerXdl,
141-
int64_t kPack, int64_t kPackPerBlock);
148+
int64_t kPack, int64_t kPackPerBlock,
149+
int64_t scheduleVersion);
142150
MfmaInsnGroup(Type elementTypeA, Type elementTypeB, const MfmaInsn &insn,
143151
const MfmaInsnGroupAttr &groupAttr);
144152
int64_t getMRepeats(int64_t mPerWave);
@@ -150,8 +158,13 @@ class MfmaInsnGroup {
150158
Type getArgTypeA();
151159
Type getArgTypeB();
152160
VectorType getRetType();
153-
bool isCoherentWithK(int64_t kPack, int64_t kPerBlock);
161+
bool isCoherentWithK(int64_t kPack, int64_t kPerBlock,
162+
int64_t scheduleVersion);
154163
SmallString<16> getROCDLIntrinsicName() { return groupAttr.insn; }
164+
165+
// Check if this is FP8 using scaled MFMA (mfma_scale with cbsz=0, blgp=0)
166+
// These instructions have larger K dimension (128 for 16x16, 64 for 32x32)
167+
bool isScaledFp8() const;
155168
};
156169

157170
} // namespace rock

mlir/include/mlir/Dialect/Rock/IR/RockAttrDefs.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ def ConvOpBwdWeightType : I32EnumAttrCase<"BwdWeight", 2, "conv_bwd_weight">;
5959
def ConvOpTypes : Rock_I32Enum<"ConvOpType", "The type of a convolution operation",
6060
[ConvOpType, ConvOpBwdDataType, ConvOpBwdWeightType]>;
6161

62+
/// LinalgConvType
63+
def LinalgConv_1D : I32EnumAttrCase<"Conv1dNgchGkch", 0, "conv1d_ngch_gkch">;
64+
def LinalgConv_2D
65+
: I32EnumAttrCase<"Conv2dNgchwGkchw", 1, "conv2d_ngchw_gkchw">;
66+
def LinalgConv_3D
67+
: I32EnumAttrCase<"Conv3dNgchwdGkchwd", 2, "conv3d_ngchwd_gkchwd">;
68+
69+
def LinalgConvType
70+
: Rock_I32Enum<"LinalgConvType",
71+
"Hints for the linalg.generic convolution ops used by "
72+
"linalg-to-rock lowering",
73+
[LinalgConv_1D, LinalgConv_2D, LinalgConv_3D]>;
74+
75+
def LinalgConvTypeAttr
76+
: EnumAttr<Rock_Dialect, LinalgConvType, "LinalgConvType">;
77+
6278
/// Kerneltype
6379
def KernelTypeConv : I32EnumAttrCase<"Conv", 0>;
6480
def KernelTypeConvBwdData : I32EnumAttrCase<"ConvBwdData", 1>;

mlir/include/mlir/Dialect/Rock/Passes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace rock {
4242
#define GEN_PASS_DECL_ROCKVIEWTOTRANSFORMPASS
4343
#define GEN_PASS_DECL_ROCKDETECTFLASHDECODINGPASS
4444
#define GEN_PASS_DECL_ROCKLOWERREDUCEPASS
45+
#define GEN_PASS_DECL_ROCKREMOVEREDUNDANTCASTSPASS
4546
#define GEN_PASS_DECL_ROCKPREPARELLVMPASS
4647
#define GEN_PASS_DECL_ROCKCHECKRESIDENCYPASS
4748
#define GEN_PASS_DECL_ROCKVECTORIZEFUSIONSPASS

mlir/include/mlir/Dialect/Rock/Passes.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,20 @@ def RockLowerReducePass : Pass<"rock-lower-reduce", "::mlir::func::FuncOp"> {
182182
let dependentDialects = ["rock::RockDialect", "func::FuncDialect", "gpu::GPUDialect"];
183183
}
184184

185+
def RockRemoveRedundantCastsPass
186+
: Pass<"rock-remove-redundant-casts", "::mlir::LLVM::LLVMFuncOp"> {
187+
let summary = "Remove redundant fptrunc/fpext pairs through buffers at LLVM "
188+
"dialect level";
189+
let description = [{
190+
Detects patterns at the LLVM dialect level where wider float values are
191+
truncated (llvm.fptrunc) to a narrower type, stored to a buffer, then loaded
192+
and extended (llvm.fpext) back to the original wider type. This pass
193+
redirects the loads to read the wide values directly, eliminating the
194+
fpext and preserving precision.
195+
}];
196+
let dependentDialects = ["LLVM::LLVMDialect"];
197+
}
198+
185199
def RockPrepareLLVMPass : Pass<"rock-prepare-llvm", "::mlir::LLVM::LLVMFuncOp"> {
186200
let summary = "prepare the generated code for llvm";
187201
let dependentDialects = ["ROCDL::ROCDLDialect"];

0 commit comments

Comments
 (0)