Repository navigation
Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels
Activity
LyricZhao commentedon Feb 28, 2025
Fixed in 6c5da03, thanks for feedback!
BTW, your matrix size is so big which leads to OOM on H800s (
calc_difffunction uses too much VRAM). So I tested it with smaller M=1024.NexusMancer commentedon Feb 28, 2025
The issue has been successfully resolved. Thank you very much!!!
Fully refactor with C++ (#22)
Apply top-k weights in NVFP4 MegaMoE combine (deepseek-ai#22)