Skip to content

Commit 7dfa665

Browse files
caustenTedThemistokleouslakhinderwaliakahmed10CharlieL7
authored
[7.1] bulk merge (#4358)
* Update build and test script and dockerfile to add in onnxrt pai laun… (#4336) Update build and test script and dockerfile to add in onnxrt pai launcher scripts Push pai launcher scripts to Onnxrutime to let us reuse scripts from prior run Related to change from - #4321 * Bump SQlite3 to 3.50.4 (#4322) * TopK exception bugfix (#4329) * Use --input-dim for specifying dynamic shapes at driver runtime (#4342) * Add video and render groups in docker for CI (#4340) * Fix MXFP4 bugs (#4324) * propagate_constant ignores `unpack_fp4` instructions now * `match_find_mx_quantizable_ops` from `simplify_qdq` updated to not require non-constant scales. The scales can be literals. * transpose, reshape, and broadcast instructions propagated on scale instructions when going to `quant_dot` and `quant_conv` * `raw_data` `operator<<` updated to use `fallback_visit` to also handle non-computable types * Brevitas MXFP4 quantization parse (#4301) * Bump onnx to 1.18.0 (#4323) * Fuse GEMM+GEMM with rocMLIR (#4261) rocmlir supports GEMM+GEMM fusion, so MIGraphX needs to support the fusion on our side. Solves #4230 * Updated SD3 example for change in optimum-onnx[onnxruntime] (#4344) * Lower lrn to pooling (#4294) This PR implements a lowering transformation that converts LRN operations into a series of pooling and arithmetic operations. * Update onnxruntime main be655f69f6c8623eebcac094626d0c8545951e6d (#4348) * Update docs/reference/MIGraphX-dev-env-vars.rst --------- Co-authored-by: Ted Themistokleous <[email protected]> Co-authored-by: Lakhinder Walia <[email protected]> Co-authored-by: kahmed10 <[email protected]> Co-authored-by: Charlie Lin <[email protected]> Co-authored-by: Breanna Devore-McDonald <[email protected]> Co-authored-by: Aarushi Jain <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1561215 commit 7dfa665

Some content is hidden

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

42 files changed

+2244
-60
lines changed

Jenkinsfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def rocmtestnode(Map conf) {
3939
export MIGRAPHX_GPU_DEBUG=${gpu_debug}
4040
export CXX=${compiler}
4141
export CXXFLAGS='-Werror'
42+
rocminfo
4243
env
4344
rm -rf build
4445
mkdir build
@@ -66,12 +67,18 @@ def rocmtestnode(Map conf) {
6667
checkout scm
6768
}
6869

70+
def video_id = sh(returnStdout: true, script: 'getent group video | cut -d: -f3').trim()
71+
def render_id = sh(returnStdout: true, script: 'getent group render | cut -d: -f3').trim()
72+
def docker_opts = "--device=/dev/kfd --device=/dev/dri --cap-add SYS_PTRACE -v=${env.WORKSPACE}/../:/workspaces:rw,z"
73+
docker_opts = docker_opts + " --group-add=${video_id} --group-add=${render_id} "
74+
echo "Docker flags: ${docker_opts}"
75+
6976
gitStatusWrapper(credentialsId: "${env.migraphx_ci_creds}", gitHubContext: "Jenkins - ${variant}", account: 'ROCmSoftwarePlatform', repo: 'AMDMIGraphX') {
7077
withCredentials([usernamePassword(credentialsId: 'docker_test_cred', passwordVariable: 'DOCKERHUB_PASS', usernameVariable: 'DOCKERHUB_USER')]) {
7178
sh "echo $DOCKERHUB_PASS | docker login --username $DOCKERHUB_USER --password-stdin"
7279
pre()
7380
sh "docker pull ${DOCKER_IMAGE}:${env.IMAGE_TAG}"
74-
withDockerContainer(image: "${DOCKER_IMAGE}:${env.IMAGE_TAG}", args: "--device=/dev/kfd --device=/dev/dri --group-add video --cap-add SYS_PTRACE -v=${env.WORKSPACE}/../:/workspaces:rw,z ${docker_args}") {
81+
withDockerContainer(image: "${DOCKER_IMAGE}:${env.IMAGE_TAG}", args: docker_opts + docker_args) {
7582
timeout(time: 4, unit: 'HOURS') {
7683
body(cmake_build)
7784
}
@@ -192,7 +199,7 @@ rocmtest clang_debug: rocmnode('mi200+') { cmake_build ->
192199
}
193200
}, mlir_debug: rocmnode('mi100+') { cmake_build ->
194201
stage('MLIR Debug') {
195-
withEnv(['MIGRAPHX_ENABLE_EXTRA_MLIR=1', 'MIGRAPHX_MLIR_USE_SPECIFIC_OPS=fused,attention,convolution,dot,convolution_backwards', 'MIGRAPHX_ENABLE_MLIR_INPUT_FUSION=1', 'MIGRAPHX_MLIR_ENABLE_SPLITK=1', 'MIGRAPHX_ENABLE_MLIR_REDUCE_FUSION=1', 'MIGRAPHX_ENABLE_SPLIT_REDUCE=1','MIGRAPHX_DISABLE_LAYERNORM_FUSION=1']) {
202+
withEnv(['MIGRAPHX_ENABLE_EXTRA_MLIR=1', 'MIGRAPHX_MLIR_USE_SPECIFIC_OPS=fused,attention,convolution,dot,convolution_backwards', 'MIGRAPHX_ENABLE_MLIR_INPUT_FUSION=1', 'MIGRAPHX_MLIR_ENABLE_SPLITK=1', 'MIGRAPHX_ENABLE_MLIR_REDUCE_FUSION=1', 'MIGRAPHX_ENABLE_MLIR_GEG_FUSION=1', 'MIGRAPHX_ENABLE_SPLIT_REDUCE=1','MIGRAPHX_DISABLE_LAYERNORM_FUSION=1']) {
196203
def sanitizers = "undefined"
197204
// Note: the -fno-sanitize= is copied from upstream LLVM_UBSAN_FLAGS.
198205
def debug_flags = "-g -O2 -fsanitize=${sanitizers} -fno-sanitize=vptr,function -fno-sanitize-recover=${sanitizers}"

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323
#####################################################################################
24-
ROCmSoftwarePlatform/rocm-recipes
24+
ROCm/rocm-recipes
2525
facebook/[email protected] -X subdir -DCMAKE_DIR=build/cmake
2626
[email protected] -DENABLE_TESTING=OFF
2727
pcre,pfultz2/[email protected] -H sha256:d6f7182602a775a7d500a0cedca6449af0400c6493951513046d17615ed0bf11

docs/reference/MIGraphX-dev-env-vars.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ Model performance tunable variables change the compilation behavior of a model.
144144
145145
| Default: Reduction fusions are turned off.
146146
147+
* - | ``MIGRAPHX_ENABLE_MLIR_GEG_FUSION``
148+
| Turns on GEMM+GEMM fusions in MLIR.
149+
150+
- | ``1``: Turns on G+G fusions.
151+
| ``0``: Returns to default behavior.
152+
153+
| Default: GEMM+GEMM fusions are turned off.
154+
147155
* - | ``MIGRAPHX_MLIR_ENABLE_SPLITK``
148156
| Turns on Split-k performance configurations during MLIR tuning.
149157
@@ -213,6 +221,14 @@ Model performance tunable variables change the compilation behavior of a model.
213221
214222
| Default: No tuning is done for composable kernels.
215223
224+
* - | ``MIGRAPHX_REWRITE_LRN``
225+
| Turns on LRN-to-pooling lowering in the ``rewrite_pooling`` pass.
226+
227+
228+
- | ``1``: Turns on LRN-to-pooling lowering.
229+
| ``0``: Returns to default behavior.
230+
231+
| Default: LRN-to-pooling lowering is turned off.
216232
217233
Matching
218234
**********

examples/diffusion/python_stable_diffusion_3/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ python3 -m venv sd_venv
1717
Install dependencies
1818

1919
```bash
20+
pip install --upgrade pip
2021
pip install -r torch_requirements.txt
2122
pip install -r requirements.txt
2223
```
@@ -37,7 +38,7 @@ huggingface-cli login
3738
Export the models to onnx.
3839
Currently, optimum does not have the changes required in their latest release. Please install from their development branch instead.
3940
```bash
40-
python -m pip install optimum[onnxruntime]@git+https://github.com/huggingface/optimum.git
41+
pip install "optimum-onnx[onnxruntime]"@git+https://github.com/huggingface/optimum-onnx.git
4142
```
4243

4344
Once optimum is built, use the following command to export the models:

rbuild.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
cxx = ${rocm_path}/llvm/bin/clang++
33
cc = ${rocm_path}/llvm/bin/clang
44
deps =
5-
ROCmSoftwarePlatform/rocm-recipes
5+
ROCm/rocm-recipes
66
-f requirements.txt
77

88
[gh]
99
ignore =
1010
danmar/cppcheck
11-
ROCmSoftwarePlatform/rocMLIR
11+
ROCm/rocMLIR
1212
deps =
1313
-f dev-requirements.txt
1414
oneapi-src/[email protected]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ nlohmann/[email protected] -DCMAKE_POLICY_VERSION_MINIMUM=3.5
2727
2828
pybind/pybind11@3e9dfa2866941655c56877882565e7577de6fc7b --build
2929
msgpack/[email protected] -DMSGPACK_BUILD_TESTS=Off -DMSGPACK_BUILD_EXAMPLES=Off -DCMAKE_POLICY_VERSION_MINIMUM=3.5
30-
sqlite3@3.43.2 -DCMAKE_POSITION_INDEPENDENT_CODE=On
30+
sqlite3@3.50.4 -DCMAKE_POSITION_INDEPENDENT_CODE=On
3131
ROCm/composable_kernel@b7775add2d28251674d81e220cd4a857b90b997a -DCK_BUILD_JIT_LIB=On -DCMAKE_POSITION_INDEPENDENT_CODE=On
3232
ROCm/rocMLIR@33b0fc534532f8e8cb7bec2b5f7d20a69be2def5 -DBUILD_FAT_LIBROCKCOMPILER=On -DLLVM_INCLUDE_TESTS=Off

src/driver/main.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
#include <iomanip>
6565

6666
namespace {
67+
68+
using dims_map = std::unordered_map<std::string, std::vector<std::size_t>>;
69+
6770
std::vector<std::string>
6871
get_unrecognized_migraphx_envs(const char* envp[],
6972
const std::map<std::string, std::string>& used_env)
@@ -213,7 +216,7 @@ struct loader
213216

214217
static auto parse_param_dims(const std::vector<std::string>& param_dims_info)
215218
{
216-
std::unordered_map<std::string, std::vector<std::size_t>> map_input_dims;
219+
dims_map map_input_dims;
217220
std::string name = "";
218221
for(auto&& x : param_dims_info)
219222
{
@@ -502,16 +505,24 @@ struct program_params
502505
return map_load_args;
503506
}
504507

505-
auto generate(const program& p, const target& t, bool offload, unsigned batch)
508+
auto generate(const program& p,
509+
const target& t,
510+
bool offload,
511+
unsigned batch,
512+
dims_map map_input_dims = {})
506513
{
507514
parameter_map m;
508515
auto param_shapes = p.get_parameter_shapes();
509516
std::unordered_map<std::string, shape> static_param_shapes;
510-
std::transform(
511-
param_shapes.cbegin(),
512-
param_shapes.cend(),
513-
std::inserter(static_param_shapes, static_param_shapes.end()),
514-
[&](const auto& x) { return std::make_pair(x.first, x.second.to_static(batch)); });
517+
for(auto&& param : param_shapes)
518+
{
519+
if(contains(map_input_dims, param.first))
520+
static_param_shapes[param.first] = {param.second.type(),
521+
map_input_dims[param.first]};
522+
else
523+
static_param_shapes[param.first] = param.second.to_static(batch);
524+
}
525+
515526
for(auto&& s : fill0)
516527
m[s] = fill_argument(static_param_shapes.at(s), 0);
517528
for(auto&& s : fill1)
@@ -591,7 +602,8 @@ struct compiler
591602

592603
auto params(const program& p)
593604
{
594-
return parameters.generate(p, ct.get_target(), co.offload_copy, l.batch);
605+
return parameters.generate(
606+
p, ct.get_target(), co.offload_copy, l.batch, loader::parse_param_dims(l.param_dims));
595607
}
596608

597609
auto host_params(const program& p)
@@ -730,7 +742,8 @@ struct verify : command<verify>
730742
std::cout << p << std::endl;
731743

732744
auto t = c.ct.get_target();
733-
auto m = c.parameters.generate(p, t, true, c.l.batch);
745+
auto m =
746+
c.parameters.generate(p, t, true, c.l.batch, loader::parse_param_dims(c.l.param_dims));
734747

735748
if(c.to_fp16)
736749
{

src/include/migraphx/module.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ struct MIGRAPHX_EXPORT module
339339
ins_dep_map calc_implicit_deps() const;
340340

341341
void repeat_while_changes(std::size_t n, const std::function<void()>& f);
342+
void localized_sort(instruction_ref start_ins, instruction_ref end_ins);
342343

343344
MIGRAPHX_EXPORT friend std::ostream& operator<<(std::ostream& os, const module& m);
344345
MIGRAPHX_EXPORT friend bool operator==(const module& x, const module& y);

src/include/migraphx/raw_data.hpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ struct raw_data : raw_data_base
5353
friend Stream& operator<<(Stream& os, const Derived& d)
5454
{
5555
if(not d.empty())
56-
d.visit([&](auto x) { os << x; },
57-
[&](auto&& xs) {
58-
for(auto&& x : xs)
59-
{
60-
os << "{ ";
61-
os << x;
62-
os << " }, ";
63-
}
64-
});
56+
d.fallback_visit([&](auto x) { os << x; },
57+
[&](auto&& xs) {
58+
for(auto&& x : xs)
59+
{
60+
os << "{ ";
61+
os << x;
62+
os << " }, ";
63+
}
64+
});
6565
return os;
6666
}
6767

@@ -123,9 +123,13 @@ struct raw_data : raw_data_base
123123
}
124124
else
125125
{
126-
auto&& buffer = static_cast<const Derived&>(*this).data();
126+
auto* buffer = static_cast<const Derived&>(*this).data();
127127
shape view_shape = {shape::uint8_type, {s.bytes()}};
128-
v(make_view(view_shape, reinterpret_cast<byte*>(buffer)));
128+
using byte_type =
129+
std::conditional_t<std::is_const<std::remove_pointer_t<decltype(buffer)>>{},
130+
const byte*,
131+
byte*>;
132+
v(make_view(view_shape, reinterpret_cast<byte_type>(buffer)));
129133
}
130134
}
131135

src/include/migraphx/rewrite_pooling.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
4+
* Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -38,6 +38,7 @@ struct module;
3838
*/
3939
struct MIGRAPHX_EXPORT rewrite_pooling
4040
{
41+
bool rewrite_lrn = false;
4142
std::string name() const { return "rewrite_pooling"; }
4243
void apply(module& m) const;
4344
};

0 commit comments

Comments
 (0)