Highly efficient matrix transpose in Mojo
31–40 of 70 posts
Re: Highly efficient matrix transpose in Mojo
#32Why do we ever need to transpose a matrix? Isn't it better to simply combine the transposition with whatever next operation one wishes to do with the matrix?
Re: Highly efficient matrix transpose in Mojo
#33I'm not an expert in this space, but is this meaningful? I'd assume that it's more common to fuse together transposition with an operation that precedes or follows it (e.g. matmul), which should be far more efficient than materializing the entire transposition in memory if it's just an intermediate value.
Re: Highly efficient matrix transpose in Mojo
#34Re: Highly efficient matrix transpose in Mojo
#35Does anyone use Mojo in production at all or are even hiring for Mojo?
Re: Highly efficient matrix transpose in Mojo
#36As someone said below - you'd never write just a transpose kernel - it'll be fused into something else.
Re: Highly efficient matrix transpose in Mojo
#37I'm not an expert in this space, but is this meaningful? I'd assume that it's more common to fuse together transposition with an operation that precedes or follows it (e.g. matmul), which should be far more efficient than materializing the entire transposition in memory if it's just an intermediate value.
Matrix transpose is a canonical example of a memory bound operation and often used to showcase optimization in a particular programming language or library. See for example the cutlass matrix transpose tutorial from Jay Shah of flash attention 3 paper: https://research.colfax-intl.com/tutorial-matrix-transpose-i...
Re: Highly efficient matrix transpose in Mojo
#38Earlier quoted context omitted.
The next operation might need the data in column major order to read it fast. So you might have to transpose first. And these maybe be concurrent stages of a processing pipeline.
Now I'm curious, how many times do you have to fully read the matrix in GPU for the total impact of reading columns to be higher than one-off actual transpose and then sequential row reads? I know it depends on lots of things, I'm after a rough estimate.
Re: Highly efficient matrix transpose in Mojo
#39I wonder if there is a reason for not using the high level abstractions provided by Modular
Re: Highly efficient matrix transpose in Mojo
#40I can't say for sure because I couldn't find the CUDA kernel but I kind of doubt this is true. You can hit memory bandwidth on Hopper without using TMA at all, which is mostly designed for accelerating asynchronous copies and reducing memory pressure. If all you are doing is a transpose you don't need any of this to go fast (though it might simplify your indexing code…?)