Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Illegal memory access in CUTLASS FP8 kernels #5506

Closed
tlrmchlsmth opened this issue Jun 13, 2024 · 1 comment · Fixed by #5516
Closed

[Bug]: Illegal memory access in CUTLASS FP8 kernels #5506

tlrmchlsmth opened this issue Jun 13, 2024 · 1 comment · Fixed by #5516
Labels
bug Something isn't working

Comments

@tlrmchlsmth
Copy link
Collaborator

tlrmchlsmth commented Jun 13, 2024

For now, I've filed to use torch._scaled_mm in #5505

Your current environment

Collecting environment information...
PyTorch version: 2.3.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.29.3
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.19.0-1010-nvidia-lowlatency-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.5.40
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA H100 NVL
GPU 1: NVIDIA H100 NVL
GPU 2: NVIDIA H100 NVL
GPU 3: NVIDIA H100 NVL
GPU 4: NVIDIA H100 NVL
GPU 5: NVIDIA H100 NVL
GPU 6: NVIDIA H100 NVL
GPU 7: NVIDIA H100 NVL

Nvidia driver version: 555.42.02
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Address sizes:                   46 bits physical, 57 bits virtual
Byte Order:                      Little Endian
CPU(s):                          144
On-line CPU(s) list:             0-143
Vendor ID:                       GenuineIntel
Model name:                      Intel(R) Xeon(R) Platinum 8452Y
CPU family:                      6
Model:                           143
Thread(s) per core:              2
Core(s) per socket:              36
Socket(s):                       2
Stepping:                        8
Frequency boost:                 enabled
CPU max MHz:                     2001.0000
CPU min MHz:                     800.0000
BogoMIPS:                        4000.00
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts hfi avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr ibt amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities
Virtualization:                  VT-x
L1d cache:                       3.4 MiB (72 instances)
L1i cache:                       2.3 MiB (72 instances)
L2 cache:                        144 MiB (72 instances)
L3 cache:                        135 MiB (2 instances)
NUMA node(s):                    2
NUMA node0 CPU(s):               0-35,72-107
NUMA node1 CPU(s):               36-71,108-143
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected

Versions of relevant libraries:
[pip3] mypy==1.9.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] sentence-transformers==3.0.1
[pip3] torch==2.3.0
[pip3] transformers==4.41.1
[pip3] triton==2.3.0
[pip3] vllm-nccl-cu12==2.18.1.0.4.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.0
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0	GPU1	GPU2	GPU3	GPU4	GPU5	GPU6	GPU7	NIC0	NIC1	CPU Affinity	NUMA Affinity	GPU NUMA ID
GPU0	 X 	NODE	NODE	NODE	SYS	SYS	SYS	SYS	SYS	SYS	0-35,72-107	0		N/A
GPU1	NODE	 X 	PIX	PIX	SYS	SYS	SYS	SYS	SYS	SYS	0-35,72-107	0		N/A
GPU2	NODE	PIX	 X 	PIX	SYS	SYS	SYS	SYS	SYS	SYS	0-35,72-107	0		N/A
GPU3	NODE	PIX	PIX	 X 	SYS	SYS	SYS	SYS	SYS	SYS	0-35,72-107	0		N/A
GPU4	SYS	SYS	SYS	SYS	 X 	PIX	NODE	NODE	NODE	NODE	36-71,108-143	1		N/A
GPU5	SYS	SYS	SYS	SYS	PIX	 X 	NODE	NODE	NODE	NODE	36-71,108-143	1		N/A
GPU6	SYS	SYS	SYS	SYS	NODE	NODE	 X 	PIX	NODE	NODE	36-71,108-143	1		N/A
GPU7	SYS	SYS	SYS	SYS	NODE	NODE	PIX	 X 	NODE	NODE	36-71,108-143	1		N/A
NIC0	SYS	SYS	SYS	SYS	NODE	NODE	NODE	NODE	 X 	PIX				
NIC1	SYS	SYS	SYS	SYS	NODE	NODE	NODE	NODE	PIX	 X 				

Legend:

  X    = Self
  SYS  = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
  NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
  PHB  = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
  PXB  = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
  PIX  = Connection traversing at most a single PCIe bridge
  NV#  = Connection traversing a bonded set of # NVLinks

NIC Legend:

  NIC0: mlx5_0
  NIC1: mlx5_1

🐛 Describe the bug

This fixes an illegal memory access during the execution of the fp8 CUTLASS kernels during the execution of a 20b granite model. At least until we know what's going on, let's revert back to scaled_mm.

To repro:
First apply this small patch:

diff --git a/vllm/model_executor/models/gpt_bigcode.py b/vllm/model_executor/models/gpt_bigcode.py
index 69b75763..f3df6337 100644
--- a/vllm/model_executor/models/gpt_bigcode.py
+++ b/vllm/model_executor/models/gpt_bigcode.py
@@ -299,4 +299,10 @@ class GPTBigCodeForCausalLM(nn.Module):
             param = params_dict[name]
             weight_loader = getattr(param, "weight_loader",
                                     default_weight_loader)
-            weight_loader(param, loaded_weight)
+
+            if "c_attn.input_scale" in name or "c_attn.weight_scale" in name:
+                weight_loader(param, loaded_weight, 'q')
+                weight_loader(param, loaded_weight, 'k')
+                weight_loader(param, loaded_weight, 'v')
+            else:
+                weight_loader(param, loaded_weight)
python3 -m "vllm.entrypoints.openai.api_server" --model nm-testing/granite-20b-code-base-FP8

A couple more threads to pull on:
If I define the following at the top of scaled_mm_dq_c3x.cu

#define CUTLASS_DEBUG_TRACE_LEVEL 1

I see

temp.linux-x86_64-3.10/_deps/cutlass-src/include/cutlass/gemm/device/gemm_universal_adapter.h:412    Kernel launch failed. Reason: an illegal memory access was encountered

The arguments to the failing GEMM look valid, (alignments, strides, data types, device all look good), and in fact an identical looking GEMM has already been executed on the failing run in question.

@tlrmchlsmth tlrmchlsmth added the bug Something isn't working label Jun 13, 2024
@tlrmchlsmth tlrmchlsmth changed the title [Bug]: asdf [Bug]: Illegal memory access in CUTLASS FP8 kernels Jun 13, 2024
@tdoublep
Copy link
Member

@tlrmchlsmth Thanks a lot for creating this issue!

I also created PR #5460 containing the patch referenced above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants