Skip to content

How can I use a custom size? #22

Closed

Description

@NexusMancer

I encountered an issue while customizing the size. Could you please advise me on how to resolve it?

while m = 73728, k = 128, n = 36864

def test_gemm() -> None:
    print('Testing GEMM:')
    for m in (73728,):
        for k, n in [(128, 36864)]:
            x_fp8, y_fp8, out, ref_out = construct(m, k, n)
            deep_gemm.gemm_fp8_fp8_bf16_nt(x_fp8, y_fp8, out)
            diff = calc_diff(out, ref_out)
            assert diff < 0.001, f'{m=}, {k=}, {n=}, {diff:.5f}'
            # noinspection PyShadowingNames
            def test_func():
                # Construct new tensors every time to avoid L2 cache acceleration
                x_fp8, y_fp8, out, ref_out = construct(m, k, n)
                deep_gemm.gemm_fp8_fp8_bf16_nt(x_fp8, y_fp8, out)
            t = bench_kineto(test_func, 'fp8_gemm', suppress_kineto_output=True)
            print(f' > Performance (m={m:5}, n={n:5}, k={k:5}): {t * 1e6:4.0f} us | '
                  f'throughput: {2 * m * n * k / t / 1e12:4.0f} TFLOPS, '
                  f'{(m * k + k * n + m * n * 2) / 1e9 / t:4.0f} GB/s')
    print()

issue like

(psekv3) [myname@gpu DeepGEMM]$ python test_core.py 

Library path:
 > ['/home/myname/DeepGEMM/deep_gemm']

Testing GEMM:
lhs.shape: torch.Size([73728, 128])
lhs_scales.shape: torch.Size([73728, 1])
rhs.shape: torch.Size([36864, 128])
rhs_scales.shape: torch.Size([288, 1])
/home/myname/DeepGEMM/deep_gemm/jit/../include/deep_gemm/fp8_gemm.cuh(103): error: static assertion failed with "Misaligned barriers"
      static_assert(not kMustUseUniformedScaleB or SHAPE_K_SCALES % (sizeof(Barrier) / sizeof(float)) == 0, "Misaligned barriers");
      ^
          detected during:
            instantiation of "void deep_gemm::fp8_gemm_kernel<SHAPE_N,SHAPE_K,BLOCK_M,BLOCK_N,BLOCK_K,kNumGroups,kNumStages,kNumTMAThreads,kNumMathThreadsPerGroup,kNumTMAMulticast,kGemmType>(__nv_bfloat16 *, float *, int *, uint32_t, CUtensorMap, CUtensorMap, CUtensorMap, CUtensorMap) [with SHAPE_N=36864U, SHAPE_K=128U, BLOCK_M=128U, BLOCK_N=128U, BLOCK_K=128U, kNumGroups=1U, kNumStages=5U, kNumTMAThreads=128U, kNumMathThreadsPerGroup=128U, kNumTMAMulticast=2U, kGemmType=deep_gemm::GemmType::Normal]" at line 368
            instantiation of "void deep_gemm::Gemm<SHAPE_N, SHAPE_K, BLOCK_M, BLOCK_N, BLOCK_K, kNumGroups, kNumStages, kNumTMAMulticast, kGemmType>::run(__nv_bfloat16 *, float *, int *, uint32_t, const CUtensorMap &, const CUtensorMap &, const CUtensorMap &, const CUtensorMap &, cudaStream_t, int, uint32_t) [with SHAPE_N=36864U, SHAPE_K=128U, BLOCK_M=128U, BLOCK_N=128U, BLOCK_K=128U, kNumGroups=1U, kNumStages=5U, kNumTMAMulticast=2U, kGemmType=deep_gemm::GemmType::Normal]" at line 37 of /home/myname/.deep_gemm/cache/kernel.gemm_fp8_fp8_bf16_nt.21f2d977befb/kernel.cu

1 error detected in the compilation of "/home/myname/.deep_gemm/cache/kernel.gemm_fp8_fp8_bf16_nt.21f2d977befb/kernel.cu".
Traceback (most recent call last):
  File "/home/myname/DeepGEMM/test_core.py", line 158, in <module>
    test_gemm()
  File "/home/myname/DeepGEMM/test_core.py", line 72, in test_gemm
    deep_gemm.gemm_fp8_fp8_bf16_nt(x_fp8, y_fp8, out)
  File "/home/myname/DeepGEMM/deep_gemm/jit_kernels/gemm.py", line 160, in gemm_fp8_fp8_bf16_nt
    runtime = jit_tuner.compile_and_tune(
  File "/home/myname/DeepGEMM/deep_gemm/jit_kernels/tuner.py", line 40, in compile_and_tune
    kernels.append((build(name, arg_defs, code), tuned_keys))
  File "/home/myname/DeepGEMM/deep_gemm/jit/compiler.py", line 139, in build
    assert subprocess.check_call(command) == 0, f'Failed to compile {src_path}'
  File "/home/myname/miniconda3/envs/psekv3/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/cuda/bin/nvcc', '/home/myname/.deep_gemm/cache/kernel.gemm_fp8_fp8_bf16_nt.21f2d977befb/kernel.cu', '-o', '/home/myname/.deep_gemm/tmp/nvcc.tmp.44fc9af3-79ad-4dbd-9358-04df3cfd478f.1c2307ed5faf.so', '-std=c++17', '-shared', '-O3', '--expt-relaxed-constexpr', '--expt-extended-lambda', '-gencode=arch=compute_90a,code=sm_90a', '--ptxas-options=--register-usage-level=10', '--diag-suppress=177,174,940', '--compiler-options=-fPIC,-O3,-Wno-deprecated-declarations,-Wno-abi', '-I/home/myname/DeepGEMM/deep_gemm/jit/../include']' returned non-zero exit status 1.

Activity

  1. LyricZhao commented on Feb 28, 2025

    @LyricZhao
    Collaborator

    Fixed in 6c5da03, thanks for feedback!

    BTW, your matrix size is so big which leads to OOM on H800s (calc_diff function uses too much VRAM). So I tested it with smaller M=1024.

  2. NexusMancer commented on Feb 28, 2025

    @NexusMancer
    Author

    Fixed in 6c5da03, thanks for feedback!

    BTW, your matrix size is so big which leads to OOM on H800s (calc_diff function uses too much VRAM). So I tested it with smaller M=1024.

    The issue has been successfully resolved. Thank you very much!!!

  3. added a commit that references this issue on Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions