Commit Graph

101 Commits

Author SHA1 Message Date
Ville Pietilä
f74e034ae9 Adapt factories to warp GEMM and transfer parameters refactoring. 2026-01-09 09:17:45 -05:00
Ville Pietilä
1abe9ab6c9 Merge branch 'vpietila/ckb-bwd-weight-factories' into vpietila/ckb-refactor-warp-gemm-descriptors 2026-01-08 06:55:01 -05:00
Ville Pietilä
6c41727997 Merge remote-tracking branch 'origin/develop' into vpietila/ckb-bwd-weight-factories 2026-01-08 05:12:35 -05:00
Robin Voetter
e3884bbf05 [CK_BUILDER] Debug utilities (#3528)
* ck-builder: make toString to_string

We are using snake case for CK-Builder

* ck-builder: add debug.hpp with tensor descriptor printing function

This adds some initial functionality to debug.hpp, a header which will
be used to house some debug utilities.

* ck-builder: abstract nd-iteration

Abstracting this makes it easier to test, clearer, and allows us to
use it elsewhere (such as in debug.hpp soon)

* ck-builder: tensor printing

* ck-builder: rename INT32 to I32

This makes it more in line with the other data type definitions.
2026-01-08 10:14:13 +01:00
Ville Pietilä
7b3aca7878 Merge remote-tracking branch 'origin/vpietila/ckb-bwd-weight-factories' into vpietila/ckb-refactor-warp-gemm-descriptors 2026-01-07 06:16:43 -05:00
Ville Pietilä
d107b851c1 Merge branch 'develop' into vpietila/ckb-bwd-weight-factories 2026-01-07 02:43:24 -08:00
Ville Pietilä
c5cdd51ce4 Fix factory for regular WMMA conv bwd weight. 2026-01-07 05:41:22 -05:00
Ville Pietilä
37e9547a29 Fix ref algorithm dispatching. 2026-01-07 03:56:50 -05:00
Robin Voetter
1c433c64ec [CK_BUILDER] Integrate reference conv with testing (#3511)
* ck-builder: explicitly delete forward declarations

Before, these functions were seen as a forward declaration for an existing function.
If no actual implementation overload could be found, these would be selected and
a linker error or warning would be generated. By marking these functions as explicitly
deleted, they incorrect invocations are generated as compile error instead.

* ck-builder: ckt::run plumbing for reference conv

This implements the ckt::run plumbing for the reference convolution
implementation and sets up the first complete end-to-end test.

* ck-builder: make validation system check for all-zeros

When both the actual and reference output are both all zero bits,
there is probably something wrong in the test framework.

* ck-builder: proper implementation+tests for TensorDescriptor::is_packed

* ck-builder: fix typos
2026-01-06 09:29:06 +01:00
Ville Pietilä
02243cabe6 Merge branch 'develop' into vpietila/ckb-bwd-weight-factories 2026-01-05 07:07:01 -08:00
Ville Pietilä
5f639559a1 WIP: Unify warp GEMM and thread distribution descriptions. 2026-01-05 09:52:46 -05:00
Robin Voetter
e6e7dc2910 [CK_BUILDER] validation (#3471)
This pull request builds on #3267 by proving the "validation" infrastructure, the means to compare a set of `Outputs`.

The design of the validation infrastructure is relatively straight forward:
- Each SIGNATURE should come with a `validate()` implementation, which should be implemented in a similar way that the other functions/types from `testing.hpp` are implemented.
- `validate()` returns a `ValidationReport`, which is a structure that keeps all relevant information about comparing the tensors from two `Outputs`. Note that crucially, `validate()` should not do any reporting by itself. Rather, glue logic should be implemented by the user to turn `ValidationReport` into a relevant error message.
- You can see this clue code for CK-Builder itself in `testing_utils.hpp`, its `MatchesReference()`. This functionality is relatively barebones right now, it will be expanded upon in a different PR to keep the scope of this one down.

The comparison is done on the GPU (using an atomic for now), to keep tests relatively quick. Some notable items from this PR:
- To help compare the tensors and with writing tests, I've written a generic function `tensor_foreach` which invokes a callback on every element of a tensor.
- For that it was useful that the `TensorDescriptor` has a rank which is known at compile-time, so I've changed the implementation of `TensorDescriptor` for that. I felt like it was a better approach than keeping it dynamic, for multiple reasons:
  - This is C++ and we should use static typing where possible and useful. This way, we don't have to implement runtime assertions about the tensor rank.
  - We know already know the rank of tensors statically, as it can be derived from the SIGNATURE.
  - It simpifies the implementation of `tensor_foreach` and other comparison code.
- There are a lot of new tests for validating the validation implementation, validating validation validation tests (Only 3 recursive levels though...). For a few of those functions, I felt like it would be useful to expose them to the user.
- Doc comments everywhere.
2026-01-05 04:57:34 -08:00
Ville Pietilä
201039646e Move compile-time diagnostics to a separate branch. 2026-01-05 05:32:09 -05:00
Ville Pietilä
881bf916fe clang-format 2026-01-05 04:45:51 -05:00
Ville Pietilä
829eabed3a Fix fwd factories after refactoring. 2026-01-05 04:42:31 -05:00
Ville Pietilä
1dcea1825f Fix DeviceGroupedConvBwdWeightMultipleD_Wmma_CShuffleV3 factory and compute types for input and output tensor in bwd weigth convs. 2026-01-05 03:09:22 -05:00
Max Podkorytov
e339101e9c [CK-Tile] move out memory operation from cshuffle epilogue class (#3359)
* initial poc

* factor out common parts in operator()

* cv4

* rest of the universal gemm pipelines

* fix test

* remove boilerplate from tile engine

* fix example

* fix example

* format

* fix tests build for gemm

* remove base pipeline codegen from gemm instance builder

* unify v3 logic with the rest of universal gemm pipelines

* fix build for multi abd test

* fix test gemm multi d

* fix build for weight preshuffle

* fix grouped gemm test

* fix grouped gemm multi d test

* fix grouped gemm preshuffle

* fix grouped gemm example except for quant

* fix gemm preshuffle

* fix splitk 2 stage example

* fix batched gemm example

* fix multid example

* fix multiabd example

* fix batched gemm test

* fixup

* fix examples build

* fix grouped gemm test build

* fix smoke builder

* hacky poc

* fix tile engine

* kill the lambda

* maybe fix test build

* more fixes

* clang-format

* save temp

* clang-format

* mostly fix examples

* clang-format

* remove dead code

* more cleanup

* fix fmha bwd build (default epilogue set/add appears to be broken)

* fix default epilogue tests but not correctness

* clang-format

* fix bquant

* clang-format

* cleanup dead code

* rearrange make windows for readability

* restore changes to IsSupportedArgument

* fix smoke-builder

* clang-format

* fixup rename class

* build fixes

* clang-format

* fix builder

* fixup

* remove set from builder tests

* fix test

* clang-format

* re-refactor the kernels

* clang-format

* fix header license

* remove memory operation from conv bwd test

* clang-format

* clang-format example,include

* clang-format test

* build fixes

* clang-format

* solve compilation error

* fix the CI

* solve compilation error

* clang format

* solve merge conflict

* solve merge conflict

* solve the gfx11 error

* solve test error

* moar build fixes

* remove AtomicAddRequiresKBatchGreaterThanOne test since the property is removed from the kernel scope

---------

Co-authored-by: Thomas Ning <Thomas.Ning@amd.com>
2026-01-04 03:28:14 -08:00
Ville Pietilä
4eea42c5b7 Add factory for DeviceGroupedConvBwdWeightMultipleD_Wmma_CShuffleV3 2026-01-02 09:52:52 -05:00
Ville Pietilä
c3a9044bad Dispatching for DeviceGroupedConvBwdWeightMultipleD_Wmma_CShuffle. 2026-01-02 09:25:38 -05:00
Ville Pietilä
1759db7250 Factory and tests for DeviceGroupedConvBwdWeight_Wmma_CShuffle. 2026-01-02 08:52:38 -05:00
Ville Pietilä
aa10d659b7 Added factory and tests for DeviceGroupedConvBwdWeightTwoStage_Wmma_CShuffleV3. 2026-01-02 07:51:40 -05:00
Ville Pietilä
bc3cba873b Add factory and tests for DeviceGroupedConvBwdWeight_Wmma_CShuffleV3. 2026-01-02 06:08:29 -05:00
Ville Pietilä
d045923a0d Refactor large tensor support and WMMA configuration. 2026-01-02 05:12:19 -05:00
Ville Pietilä
09e188f2a8 Treat ref algorithm the same way as real algorithms in the dispatcher. 2026-01-02 02:28:05 -05:00
Ville Pietilä
5be1ed65fb Merge remote-tracking branch 'origin/develop' into vpietila/ckb-bwd-weight-factories 2026-01-02 02:15:24 -05:00
Ville Pietilä
6e8c401e33 [CK_BUILDER] Instance traits for conv bwd weight algorithms (#3498)
Added instance traits for the following bwd weight conv algorithms

DeviceGroupedConvBwdWeight_Xdl_CShuffleV3
DeviceGroupedConvBwdWeight_Wmma_CShuffleV3
DeviceGroupedConvBwdWeight_Wmma_CShuffle
DeviceGroupedConvBwdWeight_TwoStage_Xdl_CShuffle
DeviceGroupedConvBwdWeight_TwoStage_Wmma_CShuffleV3
DeviceGroupedConvBwdWeight_DL
DeviceGroupedConvBwdWeightMultipleD_Xdl_CShuffle
DeviceGroupedConvBwdWeightMultipleD_Wmma_CShuffleV3
Added also unit tests for instance traits of those bwd weigth algorithms that are currently exposed by the narrow CK build for MIOpen.
---------

Co-authored-by: Ville Pietilä <>
2025-12-31 15:41:15 -08:00
Ville Pietilä
fba80401d1 Add factory for DeviceGroupedConvBwdWeightMultipleD_Xdl_CShuffle 2025-12-31 09:32:58 -05:00
Ville Pietilä
83be9c740c Add test for creating DeviceGroupedConvBwdWeightMultipleD_Xdl_CShuffle instance. 2025-12-31 09:08:06 -05:00
Ville Pietilä
3b0777f629 Conv bwd weight DL factory. 2025-12-31 07:38:52 -05:00
Ville Pietilä
75710202ab Added factory for DeviceGroupedConvBwdWeightTwoStage_Xdl_CShuffle. 2025-12-31 04:32:28 -05:00
kabrahamAMD
f86bbb1aef [CK_Builder] [testing] Integrate device random generators (#3427)
Implemented device random number generators for ck tensors.
Includes tests and integration to ck builder testing interface.
2025-12-30 10:03:05 -08:00
Ville Pietilä
3c1e2b0170 Add instance traits for bwd weight algorithms. 2025-12-30 04:29:38 -05:00
Ville Pietilä
ab88cee0eb Add instance traits for DeviceGroupedConvBwdWeight_Xdl_CShuffleV3. 2025-12-29 09:53:07 -05:00
Ville Pietilä
a83790e9da Build conv bwd weigth v3 instances successfully. 2025-12-29 09:30:58 -05:00
Ville Pietilä
80f44824f5 Add bwd weight XDL CShuffle V3 factory. 2025-12-29 09:12:14 -05:00
JH-Leon-KIM-AMD
a0acc83a72 [CK_BUILDER] Add GPU Reference Algorithm to CK Builder (#3381)
* [CK_BUILDER] Integrate GPU reference as ConvAlgorithm

Add GPU reference as a ConvAlgorithm specialization, enabling:
- Unified Builder API for reference and optimized kernels
- Future ckProfiler integration for validation
- First step toward numerical validation in Builder tests

Changes:
- Add ConvAlgorithmSpecialization::REFERENCE enum
- Add ConvAlgorithm_Reference struct
- Add IsReferenceAlgorithm concept
- Create 3 reference factories (Forward, BwdData, BwdWeight)
- Wire into conv_dispatcher
- Add proof-of-concept test (passing)

Test result: Can instantiate reference through Builder API

* Add GPU reference execution tests

- Reference kernel executes through Builder (459ms)
- Both reference and optimized can instantiate
- Tests passing

Next: Implement utilities for comparison

* Optimized Builder kernel execution works

- MakeArgument pattern implemented
- Builder-generated kernel executes successfully
- Tests passing (451ms execution)

Next: Add comparison

* VALIDATION COMPLETE: Builder == Reference

Builder-generated kernel output matches GPU reference!

Test: Validate_Optimized_vs_Reference_Forward_2D_FP16
Result: PASS ✓

This proves CK Builder generates correct code!

* Update to new Builder API

All tests passing

* Rename test file for clarity

test_builder_kernel_execution -> test_builder_kernel_validation

* Add all 3 directions support

- Forward, Backward Data, Backward Weight
- All reference factories working
- Dispatcher wired for all directions
- 9 tests passing

Tests:
- test_reference_execution: 3 tests (all directions)
- test_optimized_execution: 3 tests (all directions)
- test_builder_kernel_validation: 3 tests (fwd validated, bwd placeholders)

* Add backward direction support

- Backward data and weight dispatcher wiring
- Fix factories for new API
- All 3 directions tested
- 9 tests passing

* Refactor: Change IsReferenceAlgorithm from concept to consteval function

Address review feedback: Use consteval function in dispatcher instead of
concept, matching the pattern for other algorithms (Tile, XDL, WMMA, DL).

- Remove IsReferenceAlgorithm concept from conv_algorithm_concepts.hpp
- Add IsReferenceAlgorithm() consteval function to conv_dispatcher.hpp
- Update dispatcher to use function call: IsReferenceAlgorithm<T>()
- Remove redundant algorithm checks from reference factory requires clauses

All tests passing (9/9).

* Move Tile algorithm check outside direction block to support all directions

* Implement MakeInvokerPointer interface and add random input validation

- Implement full Argument/Invoker structs for old CK interface (not just nullptr)
- Refactor with reference_common.hpp to reduce code duplication
- Add random input validation tests: Builder vs direct GPU reference (all directions)
- Fix layout: GNHWC -> NHWGC to match reference kernel expectations
- All 12 tests pass with IDENTICAL results on random input

* Move ConvAlgorithm_Reference to test/impl/conv_algorithm_types.hpp

Keep types.hpp for data types only (enums), move algorithm descriptors
to conv_algorithm_types.hpp as suggested by review.

* Add static_assert to ensure reference factories only accept PassThrough operations

Reference implementation doesn't support fused elementwise operations.
Add compile-time validation to fail early with clear error message if
non-PassThrough operations are specified on input, weight, or output.

* Add InstanceTraits support for reference kernels

- Store SIGNATURE/ALGORITHM/VERSION in Instance for reflection
- Create shared ReferenceCommonTraits base for common properties
- Add 3 direction-specific InstanceTraits specializations in one file
- Include data type and layouts in instance_string output

* Remove optimized kernel validation tests from reference-only branch

* Use existing layout helper and organize reference tests

Use LayoutToCK from conv_tensor_layout.hpp and move reference InstanceTraits
test to validation folder.

* Merge develop branch

Fix DataType switch for new mixed precision types.

* Fix comment spacing for CI

* Convert IsReferenceAlgorithm from function to concept

* Add reference tests to CI smoke tests

* Consolidate 3 reference factories into single unified factory

---------

Co-authored-by: Ville Pietilä <188998872+vpietila-amd@users.noreply.github.com>
2025-12-29 16:11:08 +02:00
Ville Pietilä
52086b350a Fix smoke tests. 2025-12-29 05:44:51 -05:00
Ville Pietilä
3bd0f05081 Fix fwd conv builder tests. 2025-12-29 05:31:35 -05:00
Ville Pietilä
30a9686877 Update compiletime diagnostics to use the size type. 2025-12-29 04:56:22 -05:00
Ville Pietilä
8c80e005bd Introduve a common size type for concepts. 2025-12-29 04:53:19 -05:00
Ville Pietilä
ff2fdd8acc Improve concept diagnostics. 2025-12-29 04:26:06 -05:00
Ville Pietilä
77e10c7b08 Concept improvements. 2025-12-23 10:27:38 -05:00
Ville Pietilä
a1740c614b Refactor handing of GEMM-K batch template parameter in conv bwd weight factory. 2025-12-23 10:08:56 -05:00
kabrahamAMD
4ce7d4c511 [ck_builder] add utility functions to convolution (#3459)
* reinstate conv_signature_utils.hpp

* added tests for elementwise operation getters

* add tests for getDataType functions

* added test for no data type specified

---------

Co-authored-by: Kevin Abraham <kevin.abraham@streamhpc.com>
2025-12-23 10:39:49 +01:00
Ville Pietilä
608266a4ef First functional version of bwd weight conv factory. 2025-12-22 11:50:00 -05:00
Ville Pietilä
96a4a5de37 Factory bug fixes. 2025-12-22 11:05:00 -05:00
Ville Pietilä
a8e7edd814 Update algorithm signature diagnostics. 2025-12-22 10:56:47 -05:00
Ville Pietilä
dacf82d652 Concept bug fixes. 2025-12-22 09:23:47 -05:00
Ville Pietilä
5ee99d83d5 Improve compile time diagnostics. 2025-12-22 08:59:46 -05:00
Ville Pietilä
9679d9b141 Improve missing member/wrong type compile-time errors. 2025-12-22 08:39:47 -05:00