शुरुआत में लोकल लार्ज लैंग्वेज मॉडल्स (LLMs) बिजली की तरह तेज़ महसूस होते हैं। आप एक 7B या 13B पैरामीटर वाला मॉडल लोड करते हैं, एक छोटा प्रॉम्प्ट देते हैं, और टोकन स्क्रीन पर एक आरामदायक गति से बहने लगते हैं। फिर आप एक लंबा कोड ब्लॉक पेस्ट करते हैं, या आपकी चैट हिस्ट्री दर्जनों टर्न तक बढ़ जाती है, और मॉडल रेंगने लगता है। यह सुस्ती (slowdown) शायद ही कभी धीरे-धीरे आती है। यह एक ढलान (cliff) की तरह होती है। एक पल में GPU टोकन बना रहा होता है; अगले ही पल, आपका सिस्टम मॉनिटर मेमोरी प्रेशर बढ़ते हुए दिखाता है और जनरेशन (generation) अटक-अटक कर चलने लगती है। आप किसी सटीक फॉर्मूले से यह अनुमान नहीं लगा सकते कि यह कब होगा। आपका एकमात्र भरोसेमंद गाइड स्वयं हार्डवेयर ही है।

कॉन्टेक्स्ट (Context) की छिपी हुई लागत

आपके द्वारा जनरेट किया गया हर टोकन KV cache में स्टेट (state) जोड़ता है। यह कैश prefill और generation चरणों के दौरान कंप्यूट किए गए keys और values को स्टोर करता है, और यह आपके मॉडल वेट्स (weights), अटेंशन बफ़र्स (attention buffers) और रनटाइम ओवरहेड के साथ मेमोरी में रहता है। 12 GB या 16 GB VRAM वाले एक सामान्य कंज्यूमर GPU पर, KV cache अंततः अन्य सभी चीज़ों के साथ जगह के लिए प्रतिस्पर्धा करता है। जब डेडिकेटेड वीडियो मेमोरी भर जाती है, तो ऑपरेटिंग सिस्टम कोई एरर देकर रुक नहीं जाता। यह चुपचाप ओवरफ्लो को शेयर्ड मेमोरी (shared memory) में डाल देता है, और PCIe बस के माध्यम से GPU और सिस्टम RAM के बीच डेटा को इधर-उधर भेजता रहता है। वह बस फ़ाइल ट्रांसफर के लिए तो तेज़ है, लेकिन ग्राफ़िक्स कार्ड के अंदर की मेमोरी बैंडविड्थ की तुलना में बहुत धीमी है। इसका परिणाम प्रदर्शन में मामूली गिरावट नहीं, बल्कि पूरी तरह से पतन (collapse) है।

तीन संकेत कि 'क्लिफ' (Cliff) आ चुका है

मॉडल चलते समय अपने हार्डवेयर मॉनिटर्स पर नज़र रखें। प्रदर्शन में गिरावट (performance cliff) आते ही आपको तीन स्पष्ट संकेत दिखाई देंगे।

  • Shared VRAM बढ़ना। यह वह मेमोरी है जिसे GPU ड्राइवर ने डेडिकेटेड वीडियो RAM से निकालकर होस्ट ऑपरेटिंग सिस्टम द्वारा प्रबंधित पूल में डाल दिया है। जिस क्षण यह मेट्रिक शून्य से ऊपर बढ़ता है, समझ लीजिए कि आप सीमा पार कर चुके हैं।
  • System RAM का उपयोग बढ़ना। ओवरफ्लो को कहीं न कहीं तो पहुँचना ही होगा, और वह स्थान आपकी मुख्य मेमोरी है। यदि मॉडल टोकन जनरेट करते समय आपकी RAM का उपयोग बढ़ता है, तो इसका मतलब है कि डेटा को GPU से हटाया (offload) जा रहा है।
  • Eval स्पीड का आधा या उससे अधिक कम होना। 10% की सुस्ती का मतलब थर्मल थ्रॉटलिंग (thermal throttling) या बैकग्राउंड प्रोसेस हो सकता है। लेकिन 50% की गिरावट, या उससे भी बदतर, का मतलब है कि बॉटलनेक (bottleneck) टेंसर कोर (tensor cores) से हटकर मेमोरी बैंडविड्थ और PCIe लेटेंसी (latency) पर आ गया है। जब आप जनरेशन को डबल डिजिट से सिंगल डिजिट में गिरते हुए देखते हैं, तो समझ लें कि आप पहले ही ढलान से नीचे गिर चुके हैं।

आपका क्विक बेंचमार्क शायद आपको धोखा दे रहा है

एक छोटा स्मोक टेस्ट आपको झूठा आत्मविश्वास दे सकता है। यदि आप सौ-टोकन वाले प्रॉम्प्ट के साथ मॉडल का बेंचमार्क करते हैं, अच्छा थ्रूपुट (throughput) देखते हैं, और काम खत्म मान लेते हैं, तो आपने केवल 'हनीमून फेज' को मापा है। KV cache लगभग खाली होता है। लेयर्स पर लंबे prefill का दबाव नहीं पड़ा होता है। असली फुटप्रिंट (footprint) तभी सामने आता है जब मॉडल एक बड़ा प्रॉम्प्ट प्रोसेस कर लेता है और कैश अपने वास्तविक वर्किंग साइज तक भर जाता है। आपको डीप prefill और लंबे जनरेशन रन के साथ टेस्ट करना चाहिए। कॉन्टेक्स्ट को वास्तव में जमा होने दें। तभी मेमोरी प्रेशर स्थिर होगा और आपको वास्तविक सीमा दिखाएगा।

llama.cpp के साथ अपनी सीमा का पता लगाना

यदि आप llama.cpp के माध्यम से मॉडल चला रहे हैं, तो आप सरल अंकगणित और एक धैर्यपूर्ण टेस्ट रन के साथ अपनी सीमा को माप सकते हैं।

1. शेयर्ड मेमोरी (shared memory) के उपयोग को मापें।
एक न्यूनतम प्रॉम्प्ट के साथ अपने बेसलाइन डेडिकेटेड VRAM को रिकॉर्ड करें, फिर एक लॉन्ग-कॉन्टेक्स्ट टास्क चलाएं और पीक (peak) नोट करें। पीक में से बेसलाइन को घटा दें। अंतर वह मात्रा है जो आपके GPU से निकलकर शेयर्ड सिस्टम मेमोरी में चली गई है।

2. अपने RAM डेल्टा (delta) की गणना करें।
सिस्टम RAM के लिए भी यही घटाव करें। लॉन्ग रन के दौरान पीक RAM में से अपनी बेसलाइन RAM घटाएं। यह संख्या आपको सटीक रूप से बताती है कि वीडियो कार्ड से आपकी मुख्य मेमोरी में कितना डेटा भेजा गया है। यह बस (bus) के माध्यम से होने वाले रिसाव (leak) को मापता है।

3. Eval स्पीड के गिरने के समय को मापें।
अपने बेसलाइन टोकन-प्रति-सेकंड (tokens-per-second) रेट की तुलना उस रेट से करें जो मॉडल द्वारा एक लंबा दस्तावेज़ प्रोसेस करने के बाद मिलता है। आप देख सकते हैं कि कॉन्टेक्स्ट नया होने पर मॉडल सत्रह टोकन प्रति सेकंड की गति से चलता है, लेकिन कैश भरने के बाद केवल दो टोकन प्रति सेकंड ही दे पाता है। टोकन में वह पंद्रह की गिरावट आपके लिए खतरे की घंटी है।

ब्रेकिंग पॉइंट (Breaking Point) का पता लगाना

To map the curve accurately, do not settle for one lonely data point. Run three distinct trials at 16,000 tokens, 32,000 tokens, and 65,000 tokens. Two points might suggest a line, but two dots are just a guess. The third point proves whether you are looking at measurement noise or a real memory wall. Subtract the results between runs to calculate how much extra memory each additional thousand tokens consumes on your specific combination of model, quantization layer, and GPU.

Once you have that slope, you can project forward. Take your per-token cost, multiply it by the target context length, divide by 1024 to move between units, and add the result to your base model VRAM load. The equation looks like this:

Model VRAM load + (tokens × memory per token ÷ 1024) = Theoretical VRAM usage

This projection is not prophecy. It is a guidepost derived from actual behavior. Use it to estimate your ceiling before you commit to a full production run.

Why Paper Formulas Fail, and What Quantization Can Fix

Textbook formulas ignore the messy reality of local inference. Different architectures allocate attention buffers differently. Your operating system reserves VRAM for the display driver, compositor, and CUDA context. Driver versions change how aggressively they use shared memory. A theoretical equation cannot know how much VRAM is actually free on your machine at 2:00 PM with a browser full of tabs open. You have to run the model on your specific hardware and watch the meters.

Quantization offers partial relief. Moving the KV cache from f16 to q8_0 halves its memory footprint while keeping precision high enough for nearly all practical tasks. That change buys you headroom. It does not grant immunity. The cache still grows linearly with every token you feed in. Eventually, even the reduced size overwhelms your available dedicated memory and the spillover to system RAM begins. The pressure only stops when the context window is capped or the data stops moving.

The Real Takeaway

Do not trust marketing slides, parameter counts, or back-of-the-envelope math. Load the model. Open your system monitor. Run a 65,000-token thread, watch the RAM climb, and count the tokens per second. The numbers that appear on your specific screen, on your specific GPU, are the only numbers that matter. Context always wins. Your job is to know exactly when it wins on your machine.