Skip to content

[CUDA] Merge fp_qmv into qmv#3239

Open
zcbenz wants to merge 1 commit intoml-explore:mainfrom
zcbenz:remove-fp-qmv
Open

[CUDA] Merge fp_qmv into qmv#3239
zcbenz wants to merge 1 commit intoml-explore:mainfrom
zcbenz:remove-fp-qmv

Conversation

@zcbenz
Copy link
Collaborator

@zcbenz zcbenz commented Mar 10, 2026

Use the QMV kernel for fp quantizations.

Did a simple benchmarking and it is about 9% faster on A100.

Details
import time
import mlx.core as mx

M,N,K = (1, 16384, 16384)

x = mx.random.normal(shape=(M, K), dtype=mx.float16)
w = mx.random.normal(shape=(N, K), dtype=mx.float16)

w_q, scales = mx.quantize(w, mode='mxfp4')
y = mx.quantized_matmul(x, w_q, scales, transpose=True, mode='mxfp4')
mx.eval(y)

def fun():
    y = mx.quantized_matmul(x, w_q, scales, transpose=True, mode='mxfp4')
    mx.eval(y)

for _ in range(100):
    fun()

iterations = 1000
tic = time.time()
for _ in range(iterations):
    fun()
toc = time.time()

s = toc - tic
gb = iterations * (x.nbytes + w_q.nbytes + scales.nbytes + y.nbytes) / 1e9

print("{:5.2f}".format(gb / s))

Copy link
Member

@angeloskath angeloskath left a comment

Choose a reason for hiding this comment

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

Perfect! Do you think we should test on Hopper and Blackwell as well?

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