Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions challenges/medium/96_int8_kv_cache_attention/challenge.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,66 +9,6 @@
<code>float32</code>.
</p>

<svg width="700" height="270" viewBox="0 0 700 270" xmlns="http://www.w3.org/2000/svg" style="display:block; margin:20px auto;">
<rect width="700" height="270" fill="#222" rx="10"/>
<text x="350" y="26" fill="#ccc" font-family="monospace" font-size="13" text-anchor="middle">INT8 KV-Cache Attention — single token decode</text>

<!-- Q box -->
<rect x="20" y="45" width="80" height="36" fill="#2563eb" rx="4"/>
<text x="60" y="68" fill="#fff" font-family="monospace" font-size="12" text-anchor="middle">Q (fp32)</text>

<!-- K_int8 + scale -->
<rect x="130" y="45" width="100" height="36" fill="#7c3aed" rx="4"/>
<text x="180" y="63" fill="#fff" font-family="monospace" font-size="11" text-anchor="middle">K_int8 (int8)</text>
<rect x="130" y="90" width="100" height="28" fill="#5b21b6" rx="4"/>
<text x="180" y="109" fill="#fff" font-family="monospace" font-size="11" text-anchor="middle">k_scale (fp32)</text>

<!-- V_int8 + scale -->
<rect x="260" y="45" width="100" height="36" fill="#065f46" rx="4"/>
<text x="310" y="63" fill="#fff" font-family="monospace" font-size="11" text-anchor="middle">V_int8 (int8)</text>
<rect x="260" y="90" width="100" height="28" fill="#064e3b" rx="4"/>
<text x="310" y="109" fill="#fff" font-family="monospace" font-size="11" text-anchor="middle">v_scale (fp32)</text>

<!-- dequant arrows -->
<line x1="180" y1="118" x2="180" y2="148" stroke="#a78bfa" stroke-width="1.5" marker-end="url(#arr2)"/>
<line x1="310" y1="118" x2="310" y2="148" stroke="#34d399" stroke-width="1.5" marker-end="url(#arr2)"/>
<text x="180" y="145" fill="#a78bfa" font-family="monospace" font-size="10" text-anchor="middle">×</text>
<text x="310" y="145" fill="#34d399" font-family="monospace" font-size="10" text-anchor="middle">×</text>

<!-- K_float, V_float -->
<rect x="130" y="155" width="100" height="28" fill="#4c1d95" rx="4"/>
<text x="180" y="174" fill="#e9d5ff" font-family="monospace" font-size="11" text-anchor="middle">K_float</text>
<rect x="260" y="155" width="100" height="28" fill="#022c22" rx="4"/>
<text x="310" y="174" fill="#6ee7b7" font-family="monospace" font-size="11" text-anchor="middle">V_float</text>

<!-- attention flow -->
<line x1="60" y1="81" x2="60" y2="210" stroke="#60a5fa" stroke-width="1.5"/>
<line x1="60" y1="210" x2="160" y2="210" stroke="#60a5fa" stroke-width="1.5" marker-end="url(#arr2)"/>
<line x1="180" y1="183" x2="180" y2="210" stroke="#a78bfa" stroke-width="1.5" marker-end="url(#arr2)"/>
<rect x="155" y="205" width="50" height="26" fill="#1e1b4b" rx="4"/>
<text x="180" y="222" fill="#c4b5fd" font-family="monospace" font-size="10" text-anchor="middle">scores</text>
<line x1="205" y1="218" x2="250" y2="218" stroke="#e5e7eb" stroke-width="1.5" marker-end="url(#arr2)"/>
<rect x="250" y="205" width="70" height="26" fill="#1e293b" rx="4"/>
<text x="285" y="222" fill="#93c5fd" font-family="monospace" font-size="10" text-anchor="middle">softmax</text>
<line x1="320" y1="218" x2="360" y2="218" stroke="#e5e7eb" stroke-width="1.5" marker-end="url(#arr2)"/>
<line x1="310" y1="183" x2="370" y2="218" stroke="#34d399" stroke-width="1.5"/>
<rect x="360" y="205" width="60" height="26" fill="#1a2e1a" rx="4"/>
<text x="390" y="222" fill="#86efac" font-family="monospace" font-size="10" text-anchor="middle">output</text>

<!-- formula text -->
<text x="470" y="75" fill="#93c5fd" font-family="monospace" font-size="11">K[h,s,:] = K_int8[h,s,:] × k_scale[h,s]</text>
<text x="470" y="95" fill="#6ee7b7" font-family="monospace" font-size="11">V[h,s,:] = V_int8[h,s,:] × v_scale[h,s]</text>
<text x="470" y="125" fill="#fde68a" font-family="monospace" font-size="11">scores[h,s] = Q[h,:]·K[h,s,:] / √head_dim</text>
<text x="470" y="145" fill="#fde68a" font-family="monospace" font-size="11">w[h,:] = softmax(scores[h,:])</text>
<text x="470" y="165" fill="#fde68a" font-family="monospace" font-size="11">out[h,:] = Σ_s w[h,s] · V[h,s,:]</text>

<defs>
<marker id="arr2" markerWidth="6" markerHeight="6" refX="3" refY="3" orient="auto">
<path d="M0,0 L0,6 L6,3 z" fill="#888"/>
</marker>
</defs>
</svg>

<h2>Implementation Requirements</h2>
<ul>
<li>Implement the function <code>solve(Q, K_int8, V_int8, k_scale, v_scale, output, num_heads, seq_len, head_dim)</code>.</li>
Expand Down
Loading