Coursework for CMU 11-868: Large Language Model Systems.
Python
24
103 commits
updated Aug 28, 2025
This repository documents my implementations for the assignments of the CMU course 11-868: Large Language Model Systems.
Here are some important notes and fixes I encountered while completing the assignments. These may be helpful for debugging or avoiding common pitfalls.
HW1 (autodiff): Crucial Gradient Initialization
In the autodiff part of HW1, it is essential to initialize all gradients to zero. Failing to do so can cause all backward tests in HW3 to fail unexpectedly.
HW2: Correcting CUDA Grid Dimensions
In HW2, a small but important modification to the grid dimensions in the CUDA kernel is recommended for correctness. Specifically, swap the order of m and p when calculating gridDims.
Original:
dim3 gridDims((m + threadsPerBlock - 1) / threadsPerBlock, (p + threadsPerBlock - 1) / threadsPerBlock, batch);
Modified:
dim3 gridDims((p + threadsPerBlock - 1) / threadsPerBlock, (m + threadsPerBlock - 1) / threadsPerBlock, batch);
HW4 (cuda_kernel_ops): Replacing pycuda.autoinit
The import pycuda.autoinit in HW4 can be intrusive. It's better to replace it with a more compatible PyTorch-based initialization method.
import pycuda.autoinit
import torch
if torch.cuda.is_available():
# This line gently ensures PyTorch handles CUDA initialization,
# which is less intrusive than pycuda.autoinit.
_ = torch.tensor([1.0]).cuda()
import torch statements later in the file.HW6: Python Version for Conda Environment
For HW6, the required environment uses Python 3.10, not 3.9. When creating the Conda environment, be sure to specify the correct version:
conda create --name your_env_name python=3.10
Python
88.7%
Cuda
8.4%
C++
2.9%
Coursework for CMU 11-868: Large Language Model Systems.
Python
24
103 commits
updated Aug 28, 2025
This repository documents my implementations for the assignments of the CMU course 11-868: Large Language Model Systems.
Here are some important notes and fixes I encountered while completing the assignments. These may be helpful for debugging or avoiding common pitfalls.
HW1 (autodiff): Crucial Gradient Initialization
In the autodiff part of HW1, it is essential to initialize all gradients to zero. Failing to do so can cause all backward tests in HW3 to fail unexpectedly.
HW2: Correcting CUDA Grid Dimensions
In HW2, a small but important modification to the grid dimensions in the CUDA kernel is recommended for correctness. Specifically, swap the order of m and p when calculating gridDims.
Original:
dim3 gridDims((m + threadsPerBlock - 1) / threadsPerBlock, (p + threadsPerBlock - 1) / threadsPerBlock, batch);
Modified:
dim3 gridDims((p + threadsPerBlock - 1) / threadsPerBlock, (m + threadsPerBlock - 1) / threadsPerBlock, batch);
HW4 (cuda_kernel_ops): Replacing pycuda.autoinit
The import pycuda.autoinit in HW4 can be intrusive. It's better to replace it with a more compatible PyTorch-based initialization method.
import pycuda.autoinit
import torch
if torch.cuda.is_available():
# This line gently ensures PyTorch handles CUDA initialization,
# which is less intrusive than pycuda.autoinit.
_ = torch.tensor([1.0]).cuda()
import torch statements later in the file.HW6: Python Version for Conda Environment
For HW6, the required environment uses Python 3.10, not 3.9. When creating the Conda environment, be sure to specify the correct version:
conda create --name your_env_name python=3.10
Python
88.7%
Cuda
8.4%
C++
2.9%