Skip to content

Gpu concat kernel improvements - #5175

Draft
pfultz2 wants to merge 46 commits into
developfrom
concat-group2
Draft

Gpu concat kernel improvements#5175
pfultz2 wants to merge 46 commits into
developfrom
concat-group2

Conversation

@pfultz2

@pfultz2 pfultz2 commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Technical Details

Changelog Category

Add a CHANGELOG.md entry for any option other than Not Applicable

    • Added: New functionality.
    • Changed: Changes to existing functionality.
    • Removed: Functionality or support that has been removed. (Compared to a previous release)
    • Optimized: Component performance that has been optimized or improved.
    • Resolved Issues: Known issues from a previous version that have been resolved.
    • Not Applicable: This PR is not to be included in the changelog.

Follow the LLVM AI Tool Use Policy for contributions using AI.

@gh-app-migraphx-bot-pr-write

Copy link
Copy Markdown
Test Batch New Rate (427a56) Old Rate (3a503c)* Diff Status
torchvision-resnet50 64 3,322.59 3,264.92 1.77%
torchvision-resnet50_fp16 64 7,865.89 7,548.67 4.20%
torchvision-densenet121 32 2,487.43 2,483.99 0.14%
torchvision-densenet121_fp16 32 5,016.22 5,004.24 0.24%
torchvision-inceptionv3 32 2,070.05 2,058.51 0.56%
torchvision-inceptionv3_fp16 32 4,450.91 4,416.99 0.77%
cadene-inceptionv4 16 816.11 820.61 -0.55%
cadene-resnext64x4 16 783.26 782.78 0.06%
slim-mobilenet 64 8,424.67 8,386.36 0.46%
slim-nasnetalarge 64 229.08 228.86 0.10%
slim-resnet50v2 64 3,238.29 3,180.91 1.80%
bert-mrpc-onnx 8 1,168.25 1,168.84 -0.05%
bert-mrpc-tf 1 495.41 498.63 -0.65%
pytorch-examples-wlang-gru 1 376.22 473.35 -20.52% 🔴
pytorch-examples-wlang-lstm 1 554.85 384.83 44.18% 🔆
torchvision-resnet50_1 1 1,054.02 1,046.63 0.71%
cadene-dpn92_1 1 450.50 437.32 3.01%
cadene-resnext101_1 1 364.90 365.89 -0.27%
onnx-taau-downsample 1 847.86 844.09 0.45%
dlrm-criteoterabyte 1 32.21 32.42 -0.63%
dlrm-criteoterabyte_fp16 1 51.93 51.80 0.24%
agentmodel 1 14,620.20 9,209.12 58.76% 🔆
unet_fp16 2 58.39 58.80 -0.70%
resnet50v1_fp16 1 1,445.22 1,366.11 5.79% 🔆
resnet50v1_int8 1 1,783.43 1,883.96 -5.34% 🔴
bert_base_cased_fp16 64 1,099.03 1,098.16 0.08%
bert_large_uncased_fp16 32 345.48 345.59 -0.03%
bert_large_fp16 1 208.28 206.59 0.82%
distilgpt2_fp16 16 2,095.07 2,092.89 0.10%
yolov5s 1 564.79 558.33 1.16%
tinyllama 1 nan 45.83 nan
vicuna-fastchat 1 44.12 44.20 -0.19%
whisper-tiny-encoder 1 412.78 411.87 0.22%
whisper-tiny-decoder 1 413.93 408.48 1.33%
llama2_7b 1 20.83 20.84 -0.03%
qwen1.5-7b 1 23.59 23.58 0.03%
phi3-3.8b 1 27.70 26.72 3.67%
llama3-8b 1 22.55 21.80 3.41%
whisper-large-encoder 1 10.17 10.18 -0.10%
whisper-large-decoder 1 105.06 105.30 -0.22%
mistral-7b 1 23.61 23.78 -0.72%
FLUX.1-schnell 1 771.58 755.22 2.17%

Regressions detected 🔴

* No develop baseline was found for this PR's branch point; compared against the latest available develop run instead.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes GPU concat for small, equal-width fast-axis inputs using an LDS-backed tiled kernel, with supporting kernel utilities and tests.

Changes:

  • Adds tiled concat selection and execution.
  • Extends kernel indexing, shape, debug, and preprocessor utilities.
  • Expands GPU kernel and concat verification coverage.

Review performed as a single pass without agent fan-out.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/reduce_dims.cpp Enables reduction across differing fast dimensions.
src/targets/gpu/compile_gen.cpp Exposes tile-factor computation.
src/targets/gpu/include/migraphx/gpu/compile_gen.hpp Declares the tile-factor helper.
src/targets/gpu/jit/concat.cpp Selects and launches tiled concat.
src/targets/gpu/kernels/include/migraphx/kernels/concat.hpp Implements tiled and simple concat algorithms.
src/targets/gpu/kernels/include/migraphx/kernels/debug.hpp Supports multi-argument source-location capture.
src/targets/gpu/kernels/include/migraphx/kernels/functional.hpp Reorders helpers and simplifies arg_c<0>.
src/targets/gpu/kernels/include/migraphx/kernels/index.hpp Adds ceiling group counts and block-stride traversal.
src/targets/gpu/kernels/include/migraphx/kernels/pp.hpp Extends recursive preprocessor utilities.
src/targets/gpu/kernels/include/migraphx/kernels/reduce.hpp Adapts reduction to the revised repeat macro.
src/targets/gpu/kernels/include/migraphx/kernels/shape.hpp Asserts nonempty kernel shapes.
src/targets/gpu/kernels/include/migraphx/kernels/tensor_view.hpp Adds multidimensional index construction.
src/targets/gpu/kernels/include/migraphx/kernels/test.hpp Adds templated kernel-test macros.
test/gpu/compile_gen.cpp Tests tile-factor behavior.
test/gpu/kernels/functional.cpp Adds device functional-utility tests.
test/gpu/kernels/index.cpp Tests block-stride traversal.
test/gpu/kernels/main.cpp Discovers templated kernel tests.
test/gpu/kernels/pp.cpp Adds device preprocessor tests.
test/gpu/kernels/shape.cpp Adds device shape tests.
test/reduce_dims.cpp Covers differing fast dimensions.
test/verify/test_concat_axis_neg_1.cpp Exercises varied concat sizes and types.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/reduce_dims.cpp
Comment on lines +124 to +127
std::transform(is.begin(), is.end(), rstrides.begin(), [&](auto i) -> std::size_t {
if(lens[i] == s.lens()[i])
{
rstrides[i] = stride;
stride *= lens[i];
}
else if(lens[i] != 1 and s.lens()[i] != 1)
{
return shape{};
}
}
return base.strides()[i];
return 0;
Comment on lines +132 to +133
if(concat_axis == axis and max_elements_per_op < 64 and
max_elements_per_op == avg_elements_per_op)
#endif

constexpr auto ngroup() const { return nglobal() / max_nlocal(); }
constexpr auto ngroup() const { return (nglobal() + max_nlocal() - _c<1>) / max_nlocal(); }
Comment thread test/gpu/kernels/main.cpp
Comment on lines +43 to +44
// The name may be a template-id, so it can contain spaces and commas
// (`TEST_CASE_REGISTER(foo<unsigned long, int>)`); trim what that lets in trailing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants