﻿# hipBLASLt: matrix memory order and transpose are separate descriptors

Describe hipBLASLt matrices using physical memory order and element strides, then apply operation transposes without treating descriptor changes as data movement.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-hipblaslt-memory-order-transpose-leading-dimension/
Language: en

## Start from the buffer that actually exists

A framework tensor can expose a logical matrix while its physical memory includes padding or a different contiguous direction. Record the actual address-to-element mapping before building library descriptors. Do not assume that a tensor's displayed dimensions establish its storage order. A small nonsquare matrix with distinct values is a better diagnostic than a symmetric or constant matrix, because those special cases can hide a swapped interpretation.

## Set layout order and leading dimension consistently

The [hipBLASLt datatype reference](https://rocm.docs.amd.com/projects/hipBLASLt/en/latest/reference/datatypes.html) distinguishes row-major and column-major order and defines the leading dimension as an element stride in the corresponding direction. It is not automatically a byte count or the logical number of columns. For a padded buffer, include the physical stride. Selecting an order enum declares how memory is read; it does not transpose or repack existing elements.

## Apply the mathematical transpose separately

The [API reference](https://rocm.docs.amd.com/projects/hipBLASLt/en/latest/reference/api-reference.html) separates matrix-layout creation from multiplication-operation descriptors. Establish stored dimensions first, then check the dimensions after the selected operand operation. A transpose flag must agree with the intended matrix equation, not compensate for unexplained storage assumptions. Verify the output using an independent multiplication before changing algorithms or adding an epilogue that can make the first incorrect result harder to inspect.

## Preserve output and batch layout too

Correct input descriptors do not guarantee a correct result interpretation. The output layout and any batch offsets must match allocated storage and downstream consumption. Reinterpreting a transposed result as a contiguous framework tensor can break an otherwise correct library operation. Check a selected output coordinate and neighboring row or column in the actual buffer. Keep view transformations distinct from physical copies, and include necessary repacking when measuring an end-to-end path.

## Tune only after the layout contract is stable

The [logging and heuristics guide](https://rocm.docs.amd.com/projects/hipBLASLt/en/latest/how-to/use-logging-heuristics.html) supports inspecting algorithm selection. Selection evidence is meaningful only for the matrix operation actually described. The existing [HIP portability guide](/journal/learn-hip-launch-portability/) and [software reproducibility guide](/journal/software-stack-reproducibility/) provide related context. Preserve layout, transpose, leading dimensions, batch strides and output interpretation with the result so a faster configuration remains a comparison of equivalent mathematical work and memory semantics.
