179 questions
No questions match those filters.
← All questions
LLMOps & ProductionVery Hard· CUDA· Optimization· Memory Access
Your custom CUDA GeLU runs at 1.8 ms but PyTorch’s runs...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansThe performance gap is primarily due to two factors. First, using float32 instead of bfloat16 doubles the bytes moved per element; switching to bfloat16 halves HBM traffic and bandwidth costs. Second, the kernel likely uses scalar loads instead of vectorized loads. PyTorch’s kernel uses float4 memory instructions to load 4 values per thread, fully utilizing the 128-byte HBM cache line. To close the gap, modify the kernel to advance by BLOCK_SIZE × 4, use float4 loads, and process 4 elements per thread.