hipBLASLt experimental API#
hipBLASLt ships some features through an experimental API before they become part of the stable hipBLASLt API or hipBLASLtExt API. The experimental API lets early adopters evaluate a feature and give feedback while its interface is still being refined.
Warning
The experimental API is not covered by the hipBLASLt backward compatibility guarantees. Any experimental function, type, or enumerator can change or be removed in any ROCm release, including patch releases. Code that uses it must keep a working path without it.
Enabling the experimental API#
The experimental API is declared in hipblaslt/hipblaslt-experimental.h, which is installed
with every hipBLASLt build but is not included by hipblaslt/hipblaslt.h. The header declares
nothing unless the consumer defines ROCM_ENABLE_EXPERIMENTAL_APIS to a nonzero value before
including it. The same switch enables the experimental APIs of every ROCm library; there is no
per-library switch.
#define ROCM_ENABLE_EXPERIMENTAL_APIS 1
#include <hipblaslt/hipblaslt-experimental.h>
CMake consumers can link roc::hipblaslt_experimental instead of roc::hipblaslt. It is
roc::hipblaslt plus the define, and it is exported with the hipBLASLt package but not listed in
hipblaslt_LIBRARIES:
find_package(hipblaslt CONFIG REQUIRED)
target_link_libraries(my_target PRIVATE roc::hipblaslt_experimental)
Any other build system can set the define, for example
target_compile_definitions(my_target PRIVATE ROCM_ENABLE_EXPERIMENTAL_APIS=1).
Defining it to 0 turns the experimental API off explicitly. Including the header without the
switch is not an error, so code that checks for features (below) builds either way.
Checking for a feature#
Each experimental feature defines a revision macro, HIPBLASLT_EXPERIMENTAL_<FEATURE>, set to
the feature’s current revision. The revision starts at 1 and increases only when the feature
changes in a way that can break existing callers. Additions don’t change it.
Because the shared library version does not track experimental changes, also check at runtime
that the loaded library implements the revision you compiled against.
hipblasLtExperimentalGetFeatureRevision returns the loaded library’s revision of a feature, or
0 if it doesn’t have the feature. Code that uses a feature should check both and fall back when
either doesn’t match:
#if defined(HIPBLASLT_EXPERIMENTAL_PARTITIONED_GEMM) && HIPBLASLT_EXPERIMENTAL_PARTITIONED_GEMM == 2
if(hipblasLtExperimentalGetFeatureRevision("PARTITIONED_GEMM") == 2)
{
/* Use the experimental feature. */
}
else
#endif
{
/* Stable path. */
}
Code that cannot work without a feature can report an error instead of falling back. Framework code, which is built both with and without the switch, must keep the fallback.
Experimental enumerators#
Experimental values of stable enum types, such as new epilogues or matmul descriptor attributes,
are declared in their feature’s header with HIPBLASLT_EXPERIMENTAL_ENUM_BIT set. They are
passed to the existing stable functions, for example hipblasLtMatmulDescSetAttribute. When an
experimental enumerator graduates, it is assigned a new value in the stable enum.
Experimental enumerator values are never renumbered or reused, even after the enumerator is
removed. HIPBLASLT_EXPERIMENTAL_ENUM_HIGH_WATER records the highest value ever assigned and
only increases. A removed value is rejected with HIPBLAS_STATUS_INVALID_VALUE. The mark is
shared by every experimental enum, C++ scoped enums included, so a new enum’s first value is
above it: one library-wide number is what lets the check compare only two versions of the
headers and still never reuse a value.
Lifecycle#
A breaking change never changes a declaration in place. A function whose signature or documented behavior changes gets a new name (for example with a
_v2suffix) and the old name is removed, so a program built against the old revision fails to load or falls back instead of calling the new code with old arguments. The same applies to structs, unions and typedefs: any change to one, including adding a member, gives it a new name, and the functions that use it get new names too. Each breaking change increments the feature’s revision and is listed under anExperimentalheading in the CHANGELOG.C++ features follow the same rule, applied to what decides which symbol a caller binds to and what memory it assumes:
A function or method is identified by its scope, name and parameter types. Adding a method or an overload is an addition. Removing one is a breaking change. A different parameter list is a different overload, so changing one is a removal plus an addition. The return type, default arguments and qualifiers (
const,noexcept,= delete) never change under the same parameter list. Renaming a parameter is not a change.A class’s layout is its bases, its data members and its virtual functions. Any change to it gives the class a new name. A class that keeps its state behind a private pointer to an implementation (as
PartitionedGemmdoes) can then gain methods freely. Private methods are not part of the API.Templates are not allowed in experimental headers, because they can’t be compared without instantiating them.
An experimental feature ships in at most four ROCm releases, counted from the release that introduced it (patch releases don’t count). Revision increments don’t reset this. By then it either graduates to the stable API or is removed. A feature can be extended by one release, once, with an approver recorded in the registry.
At most three experimental features exist at a time.
When a feature graduates, the stable declaration is added under a new name and the experimental feature, including its revision macro, is removed in the same release. After that,
hipblasLtExperimentalGetFeatureRevisionreturns 0 for it.
Adding or changing an experimental feature#
These rules are checked automatically, so they cannot be forgotten.
Each feature has its own header,
library/include/hipblaslt/hipblaslt-experimental-<feature>.h, whichhipblaslt-experimental.hincludes and which defines the feature’s revision macro. Enumerators must have explicit integer values.Each feature is registered in
library/experimental/features.cmakewith an owner, a tracking issue, the ROCm release that introduced it, and the last ROCm release that may ship it. Releases are counted on the ordered list incmake/rocm_feature_releases.cmake, and the release being built isHIPBLASLT_ROCM_RELEASE. CMake configure warns in the last release and fails after it, so the change that starts the next release cannot merge until the feature graduates, is removed, or is extended. Configure also fails if a feature header is not registered, is missing its revision macro, or if there are too many features.Each feature has contract tests in
clients/tests/src/experimental/contract_<feature>*_gtest.cpp. They define the feature’s promised behavior. Adding a contract test is free; changing or deleting one is a breaking change. Headers they share, such as test helpers, are namedcontract_<feature>*.hppin the same directory and are part of the contract too. Every CI lane checks part of the contract: a feature that is limited to some architectures has a contract test that it refuses on the others, so lanes without the supported hardware don’t just skip.tools/scripts/check_experimental_api.pyruns on every pull request that touches the experimental API. It compares the declarations and contract tests with the target branch and fails if:a function, C++ method, struct, union, typedef, C++ class layout or enumerator was changed in place, an enumerator value was reused, or
HIPBLASLT_EXPERIMENTAL_ENUM_HIGH_WATERwent down or is too low;a declaration, contract test or contract header was removed or changed without incrementing that feature’s revision;
a header declares a template;
a revision went backwards, or a new feature doesn’t start at revision 1 or higher.
It warns when a revision was incremented with no breaking change. Run it locally with:
python3 tools/scripts/check_experimental_api.py --base origin/develop
The checker cannot see implementation changes. If a change alters a feature’s behavior, a contract test fails, and updating that test triggers the check.
Experimental API reference#
-
HIPBLASLT_EXPERIMENTAL_ENUM_BIT#
Marker bit for experimental values of stable enum types.
Experimental enumerators for stable enums (for example, new epilogues or descriptor attributes) are declared in the feature headers as
(EnumType)(HIPBLASLT_EXPERIMENTAL_ENUM_BIT | n), so they can be passed to the existing stable entry points (such as hipblasLtMatmulDescSetAttribute) without adding enumerators to hipblaslt.h. Stable enums must never use this bit. When an experimental value graduates it receives a new value in the stable enum.
-
HIPBLASLT_EXPERIMENTAL_ENUM_HIGH_WATER#
Highest experimental enumerator value ever used, ignoring HIPBLASLT_EXPERIMENTAL_ENUM_BIT.
Experimental enumerator values are never reused, so a binary built against a retired value cannot silently get a different meaning. A new experimental enumerator, in any experimental enum, takes a value above this mark, and the mark is raised to match. It never goes down. tools/scripts/check_experimental_api.py enforces this.
hipblasLtExperimentalGetFeatureRevision()#
-
int hipblasLtExperimentalGetFeatureRevision(const char *feature)#
Returns the revision of an experimental feature in the loaded hipBLASLt library.
The shared-library version does not track experimental changes. Before calling a feature’s functions, check that this returns the revision your code was compiled against (
HIPBLASLT_EXPERIMENTAL_<FEATURE>).This function never changes and is never removed.
- Parameters:
feature – [in] The feature name without the prefix, for example “PARTITIONED_GEMM”.
- Return values:
int – The feature’s revision, or 0 if the library does not have the feature or
featureis null.
Experimental feature PARTITIONED_GEMM#
PartitionedGemm is supported on gfx1250 devices only. On any other architecture
setProblem returns HIPBLAS_STATUS_NOT_SUPPORTED.
hipblaslt_experimental::PartitionedGemm (C++ only) runs one GEMM as slices on the devices of a
partitioned GPU, for example the two partitions of a DPX card, where each partition is a separate
HIP device. The partitions can also be separate GPUs that can reach each other’s memory; the
slices that are not local then travel over the link between them. The caller passes one hipBLASLt
handle per partition (created with that partition’s device current), and one stream, workspace,
and event per partition when it initializes and runs.
SplitDim picks the dimension to split (M, N, or the batch). The first N - 1 partitions take
size / N rounded up to a 256-byte boundary of every matrix they cut when that changes the
balance by at most 1%, and the last takes the rest; otherwise they take size / N and a hint is
logged (HIPBLASLT_LOG_MASK=4). A slice that starts off a 256-byte boundary runs much slower, so
pad the leading dimensions (and batch strides) to multiples of 256 bytes, which is enough for N and
Batch splits; for an M split also make M a multiple of parts * 256 / element size. hipBLASLt
does not allocate or copy any matrix, and does not enable peer access: every partition’s slices
must be accessible from its device (local memory, or peer or VMM access that the caller has set
up), otherwise the run faults like any GEMM given an inaccessible pointer. Run in DPX mode for
speed; SPX (every partition on one device) gives correct results but is only meant for checking
them without a DPX GPU. setProblem queries where the memory is, so call it when a pointer or
the shape changes, not on every launch. The caller passes one pointer per partition for each
matrix: the same pointer shares a matrix between the partitions, different pointers give each
partition its own copy. Where the memory lives (hipMalloc on one device, or a VMM range with
pages on several devices) is up to the caller: the library gives each partition the slice whose
pages are on that partition’s device, and getSlice reports it. See
clients/samples/31_hipblaslt_gemm_partitioned_ext for an example, including the revision
checks, and hipblaslt-bench --partitions to benchmark it. The device user arguments overloads
are declared and return HIPBLAS_STATUS_NOT_SUPPORTED.
The setProblem overload that takes a hipblaslt_ext::GemmEpilogue supports what
hipblaslt_ext::Gemm supports beyond a plain GEMM: the epilogue (activation, bias, aux, bias
gradients), the scale inputs, amaxD, and MX (block-scaled) types. The epilogue and the inputs
describe the full problem; the library adds each partition’s slice offset to every tensor the
split cuts (a bias or alpha vector with an M split, an aux matrix like D, the scale rows or batches
of an MX scale tensor) and passes the rest unchanged. Each partition writes the amaxD of its
own slice to its own pointer, and the caller takes the largest. Partition i reads and writes
only the slice that getSlice(i) reports, of every tensor; that can differ from slice i,
because setProblem may reassign slices by where A to D live. Whole copies and shared tensors
always work. A framework that gives a partition a copy holding only its range must make the
assignment predictable (for example, each partition’s copies of A to D on its own device) and
check getSlice; making copies is the caller’s job. The extra pointers are not sampled for
placement and go with the copies of A to D in the same list element. MX scale blocks run along K,
which is never split. The combinations that cannot be sliced return
HIPBLAS_STATUS_NOT_SUPPORTED and log the reason: a bias gradient split across the dimension
it sums over, an MX scale tensor cut along its rows unless K is innermost (A with op T, B
with op N) and batch_count is 1, BLK32_UE8M0_128_4 (it needs an order a
PartitionedGemm cannot set), the gfx950 BLK32_UE8M0_32_8 layout, int4 with its group scales,
and scaleAux (refused by Gemm too). See the setProblem reference below for the exact
rules.
-
HIPBLASLT_EXPERIMENTAL_PARTITIONED_GEMM#
Revision of experimental feature PARTITIONED_GEMM declared in this header.
Incremented on every breaking change to the feature: a removed declaration, a function or type replaced by a renamed version, a retired enumerator, or a changed contract test. Additions do not increment it. tools/scripts/check_experimental_api.py enforces this.
-
class PartitionedGemm#
Runs one GEMM as slices on several devices.
A device that is partitioned (for example DPX) shows up as several HIP devices. A PartitionedGemm takes the full problem, gives each partition a slice of it (see hipblaslt_experimental::SplitDim), and launches the slices on one stream per partition. It owns one hipblaslt_ext::Gemm per partition and does not allocate memory or copy data.
Handle, stream, workspace, pointer and event number
iall belong to partitioni. Each handle must be created with its partition’s device current, and each stream must belong to the same device as its handle. In SPX mode, where every partition is on the same device, the streams share that device and the result is still correct, but SPX is only meant for checking results without a DPX GPU, not for speed: the partitions just run one after another or concurrently on one device.Calls follow the order of hipblaslt_ext::Gemm: setProblem, algoGetHeuristic (or isAlgoSupported), initialize, then run. Call setProblem again when a pointer or the shape changes, not on every launch: it queries where the memory is (
hipPointerGetAttributes) to decide which partition computes which slice.The epilogue, scale, aux and amaxD inputs and the MX (block-scaled) types of hipblaslt_ext::Gemm are supported, except the combinations listed at setProblem. Device user arguments are declared but not supported yet.
Public Functions
-
explicit PartitionedGemm(const std::vector<hipblasLtHandle_t> &handles, hipblasOperation_t opA, hipblasOperation_t opB, hipDataType typeA, hipDataType typeB, hipDataType typeC, hipDataType typeD, hipblasComputeType_t typeCompute)#
Constructor.
- Parameters:
handles – [in] One hipBLASLt handle per partition. The number of partitions is
handles.size().opA, opB – [in] The transpose type of matrices A and B.
typeA, typeB, typeC, typeD – [in] The data type of matrices A, B, C, and D.
typeCompute – [in] The compute type of the GEMM problem.
-
size_t getPartitionCount() const#
The number of partitions.
-
hipblasStatus_t setProblem(int64_t m, int64_t n, int64_t k, int64_t batch_count, int64_t lda, int64_t ldb, int64_t ldc, int64_t ldd, int64_t strideA, int64_t strideB, int64_t strideC, int64_t strideD, SplitDim dim, const std::vector<hipblaslt_ext::GemmInputs> &inputs, bool storePeerD = false)#
Sets up the full GEMM problem and its partitioning.
m,n,k, the leading dimensions and the strides describe the full matrices. The pointers come frominputs.Which partition computes which slice is chosen here: the slices of the split matrices (op(A) for SplitDim::M, op(B) for SplitDim::N, every batched matrix for SplitDim::Batch, and C and D) go to the partitions whose devices hold most of their pages, and otherwise partition
icomputes slicei. The result is the same either way. A slice that still mostly lives on another device is reported in the hints log (HIPBLASLT_LOG_MASK=4).inputsholds one GemmInputs per partition, N in total, withsetA,setB,setC,setD,setAlphaandsetBetaset. Each pointer points at a whole matrix (the library adds the partition’s slice offset), and the leading dimensions and batch strides describe that whole matrix. The other inputs (bias, scales, aux, amaxD) are described with the overload that takes a GemmEpilogue. The same pointer in every element shares one matrix between the partitions (it must be accessible from every partition device, see below); different pointers give each partition its own copy, which the caller keeps equal. For D, the same pointer means every partition writes its slice into one D. Copies are matched to the partitions by device, whatever the order ofinputs: partitionpuses the copy on its device, so the D on device X receives the slice of the partition on device X. All copied matrices must agree on one assignment; if they do not (for example A listed in one order and B in the other), setProblem returnsHIPBLAS_STATUS_INVALID_VALUEand logs an error. hipBLASLt allocates and copies nothing.alphaandbetaare host pointers, as in GemmInputs; they are read from the first element, must be set in every element, and apply to every partition.Precondition: every partition’s slices of A, B, C and D (and with
storePeerDthe peer D) must be accessible from that partition’s device: local memory, or peer access or VMM access that the caller has set up. Otherwise the run faults, as with any GEMM given an inaccessible pointer; setProblem does not check it and does not enable peer access. WithHIPBLASLT_LOG_MASK=4(hints) it samples a few addresses and logs a hint when one looks unreachable (hipDeviceCanAccessPeersays only that peer access is possible, not that it is enabled), but never changes its return value.Where the memory is (hipMalloc on one device, or a VMM range whose pages are on several devices) is up to the caller: for example, two copies of A back to back in one VMM range are passed as
vaandva + sizeA, and one D whose halves are on the two devices asvain both elements. The library reads where the pages of each slice are and gives every partition the slice that is on its device (see PartitionedGemm::getSlice).With
HIPBLASLT_LOG_MASK=4setProblem logs where the partitions are: all on one device (SPX mode, correct but only for checking results, not for speed), the partitions of one GPU (DPX or another partition mode, found from the PCI function of the devices), or different GPUs.With
storePeerDevery partition also stores its slice into the D of the other partition, so that both Ds are complete once every partition has finished its slice (see run()). It needs exactly 2 partitions and a replicated D (two different pointers, in any order: the peer of each partition is found by device), and the backend needs kernels that store a second D; without them setProblem succeeds and algoGetHeuristic returns nothing (also with a device library built before this feature). The peer D is written with system-scope stores. run() does not order later work after the partitions: see run().- Parameters:
m, n, k – [in] The size of the full problem.
batch_count – [in] The batch count.
lda, ldb, ldc, ldd – [in] The leading dimensions of the matrices.
strideA, strideB, strideC, strideD – [in] The batch strides of the matrices.
dim – [in] The dimension to split.
inputs – [in] One GemmInputs per partition (see below).
storePeerD – [in] Every partition also stores its slice into the D of the other partition (see below).
- Return values:
HIPBLAS_STATUS_SUCCESS – If the problem was set on every partition.
HIPBLAS_STATUS_INVALID_VALUE – If
inputsdoes not hold one GemmInputs per partition, a required pointer is null, a size is not positive, or the split dimension is smaller than the number of partitions.HIPBLAS_STATUS_NOT_SUPPORTED – If a partition’s device is not a gfx1250 (the only architecture PartitionedGemm supports), the types or operations are not supported (conjugate transpose; any type other than f64, f32, i32, f16, bf16, i8, fp8, fp6 and fp4, such as int4 or complex types), or a partition rejects its slice.
-
hipblasStatus_t setProblem(int64_t m, int64_t n, int64_t k, int64_t batch_count, int64_t lda, int64_t ldb, int64_t ldc, int64_t ldd, int64_t strideA, int64_t strideB, int64_t strideC, int64_t strideD, SplitDim dim, const hipblaslt_ext::GemmEpilogue &epilogue, const std::vector<hipblaslt_ext::GemmInputs> &inputs, bool storePeerD = false)#
Sets up the full GEMM problem with an epilogue, and its partitioning.
The same as the overload without
epilogue(which runs with a default GemmEpilogue), plus the epilogue and the extra inputs of hipblaslt_ext::Gemm: the epilogue mode and its activation arguments, bias, scaleA, scaleB, scaleC, scaleD, scaleAlphaVec or scaleAlphaScalar, aux and amaxD, and the scaling types of A and B (MX block scales).epilogueand every GemmInputs describe the full problem, as for one Gemm. The aux leading dimension and batch stride describe the whole aux matrix; 0 meansmfor the leading dimension and the leading dimension timesnfor the batch stride (each partition’s Gemm is given both explicitly). Smaller values returnHIPBLAS_STATUS_INVALID_VALUE.Every extra pointer is set in every element of
inputsor in none. As for A to D, the same pointer in every element is one tensor shared by the partitions and different pointers are copies. The extra pointers are not sampled for placement: those of elementjgo to the partition that the copies of A to D in elementjgo to. The library adds the slice offset to each:bias (a vector over the rows of D): offset by the slice with SplitDim::M; whole with N and Batch (one bias for every batch). A bias gradient output (HIPBLASLT_EPILOGUE_BGRADA, DRELU_BGRAD, DGELU_BGRAD: over the rows; BGRADB: over the columns) needs a split that cuts its dimension, M (N for BGRADB); any other split would leave each partition a partial reduction and returns
HIPBLAS_STATUS_NOT_SUPPORTED.scaleAlphaVec, and scaleA (scaleB) with HIPBLASLT_MATMUL_MATRIX_SCALE_OUTER_VEC_32F: vectors over M (N), offset with an M (N) split, whole otherwise.
scaleA, scaleB with a scalar mode, scaleC, scaleD, scaleAlphaScalar: whole.
aux: a matrix like D, offset like D. It is an output for the AUX epilogues and an input for DRELU and DGELU.
amaxD: each partition writes the amax of its own slice of D to its own pointer, so the elements must be different pointers (otherwise
HIPBLAS_STATUS_INVALID_VALUE); the amax of the whole D is the largest of them, which the caller takes after run(). There is no reduction across partitions in the library.scaleAux is refused (
HIPBLAS_STATUS_NOT_SUPPORTED), as by Gemm.
An output (D, aux, a bias gradient, amaxD) on another device than its partition is published by run() as D is. With
storePeerDonly D is stored to the peer.MX block scales (scaleA and scaleB with a VEC16/VEC32/VEC128 UE8M0, UE4M3 or UE5M3 mode) hold one scale per block of 16, 32 or 128 elements along K, so a split never cuts a block. The scale tensor of A is laid out like A with K counted in blocks (
Kb=ceil(k / block)rounded up to a multiple of128 / block) and batches ofm * Kbscales; B likewise withn. The slice offset is a whole number of scale rows or batches, and each partition reads only the scales of its own rows (columns for B) or batches, every K block of them. Because a partition’s scale tensor is addressed with the strides of its slice, a split that cuts the rows of a scale tensor needs those rows outermost and one batch: an M split with an MX scaleA needsHIPBLAS_OP_Tfor A andbatch_count1, and an N split with an MX scaleB needsHIPBLAS_OP_Nfor B andbatch_count1. A Batch split works for every op. HIPBLASLT_MATMUL_MATRIX_SCALE_BLK32_UE8M0_128_4_EXT is refused: it needs HIPBLASLT_ORDER_COL256_R128_EXT, which a PartitionedGemm cannot set. BLK32_UE8M0_32_8_EXT (a gfx950 layout) and the int4 group-scale modes are refused too. Each refusal returnsHIPBLAS_STATUS_NOT_SUPPORTEDand logs the reason.Sub-byte types (fp4, fp6) are split so that every slice starts on a whole byte of each matrix it cuts: the slice size is rounded to the multiple of indices that needs.
What each partition reads and writes: partition
icomputes the slice that getSlice(i) reports, and touches only that slice of every split matrix and of each extra tensor above. That slice can differ from slicei: setProblem may reassign slices to partitions by where the pages of A, B, C and D are (see above). Whole copies and shared tensors are always right. A caller that gives a partition a copy holding only its range (addressed as if it were the whole tensor; making such copies is the caller’s job, the library copies nothing) must make the assignment predictable, for example by putting each partition’s copies of A to D on that partition’s own device, and check getSlice after setProblem. setProblem does not read memory: it queries which device owns a few addresses of A, B, C and D across the whole matrix, so addresses outside such a copy must be unmapped or on the same device as the copy. The extra inputs are not sampled.- Return values:
HIPBLAS_STATUS_NOT_SUPPORTED – As for the other overload, and for the combinations listed above.
HIPBLAS_STATUS_INVALID_VALUE – As for the other overload, or an extra pointer is set in some elements of
inputsand not in others, or amaxD repeats a pointer.
-
hipblasStatus_t getSlice(size_t partition, int64_t &offset, int64_t &size) const#
The slice of partition
partitionalong the split dimension.It need not be slice number
partition: setProblem may give a partition the slice whose memory is on its device.- Parameters:
partition – [in] The partition index.
offset, size – [out] The first index and the number of indices of the slice.
- Return values:
HIPBLAS_STATUS_INVALID_VALUE – If the index is out of range or no problem is set.
-
hipblasStatus_t algoGetHeuristic(const int requestedAlgoCount, const hipblaslt_ext::GemmPreference &pref, std::vector<hipblasLtMatmulHeuristicResult_t> &heuristicResults)#
Retrieve the algorithms that every partition accepts.
The heuristic runs on partition 0. Algorithms that any partition rejects for its slice are dropped. The workspace size of a result is the largest over the partitions.
-
hipblasStatus_t isAlgoSupported(hipblasLtMatmulAlgo_t &algo, std::vector<size_t> &workspaceSizeInBytes)#
Check whether the algorithm supports every partition’s slice.
- Parameters:
algo – [in] The algorithm heuristic.
workspaceSizeInBytes – [out] The required workspace size of each partition.
- Return values:
HIPBLAS_STATUS_INVALID_VALUE – The algorithm does not support some slice.
-
void setMaxWorkspaceBytes(size_t workspaceBytes)#
Sets the maximum workspace size of every partition.
-
hipblasStatus_t initialize(const hipblasLtMatmulAlgo_t &algo, const std::vector<void*> &workspaces, bool useUserArgs, const std::vector<hipStream_t> &streams)#
Creates the kernel arguments of every partition.
- Parameters:
algo – [in] The algorithm to use.
workspaces – [in] One workspace pointer per partition (16B aligned).
useUserArgs – [in] Like hipblaslt_ext::Gemm::initialize; it does not affect a standard GEMM.
streams – [in] One stream per partition.
- Return values:
HIPBLAS_STATUS_INVALID_VALUE – If a vector size is not the partition count, or a stream is not on the device of its partition’s handle.
-
hipblasStatus_t run(const std::vector<hipStream_t> &streams, const std::vector<hipEvent_t> &start = {}, const std::vector<hipEvent_t> &stop = {})#
Launches every partition’s slice on its stream and returns without waiting.
Each partition’s slice is launched on its own stream, as Gemm::run does for one stream. The partitions are not joined: work that needs the whole result (for example a kernel that reads all of D) must be ordered after every partition by the caller. Record an event on each partition’s stream after this call and make the streams that need the result wait for it (hipStreamWaitEvent), or synchronize the streams from the host. The sample does the first. The same holds under stream capture, where only the kernels of each partition are recorded.
A partition whose D slice is memory of another device (a shared D), or that also stores the peer D (
storePeerD), publishes its writes on its stream after the slice, so that the other devices see them. A partition that writes only its own device’s memory does not.setProblemdecides this from the device that owns the first and the last element of the partition’s D slice (and of its peer D). A D slice whose first and last element are on the partition’s own device but which crosses another device in between (possible with a VMM mapping) is not published: making those writes visible is then the caller’s. Shared A, B and C are the caller’s too: whoever wrote them last must have made them visible to every partition’s device before this call.- Parameters:
streams – [in] One stream per partition.
start, stop – [in] Optional events, one per partition (or empty).
-
hipblasStatus_t run(const std::vector<void*> &deviceUserArgs, const std::vector<hipStream_t> &streams, const std::vector<hipEvent_t> &start = {}, const std::vector<hipEvent_t> &stop = {})#
Reserved. Runs with device user arguments, one buffer per partition.
- Return values:
HIPBLAS_STATUS_NOT_SUPPORTED – If any pointer in
deviceUserArgsis not null. The call is declared now so that adding it later changes no signature.
-
hipblasStatus_t getDefaultValueForDeviceUserArguments(const std::vector<void*> &hostDeviceUserArgs)#
Reserved. Fills one host
UserArgumentsbuffer per partition.- Return values:
HIPBLAS_STATUS_NOT_SUPPORTED – Always, in this version.
-
explicit PartitionedGemm(const std::vector<hipblasLtHandle_t> &handles, hipblasOperation_t opA, hipblasOperation_t opB, hipDataType typeA, hipDataType typeB, hipDataType typeC, hipDataType typeD, hipblasComputeType_t typeCompute)#
-
enum class hipblaslt_experimental::SplitDim#
The dimension along which a PartitionedGemm splits the problem.
With
M, every partition computesm_i x n x kand the first operand (A) is split. WithN, every partition computesm x n_i x kand the second operand (B) is split. WithBatch, every partition computes wholem x n x kmatrices for a range of the batches, and every matrix with a nonzero batch stride is split. The firstN - 1partitions takesize / Nrounded up so that every slice starts at a multiple of 256 bytes in every matrix it cuts, and the last partition takes the rest, when that changes the balance by at most 1%. Otherwise they takesize / Nand a hint is logged (HIPBLASLT_LOG_MASK=4) naming what to pad. The split is never refused because of alignment. Pad the leading dimensions (and batch strides) to multiples of 256 bytes: that is enough forNandBatch; forMalso makeMa multiple ofparts * 256 / element size.Experimental enumerator values are never reused (see HIPBLASLT_EXPERIMENTAL_ENUM_HIGH_WATER).
Values:
-
enumerator M#
Split rows of op(A), C and D.
-
enumerator N#
Split columns of op(B), C and D.
-
enumerator Batch#
Split the batch: whole matrices, a range of batches per partition.
-
enumerator M#