멀티헤드 캐시
More KV heads scale cache bytes linearly.
로컬 계산 / 시뮬레이션외부 API 없는 로컬 교육용 실험입니다. 합성 데이터는 운영 환경 측정이 아닙니다.
Study guide & lesson outline
LEARNING CONTRACTUnderstand → implement → investigate
Goal: explain the mechanism in this lesson, reproduce one example and test a failure case. Reading alone does not mark mastery.
- Understand: state assumptions, shapes/units and a counterexample.
- Implement: reproduce a numerical example and inspect boundaries.
- Investigate: compare one alternative under a matched budget.
02 · 예측 및 설정
기술 설명, 매개변수 이름과 참고 답변은 현재 영어입니다.
03 · 근거 확인
방법과 참고 문헌
32 layers, head dimension 128. Dense cache only; excludes model weights, activations, block tables and sharing. Per-sequence allocation rounds up to the next page.
Text / 原始公式
KV bytes=2×layers×KV heads×head dimension×sequence×batch×bytes/value
An estimated cache footprint is not a measured GPU throughput or total memory requirement.
GQA (2023); PagedAttention (2023) ↗연습 문제
kv-2 / 01What does “Multi-head cache” test?
More KV heads scale cache bytes linearly.
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 02Which computation produces the result in “Multi-head cache”?
KV
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 03What is the baseline configuration for “Multi-head cache”?
{"sequence":4096,"batch":1,"heads":32,"bytes":2,"block":16}
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 04What numerical result should you check for “Multi-head cache”?
{"KV cache (GiB)":2,"Allocated KV (GiB)":2,"Padding tokens":0}
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 05How would you run a controlled comparison for “Multi-head cache”?
Keep the supplied fixture and other settings fixed; change sequence. Compare logical KV GiB, allocated GiB and padding tokens.
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 06What failure could invalidate a conclusion from “Multi-head cache”?
An estimated cache footprint is not a measured GPU throughput or total memory requirement.
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 07Is “Multi-head cache” a benchmark of a deployed language model?
No. 32 layers, head dimension 128. Dense cache only; excludes model weights, activations, block tables and sharing. Per-sequence allocation rounds up to the next page.
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 08Which evidence should you report for “Multi-head cache”?
Compare logical KV GiB, allocated GiB and padding tokens. Export inputs, engine, result and method; distinguish synthetic fixtures from observed production data.
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 09How can another researcher reproduce “Multi-head cache”?
Open kv-2, reset the preset, retain the exact inputs and run. The calculation is deterministic for identical inputs.
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →kv-2 / 10What is the next validation step after “Multi-head cache”?
An estimated cache footprint is not a measured GPU throughput or total memory requirement. Test the hypothesis on a representative held-out workload and document a baseline, success metric and stopping rule before claiming deployment readiness.
Original teaching answer / local derivation. Method reference: GQA (2023); PagedAttention (2023) ↗
실험 열기 →Assumptions, implementation & acceptance
Count both K and V, KV heads rather than query heads, and sequence×batch exactly once. The byte formula excludes activations, weights, allocator fragmentation and attention workspace.
Engine formulas, scenario presets and numerical safeguards reviewed. Seeded synthetic inputs are not a production benchmark.
Before running: predict a boundary case
More KV heads scale cache bytes linearly.
Hint: isolate the assumption
Keep the baseline input fixed, change one parameter or boundary, and compare both the numerical result and the claimed units. A passing example verifies this fixture only.
Minimal executable example
Save the example and linked modules in one folder. Use Node.js 22 or newer, then run node kv-2.mjs. No third-party runtime dependencies.
import {calculate,network} from './academy-core.mjs';
const params={
"sequence": 4096,
"batch": 1,
"heads": 32,
"bytes": 2,
"block": 16
};
const result=calculate('kv',params);
console.log(result.metrics);Test and transfer
More KV heads scale cache bytes linearly.
Record input, code version, expected result and observed result in the notebook below. Then construct a counterexample that violates the assumption above and explain why the original conclusion no longer follows.
Download complete kit (.tar.gz) · Complete reference kit and regression checksPredict, test and keep evidence
Before revealing an answer, predict one result. After the exercise, record the discrepancy and a transfer test. Saved locally across language editions.
Open notebook / export / clear →The mathematical review scope is recorded per lesson. It does not establish empirical paper reproduction; report suspected errors in your notes. Review scope