UUtah CS 6340 NLP | Fall 2026 | LLM efficiency: quantization, LoRA
Overview
The lecture explains two ways to make large language models more efficient: quantization reduces the memory used by model weights, while LoRA reduces the number of parameters that must be trained. It covers linear quantization, precision and outlier tradeoffs, Hugging Face loading, and LoRA’s low-rank adapter design, then previews QLoRA and further adapter-training choices for the next lecture.
Key takeaways
- Quantization reduces model-weight storage by representing values with fewer bits; the lecture estimates that a 70-billion-parameter model drops from about 336 GB at 32-bit precision to roughly 42 GB at 4-bit precision.
- Quantization granularity balances accuracy against metadata overhead: per-channel or per-block ranges can limit outlier damage, but each additional scale and zero point consumes memory.
- Post-training quantization is presented as the practical default for pretrained models, while training models from scratch at very low precision remains difficult to make competitive.
- LoRA fine-tunes a model by adding a low-rank update ΔW = BA to the reference weights, reducing the number of trainable values and the associated gradient and optimizer-state memory.
- For a 4096 by 4096 projection and rank-8 LoRA, the lecture estimates about 65,000 trainable adapter parameters instead of approximately 16 million full-matrix parameters.
- QLoRA combines quantized model weights with LoRA adapters to reduce fine-tuning resource requirements further.
Chapters
- The final practice assignment asks students to develop and verify an LLM-as-a-judge system, including Cohen's kappa and confidence intervals.
- The final practicum focuses on selecting tests to expose judge bias, rather than implementing the statistical functions.
- Undergraduates cannot revise this practicum, and the course also has one remaining quiz on efficiency.
- The next course unit covers efficient fine-tuning and inference for already post-trained models, rather than full pretraining.
- GPU memory holds model weights, activations, gradients, and Adam optimizer state, including moving averages of gradients and squared gradients.
- Autoregressive generation can reuse prior attention keys and values through caching instead of recomputing them for each token.
- GPU access has substantial hardware and cloud costs; the lecturer cites two 80 GB A100 GPUs plus supporting hardware costing about $60,000 in 2022.
- The lecture introduces weight compression and parameter-efficient fine-tuning, with quantization and LoRA as the main topics.
- A rough memory estimate multiplies parameter count by numeric precision and an approximate 1.2 overhead factor.
- A 70-billion-parameter model is estimated to need about 336 GB at 32-bit precision, while 4-bit storage can reduce that to roughly 42 GB.
- Reducing precision introduces quantization error, so the goal is to lower memory use without materially damaging model quality.
- Linear quantization maps a continuous range of floating-point weights into a finite integer range, such as signed 8-bit values from -128 to 127.
- Several original values may map to the same integer, forming a quantization bin.
- Symmetric quantization suits weights that are centered around zero; asymmetric quantization is useful for activations that may not be.
- Zero-centered symmetry does not mean zero mean, and layer normalization does not make every activation symmetric.
- The basic process finds the minimum and maximum of a weight tensor, then identifies the target integer range from the chosen bit width.
- A scale and zero point define how floating-point values map to integers; the zero point represents floating-point zero in the integer range.
- Quantized weights are stored in low precision and dequantized for computation, after which temporary higher-precision weights can be discarded.
- Quantization quality is assessed by comparing original weights with their dequantized reconstructions; large errors can affect downstream model performance.
- Using one minimum and maximum for an entire matrix can let a single outlier compress the useful range for most weights.
- Per-channel quantization calculates separate ranges and scale parameters for each row of a weight matrix.
- Per-group or per-block quantization applies separate ranges to smaller sections, such as windows of 128 values.
- Finer granularity can improve accuracy but requires more scale and zero-point metadata, reducing some memory benefits.
- An outlier, such as a value beyond a selected percentile, can dominate a block's range and reduce resolution for ordinary values.
- One option is to keep outliers in full precision while quantizing the remaining weights, a mixed-precision strategy.
- Smaller quantization blocks localize an outlier's effect to the block where it appears.
- For symmetric weight quantization, the integer range is centered around zero, so the mapping can use a scale without a separate zero point.
- Post-training quantization starts with a model trained at higher precision and quantizes it afterward; training from scratch at low precision is harder to make competitive.
- Activation ranges vary with each input token, so their minima and maxima cannot always be calculated once and reused like fixed model weights.
- The lecture previews quantizing the key-value cache as a later way to reduce the memory needed during generation.
- Hugging Face Transformers can load a causal language model with a BitsAndBytesConfig, for example by enabling 8-bit loading.
- The lecture describes 16-bit and 32-bit model precision as having a negligible practical difference for the discussed use case.
- Eight-bit quantization offers roughly a twofold memory reduction relative to 16-bit, and four-bit is often a useful tradeoff despite some quality degradation.
- Two-bit quantization is described as problematic for typical pretrained models, while very low-bit approaches such as BitNet are not presented as competitive general-purpose open-weight models.
- The practical goal is to fit the largest model that benefits the task within available GPU memory, not to quantize further without a reason.
- Parameter-efficient fine-tuning, or PEFT, updates only a subset of model parameters while leaving the rest unchanged.
- Full fine-tuning stores gradients and Adam state for trainable weights, so reducing the number of trainable parameters can substantially lower memory requirements.
- The lecture identifies LoRA as a widely used PEFT method and QLoRA as a combination of LoRA with quantization.
- Matrix rank is the maximum number of linearly independent rows or columns; a low-rank matrix can be represented as a product of smaller matrices.
- The lecture describes low intrinsic rank as an observed property of transformer weights, with an example contrasting a 128-dimensional representation with activation dimensions in the thousands.
- For a matrix with dimensions m by n and rank r, a factorization uses matrices of sizes m by r and r by n.
- When r is much smaller than m and n, training the factor matrices requires fewer parameters than updating the original matrix.
- LoRA represents fine-tuned weights as the reference weights W0 plus an update ΔW, rather than changing every entry of W0.
- The update is factored into adapter matrices B and A, with dimensions d by r and r by d, and only these adapter weights are trained.
- A low rank such as 8 can sharply reduce trainable parameters: for a 4096 by 4096 projection, the lecture compares about 16 million full parameters with roughly 65,000 adapter parameters.
- LoRA commonly scales its low-rank update using the hyperparameters alpha and r, with alpha helping control fine-tuning strength and stability.
- The scalar factor does not change the low-rank nature of the update because it can be absorbed into one adapter matrix.
- The remaining topics include which model weights to adapt, how to select rank, and how QLoRA combines quantization with LoRA.
- The lecturer recommends reviewing a LoRA hyperparameter guide before the next class, when QLoRA and additional adapter-training choices will be covered.
Transcript excerpt
0:00 Um so uh we continue with uh uh uh more more content. Um in regards to announcements uh I released a last practice assignment which is all about uh developing and verifying uh LLM as a judge. And um as I mentioned a few times before I really expect if you continue to do something with LLMs, you will be tasked to develop and verify LLM as a judge. So you know um if if you see yourself working with LLMs uh later be in research or in a company I would really uh encourage you to take this assignment seriously so you really practice that skill once. Uh in the assignment I added more of the content than I had in the lectures. uh um I mean
0:51 I had uh everything mentioned in my slides but I didn't go into details of what is coins kappa or bootstrapping and how we calculate confidence interval. My plan was that through this assignment you you practice uh and learn about those things. So it's a additional content to uh the lecture itself. uh practicum will be set up such that unlike in the assignment where I also ask you to implement coins kappa because I I feel like that through implementation sometimes we actually realize the concept um so I made you implement coins kappa and confidence intervals I will not ask you to implement those in the practicum so those functionalities will be given rather what I will test you on is whether you can find a bias
1:41 that LLM has. So I'm going to set up some kind of bias uh uh ver some some kind of bias judgment and you you will need to showcase that you know what kind of tests you can run to see whether
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, UofU Data Science.