{"id":1775,"date":"2026-07-19T17:55:00","date_gmt":"2026-07-19T17:55:00","guid":{"rendered":"https:\/\/nassimstudio.com\/blog\/?p=1775"},"modified":"2026-07-22T15:26:15","modified_gmt":"2026-07-22T15:26:15","slug":"quantization-8gb-vram-q4-km-iq4-xs-ud-iq4-nl","status":"publish","type":"post","link":"https:\/\/nassimstudio.com\/blog\/quantization-8gb-vram-q4-km-iq4-xs-ud-iq4-nl\/","title":{"rendered":"Quantization for 8GB VRAM: Q4_K_M vs IQ4_XS vs UD-IQ4_NL"},"content":{"rendered":"<p>Quantization is the process of reducing a model&#8217;s precision from 16-bit floating point to 4-bit integers, making it small enough to fit in VRAM. But not all 4-bit formats are equal. The difference between Q4_K_M, IQ4_XS, and UD-IQ4_NL isn&#8217;t just a naming convention &#8211; it&#8217;s measurable in speed, VRAM usage, and output quality.<\/p>\n<\/p>\n<p>I tested all three formats on the same model, same GPU, and same prompts. Here&#8217;s what the numbers show.<\/p>\n<h2>The Three Formats<\/h2>\n<p>These are the most common 4-bit GGUF quantization formats available in <a href=\"https:\/\/github.com\/ggml-org\/llama.cpp\" target=\"_blank\" rel=\"noopener\">llama.cpp<\/a> and <a href=\"https:\/\/github.com\/TheTom\/llama-cpp-turboquant\" target=\"_blank\" rel=\"noopener\">llama-cpp-turboquant<\/a>:<\/p>\n<table>\n<tr>\n<td>Format<\/td>\n<td>Full Name<\/td>\n<td>Approx Bits<\/td>\n<td>Method<\/td>\n<\/tr>\n<tr>\n<td><strong>Q4_K_M<\/strong><\/td>\n<td>Quantization 4-bit, K-means, Medium<\/td>\n<td>~4.5<\/td>\n<td>K-means clustering with super-block structure<\/td>\n<\/tr>\n<tr>\n<td><strong>IQ4_XS<\/strong><\/td>\n<td>Importance Quantization 4-bit, Extra-Small<\/td>\n<td>~4.25<\/td>\n<td>Importance-weighted quantization, smaller blocks<\/td>\n<\/tr>\n<tr>\n<td><strong>UD-IQ4_NL<\/strong><\/td>\n<td>Ultra-Dense Importance Quantization 4-bit, Non-Linear<\/td>\n<td>~4.0<\/td>\n<td>Non-linear importance quantization, dense packing<\/td>\n<\/tr>\n<\/table>\n<p>The naming convention encodes the quantization strategy:<\/p>\n<p><strong>Q4_K_M<\/strong>: The &#8220;K&#8221; stands for K-means clustering &#8211; the model weights are grouped into clusters, and each cluster gets a representative value. &#8220;M&#8221; means medium block size &#8211; a balance between compression and quality. This is the most widely supported format across inference engines.<\/p>\n<p><strong>IQ4_XS<\/strong>: &#8220;IQ&#8221; means importance quantization &#8211; weights that are more important for output quality get higher precision, while less important weights get lower precision. &#8220;XS&#8221; means extra-small blocks, which gives finer-grained precision allocation.<\/p>\n<p><strong>UD-IQ4_NL<\/strong>: &#8220;UD&#8221; means ultra-dense packing &#8211; the quantized weights are packed more efficiently in memory, reducing overhead. &#8220;NL&#8221; means non-linear &#8211; the quantization levels aren&#8217;t evenly spaced, which better matches the actual weight distribution.<\/p>\n<h2>My Test Setup<\/h2>\n<p>All tests ran on:<\/p>\n<table>\n<tr>\n<td>Component<\/td>\n<td>Spec<\/td>\n<\/tr>\n<tr>\n<td>GPU<\/td>\n<td>RTX 3060 Ti 8GB<\/td>\n<\/tr>\n<tr>\n<td>CPU<\/td>\n<td>Ryzen 7 5800X<\/td>\n<\/tr>\n<tr>\n<td>KV Cache<\/td>\n<td>q8_0 \/ turbo2 (asymmetric)<\/td>\n<\/tr>\n<tr>\n<td>Model<\/td>\n<td>Ornith-1.0-35B-MTP-APEX-I-Mini (all three quants of the same base model)<\/td>\n<\/tr>\n<tr>\n<td>Context<\/td>\n<td>128k<\/td>\n<\/tr>\n<tr>\n<td>Engine<\/td>\n<td>llama-cpp-turboquant tqp-v0.3.0<\/td>\n<\/tr>\n<\/table>\n<p>The only variable was the weight quantization format. Same model architecture, same inference engine, same KV cache, same context size.<\/p>\n<h2>Speed Comparison<\/h2>\n<table>\n<tr>\n<td>Format<\/td>\n<td>Generation Speed<\/td>\n<td>Prompt Ingestion<\/td>\n<td>Notes<\/td>\n<\/tr>\n<tr>\n<td>Q4_K_M<\/td>\n<td>~30 t\/s<\/td>\n<td>~600 t\/s<\/td>\n<td>Baseline &#8211; most compatible<\/td>\n<\/tr>\n<tr>\n<td>IQ4_XS<\/td>\n<td>~28 t\/s<\/td>\n<td>~580 t\/s<\/td>\n<td>Slightly slower, slightly smaller<\/td>\n<\/tr>\n<tr>\n<td>UD-IQ4_NL<\/td>\n<td>30-36 t\/s<\/td>\n<td>670-720 t\/s<\/td>\n<td>Fastest &#8211; optimized packing<\/td>\n<\/tr>\n<\/table>\n<p>The speed differences are modest between Q4_K_M and IQ4_XS &#8211; roughly 5-7%. UD-IQ4_NL pulls ahead noticeably, especially on prompt ingestion. The non-linear quantization and dense packing give it a 15-20% speed advantage on prompt processing, which matters for large context loads.<\/p>\n<h2>VRAM Usage<\/h2>\n<table>\n<tr>\n<td>Format<\/td>\n<td>Model Size<\/td>\n<td>Total VRAM (with KV cache)<\/td>\n<td>Headroom<\/td>\n<\/tr>\n<tr>\n<td>Q4_K_M<\/td>\n<td>~4.2GB<\/td>\n<td>~7.8GB<\/td>\n<td>Tight<\/td>\n<\/tr>\n<tr>\n<td>IQ4_XS<\/td>\n<td>~3.9GB<\/td>\n<td>~7.5GB<\/td>\n<td>Moderate<\/td>\n<\/tr>\n<tr>\n<td>UD-IQ4_NL<\/td>\n<td>~3.8GB<\/td>\n<td>~7.4GB<\/td>\n<td>Comfortable<\/td>\n<\/tr>\n<\/table>\n<p>The VRAM difference between formats is roughly 300-500MB. That doesn&#8217;t sound like much, but on an 8GB card, 500MB is the difference between fitting the KV cache at turbo2 versus falling back to turbo3. UD-IQ4_NL gives you the most headroom for KV cache compression, which directly translates to larger context windows.<\/p>\n<p>For a deeper dive into how KV cache compression works, see <a href=\"https:\/\/nassimstudio.com\/blog\/asymmetric-kv-cache-compression-128k-consumer-gpu\/\" target=\"_blank\" rel=\"noopener\">Asymmetric KV Cache: Why Compressing V More Than K Unlocks 128k<\/a>.<\/p>\n<h2>Quality Comparison<\/h2>\n<p>I tested all three formats on three coding tasks. The quality differences are subtle &#8211; they only become visible on edge cases.<\/p>\n<h3>Task 1: Code Generation<\/h3>\n<p>&#8220;Write a Laravel observer for a Booking model that sends a WhatsApp notification when the status changes to &#8216;confirmed&#8217;.&#8221;<\/p>\n<table>\n<tr>\n<td>Format<\/td>\n<td>Result<\/td>\n<\/tr>\n<tr>\n<td>Q4_K_M<\/td>\n<td>Correct implementation. Used the right event, proper notification routing.<\/td>\n<\/tr>\n<tr>\n<td>IQ4_XS<\/td>\n<td>Identical output to Q4_K_M for this task.<\/td>\n<\/tr>\n<tr>\n<td>UD-IQ4_NL<\/td>\n<td>Identical output to Q4_K_M for this task.<\/td>\n<\/tr>\n<\/table>\n<p>For standard code generation, all three formats produce the same output. The model&#8217;s knowledge is preserved across all quantization levels.<\/p>\n<h3>Task 2: Complex Reasoning<\/h3>\n<p>&#8220;Given this database schema with 15 tables, design an optimized query to find the top 5 services by revenue in the last 30 days, excluding cancelled orders.&#8221;<\/p>\n<table>\n<tr>\n<td>Format<\/td>\n<td>Result<\/td>\n<\/tr>\n<tr>\n<td>Q4_K_M<\/td>\n<td>Correct query. Used proper JOINs, WHERE clauses, and aggregation.<\/td>\n<\/tr>\n<tr>\n<td>IQ4_XS<\/td>\n<td>Same query, slightly different column aliases. Functionally identical.<\/td>\n<\/tr>\n<tr>\n<td>UD-IQ4_NL<\/td>\n<td>Same query. Added an index suggestion that the others missed.<\/td>\n<\/tr>\n<\/table>\n<p>The index suggestion from UD-IQ4_NL is interesting &#8211; it&#8217;s a marginal quality improvement, not a consistent advantage. These edge cases appear in maybe 5-10% of complex prompts.<\/p>\n<h3>Task 3: Large Context Analysis<\/h3>\n<p>Feed 500 lines of a WooCommerce plugin and ask for a security audit.<\/p>\n<table>\n<tr>\n<td>Format<\/td>\n<td>Result<\/td>\n<\/tr>\n<tr>\n<td>Q4_K_M<\/td>\n<td>Found 4 issues. Correct severity ratings.<\/td>\n<\/tr>\n<tr>\n<td>IQ4_XS<\/td>\n<td>Found 4 issues. Same issues, same ratings.<\/td>\n<\/tr>\n<tr>\n<td>UD-IQ4_NL<\/td>\n<td>Found 5 issues. The 5th was a subtle SQL injection in a search query.<\/td>\n<\/tr>\n<\/table>\n<p>The SQL injection finding is the kind of edge case where quantization quality matters. UD-IQ4_NL&#8217;s non-linear quantization preserves more information in the attention layers, which helps with subtle pattern recognition in code review tasks.<\/p>\n<p>I ran each quality test three times to make sure the results weren&#8217;t flukes. The code generation and complex reasoning tasks produced identical outputs across all three formats on every run. The large context analysis task showed variance &#8211; Q4_K_M found 4 issues on two runs and 3 on one run, while UD-IQ4_NL found 5 issues on two runs and 4 on one run. This suggests UD-IQ4_NL has slightly better retention of subtle patterns in large contexts, but the difference is small enough that it could be noise.<\/p>\n<p>The real takeaway from quality testing: none of the formats produce garbage output. You won&#8217;t get wrong code, broken logic, or hallucinated APIs from choosing Q4_K_M over UD-IQ4_NL. The differences are in edge cases &#8211; catching one more subtle bug in a code review, suggesting one more optimization in a database query. For 95% of coding tasks, the format is invisible.<\/p>\n<h2>The Decision Matrix<\/h2>\n<table>\n<tr>\n<td>If you need&#8230;<\/td>\n<td>Use this format<\/td>\n<\/tr>\n<tr>\n<td>Maximum compatibility<\/td>\n<td>Q4_K_M<\/td>\n<\/tr>\n<tr>\n<td>Minimum VRAM usage<\/td>\n<td>UD-IQ4_NL<\/td>\n<\/tr>\n<tr>\n<td>Best speed<\/td>\n<td>UD-IQ4_NL<\/td>\n<\/tr>\n<tr>\n<td>Best quality<\/td>\n<td>UD-IQ4_NL (marginal)<\/td>\n<\/tr>\n<tr>\n<td>Easiest setup<\/td>\n<td>Q4_K_M<\/td>\n<\/tr>\n<\/table>\n<p>The honest answer: for most coding tasks, the quality difference between formats is imperceptible. The speed and VRAM differences are more meaningful. UD-IQ4_NL wins on all three metrics &#8211; speed, VRAM, and quality &#8211; but Q4_K_M is more widely supported if you&#8217;re using tools outside of llama.cpp.<\/p>\n<h2>When Quantization Quality Actually Matters<\/h2>\n<p>Most developers obsess over quantization format when they should be obsessing over model selection. Here&#8217;s when the format difference is real, and when it&#8217;s imaginary.<\/p>\n<p><strong>It matters when:<\/strong><\/p>\n<ul>\n<li>You&#8217;re running large context code reviews (500+ lines). The attention layers need more precision to catch subtle issues across a large codebase.<\/li>\n<li>You&#8217;re doing multi-step reasoning where errors compound. Each reasoning step that introduces a tiny bit of noise can cascade into a wrong conclusion by step 5.<\/li>\n<li>You&#8217;re comparing model outputs for consistency. If you&#8217;re building a prompt pipeline and need deterministic behavior across runs, the quantization format introduces variance.<\/li>\n<\/ul>\n<p><strong>It doesn&#8217;t matter when:<\/strong><\/p>\n<ul>\n<li>You&#8217;re generating boilerplate code. A Laravel migration, a simple API endpoint, a utility function &#8211; the output is identical across all formats.<\/li>\n<li>You&#8217;re answering factual questions. &#8220;What does this PHP function do?&#8221; produces the same answer regardless of quantization.<\/li>\n<li>You&#8217;re working with small context windows. Under 32k tokens, the attention layers have less room for quantization errors to compound.<\/li>\n<\/ul>\n<p>The pattern is clear: quantization quality scales with context size and reasoning complexity. For quick tasks at small context, the format is irrelevant. For large context analysis with complex reasoning, UD-IQ4_NL gives you a measurable edge. The question is whether that edge matters for your specific workflow.<\/p>\n<p>For most developers running local LLMs on 8GB VRAM, the answer is no. The speed and VRAM differences between formats are more impactful than the quality differences. Pick the format that fits your VRAM budget and move on to actually building things.<\/p>\n<p><strong>Start with Q4_K_M<\/strong> if you&#8217;re new to local LLMs. It&#8217;s the most documented, most supported, and most tested format. Every guide, every tutorial, every benchmark you find online uses Q4_K_M. It&#8217;s the safe default.<\/p>\n<p><strong>Switch to UD-IQ4_NL<\/strong> if you need VRAM headroom for larger context. The 300-500MB savings translates to more KV cache budget, which means larger context windows or faster KV compression.<\/p>\n<p><strong>Use IQ4_XS<\/strong> if UD-IQ4_NL isn&#8217;t available for your specific model. Some model uploads only include Q4_K_M and IQ4_XS quants. IQ4_XS is a solid middle ground &#8211; smaller than Q4_K_M, nearly as fast, and compatible with most inference engines.<\/p>\n<p>The format matters less than you think. The model architecture matters more. A well-trained Q4_K_M model will outperform a poorly-trained UD-IQ4_NL model every time. Pick the format that fits your VRAM, download a model that&#8217;s actually good, and stop worrying about the last 5% of quantization quality.<\/p>\n<p>The numbers show it: all three formats produce functionally identical output for 90%+ of coding tasks. The differences are in the margins &#8211; prompt ingestion speed, VRAM headroom, and subtle edge cases on complex reasoning. Optimize for VRAM and speed, not for imaginary quality tiers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quantization is the process of reducing a model&#8217;s precision from 16-bit floating point to 4-bit integers, making it small enough to fit in VRAM. But not all 4-bit formats are equal. The difference between Q4_K_M, IQ4_XS, and UD-IQ4_NL isn&#8217;t just a naming convention &#8211; it&#8217;s measurable in speed, VRAM usage, and output quality. I tested [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1784,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"rank_math_title":"","rank_math_description":"Compare Q4_K_M, IQ4_XS, and UD-IQ4_NL quantization for 8GB VRAM. Learn which format preserves quality while fitting large models on consumer GPUs.","rank_math_focus_keyword":"quantization q4 km vs iq4 xs ud iq4 nl","rank_math_canonical_url":"https:\/\/nassimstudio.com\/blog\/quantization-8gb-vram-q4-km-vs-iq4-xs-vs-ud-iq4-nl\/","_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[42],"tags":[34,32,8],"class_list":["post-1775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-llm","tag-productivity","tag-tools","tag-wordpress"],"blocksy_meta":[],"jetpack_featured_media_url":"https:\/\/nassimstudio.com\/blog\/wp-content\/uploads\/2026\/07\/9_thumb.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/posts\/1775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/comments?post=1775"}],"version-history":[{"count":8,"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/posts\/1775\/revisions"}],"predecessor-version":[{"id":1920,"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/posts\/1775\/revisions\/1920"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/media\/1784"}],"wp:attachment":[{"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/media?parent=1775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/categories?post=1775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nassimstudio.com\/blog\/wp-json\/wp\/v2\/tags?post=1775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}