InoteveraGaidhi rinotevera
KV Cache (Kachengeta KV)
Mutauro AI
Nhungamiro yehunyanzvi
Iyo KV cache inochengeta makiyi uye inokoshesa transformer yatove computed saka haidzoreri basa kune yega tokeni nyowani - asi inogona kubharumu kune gigabytes.
Teerera kugwaro iriAI-yakarondedzerwa · ~2 min
KV cache optimization inodzikira uye inogadzirisa iyo ndangariro kuitira kuti mamodheru ashande marefu mamiriro kune vakawanda vashandisi kamwechete.
In a transformer, each new token attends to all previous tokens via attention's keys (K) and values (V). Recomputing K and V for the whole sequence at every step would be quadratic and wasteful, so models cache them: the KV cache. The downside is size. The cache grows linearly with sequence length, batch size, layers, and heads, so a long-context request can consume more GPU memory than the model weights themselves. Optimization tackles this from several angles: paged memory (vLLM's PagedAttention) stores the cache in non-contiguous blocks to reduce fragmentation and enable sharing; quantization stores K and V in 8-bit or 4-bit; and architectural changes like Grouped-Query Attention (GQA) and Multi-Query Attention (MQA) let many query heads share fewer key/value heads, slashing cache size at the source.
vLLM's PagedAttention serving many concurrent chat sessions by packing KV blocks while reducing memory fragmentation
Yakaungana-Mubvunzo Kutarisisa mumhando dzeLlama inoderedza saizi yeKV cache kuitira kuti mamiriro akareba akwane mundangariro yeGPU
Kuverengera iyo KV cache kusvika ku8-bit (KV8) kuita zvishoma nepakati cache ndangariro panguva refu-gwaro pfupiso.
Prefix caching inoshandisa zvakare maKV blocks eiyo yakagovaniswa sisitimu yekukurumidza muzviuru zvezvikumbiro zveAPI.
Sezvo mahwindo emukati anotambanudzira kumazana ezviuru kana mamirioni ezviratidzo, iyo KV cache inova iyo yakanyanya mutengo wekushandira. Tarisira kudzvinyirira cache uye kudzingwa (kudonhedza-yakaderera-kutarisisa tokeni), muchinjika-chikumbiro prefix kugovera seyakagadzika, kuburitsa inotonhora cache kuCPU kana NVMe, uye zvivakwa zvakaita seMLA neGQA zvichiva zvakajairika. Cache manejimendi ichawedzera kufanana neyakazara ndangariro hierarchy ine tiers uye smart prefetching.
Tsamba yemahara
Nhatu dzakasimbiswa dzeAI nyaya mangwanani ega ega pakati pevhiki, dzakanyorwa neChirungu chakajeka. Yemahara zvachose, hapana ads.
Imwe email zuva rega rega revhiki. Bvisa kunyoresa kamwe chete. Hatimbotengese kana kugovera kero yako.
Zviedze iwe pachako
Mhinduro yepakarepo pamhinduro yega yega, uye chitupa chinogovaniswa chine ID inobatika kana wapedza kosi.
Tsigira dzidzo yemahara yeAI. AI Understanding ndeye 501(c)(3) isingabatsiri - hapana ads, hapana paywall, zvachose. Ita chipo
Iyo KV cache inochengeta makiyi uye inokoshesa transformer yatove computed saka haidzoreri basa kune yega tokeni nyowani - asi inogona kubharumu kune gigabytes. KV cache optimization inodzikira uye inogadzirisa iyo ndangariro kuitira kuti mamodheru ashande marefu mamiriro kune vakawanda vashandisi kamwechete.
Caching makiyi uye kukosha kubva kune ekutanga tokens inodzivirira kudzoreredza kutarisisa komputa pane yega tokeni nyowani, kuchengetedza nguva.
Cache saizi zviyero zvine hurefu hwemamiriro uye concurrency, saka zvikumbiro zvenguva refu zvinogona kushandisa yakakura kwazvo yeGPU ndangariro.
PagedAttention inochengetedza cache mune isina-inobatika-yakagadziriswa-saizi mabhuroki akamepurwa netafura, senge OS paging.
Kugovera kiyi / kukosha misoro pamisoro yemibvunzo yakawanda kunoreva kushomeka kweK uye V mavheji ekuchengeta.
Iyo yakagovaniswa sisitimu yekumhanyisa inoburitsa yakafanana KV zvinyorwa, saka zvikumbiro zvakawanda zvinogona kunongedza kumabhuroko mamwe chete pane kuzvidzokorora.
Ramba uchidzidza
Mamwe madhairekitori akasarudzirwa nyaya iyi
InoteveraGaidhi rinotevera
KV Cache (Kachengeta KV)
Mutauro AI