92 lines
6.3 KiB
XML
92 lines
6.3 KiB
XML
<svg width="720" height="290" xmlns="http://www.w3.org/2000/svg">
|
|
<defs>
|
|
<marker id="ssm-arrow" markerWidth="7" markerHeight="5" refX="7" refY="2.5" orient="auto">
|
|
<polygon points="0 0, 7 2.5, 0 5" fill="#555"/>
|
|
</marker>
|
|
</defs>
|
|
<text x="360" y="22" fill="#333" font-size="14" font-weight="bold" text-anchor="middle">State Space Model: Dual View</text>
|
|
|
|
<!-- Recurrence view (top left) -->
|
|
<rect x="20" y="42" width="330" height="110" rx="10" fill="#3498db" opacity="0.05" stroke="#3498db" stroke-width="1.5"/>
|
|
<text x="185" y="62" fill="#3498db" font-size="11" font-weight="bold" text-anchor="middle">Recurrence View (Inference: O(1) per step)</text>
|
|
|
|
<!-- State boxes -->
|
|
<rect x="40" y="78" width="40" height="28" rx="4" fill="#3498db" opacity="0.15" stroke="#3498db" stroke-width="1.5"/>
|
|
<text x="60" y="96" fill="#3498db" font-size="9" text-anchor="middle">x₁</text>
|
|
|
|
<line x1="80" y1="92" x2="110" y2="92" stroke="#3498db" stroke-width="1.5" marker-end="url(#ssm-arrow)"/>
|
|
<text x="95" y="85" fill="#3498db" font-size="8" text-anchor="middle">Ā</text>
|
|
|
|
<rect x="115" y="78" width="40" height="28" rx="4" fill="#3498db" opacity="0.15" stroke="#3498db" stroke-width="1.5"/>
|
|
<text x="135" y="96" fill="#3498db" font-size="9" text-anchor="middle">x₂</text>
|
|
|
|
<line x1="155" y1="92" x2="185" y2="92" stroke="#3498db" stroke-width="1.5" marker-end="url(#ssm-arrow)"/>
|
|
<text x="170" y="85" fill="#3498db" font-size="8" text-anchor="middle">Ā</text>
|
|
|
|
<rect x="190" y="78" width="40" height="28" rx="4" fill="#3498db" opacity="0.15" stroke="#3498db" stroke-width="1.5"/>
|
|
<text x="210" y="96" fill="#3498db" font-size="9" text-anchor="middle">x₃</text>
|
|
|
|
<line x1="230" y1="92" x2="260" y2="92" stroke="#3498db" stroke-width="1.5" marker-end="url(#ssm-arrow)"/>
|
|
<text x="245" y="85" fill="#3498db" font-size="8" text-anchor="middle">Ā</text>
|
|
|
|
<rect x="265" y="78" width="40" height="28" rx="4" fill="#3498db" opacity="0.15" stroke="#3498db" stroke-width="1.5"/>
|
|
<text x="285" y="96" fill="#3498db" font-size="9" text-anchor="middle">x₄</text>
|
|
|
|
<!-- Input arrows up -->
|
|
<line x1="60" y1="125" x2="60" y2="108" stroke="#f39c12" stroke-width="1" marker-end="url(#ssm-arrow)"/>
|
|
<text x="60" y="137" fill="#f39c12" font-size="8" text-anchor="middle">u₁</text>
|
|
<line x1="135" y1="125" x2="135" y2="108" stroke="#f39c12" stroke-width="1" marker-end="url(#ssm-arrow)"/>
|
|
<text x="135" y="137" fill="#f39c12" font-size="8" text-anchor="middle">u₂</text>
|
|
<line x1="210" y1="125" x2="210" y2="108" stroke="#f39c12" stroke-width="1" marker-end="url(#ssm-arrow)"/>
|
|
<text x="210" y="137" fill="#f39c12" font-size="8" text-anchor="middle">u₃</text>
|
|
<line x1="285" y1="125" x2="285" y2="108" stroke="#f39c12" stroke-width="1" marker-end="url(#ssm-arrow)"/>
|
|
<text x="285" y="137" fill="#f39c12" font-size="8" text-anchor="middle">u₄</text>
|
|
|
|
<!-- Recurrence equation -->
|
|
<text x="185" y="155" fill="#555" font-size="9" text-anchor="middle" font-style="italic">xₖ = Āxₖ₋₁ + B̄uₖ , yₖ = Cxₖ</text>
|
|
|
|
<!-- Convolution view (top right) -->
|
|
<rect x="370" y="42" width="335" height="110" rx="10" fill="#27ae60" opacity="0.05" stroke="#27ae60" stroke-width="1.5"/>
|
|
<text x="537" y="62" fill="#27ae60" font-size="11" font-weight="bold" text-anchor="middle">Convolution View (Training: O(n log n))</text>
|
|
|
|
<!-- Kernel -->
|
|
<rect x="390" y="78" width="40" height="28" rx="4" fill="#27ae60" opacity="0.15" stroke="#27ae60" stroke-width="1.5"/>
|
|
<text x="410" y="96" fill="#27ae60" font-size="8" text-anchor="middle">CB̄</text>
|
|
|
|
<rect x="438" y="78" width="40" height="28" rx="4" fill="#27ae60" opacity="0.15" stroke="#27ae60" stroke-width="1.5"/>
|
|
<text x="458" y="96" fill="#27ae60" font-size="7" text-anchor="middle">CĀB̄</text>
|
|
|
|
<rect x="486" y="78" width="42" height="28" rx="4" fill="#27ae60" opacity="0.15" stroke="#27ae60" stroke-width="1.5"/>
|
|
<text x="507" y="96" fill="#27ae60" font-size="7" text-anchor="middle">C²B̄</text>
|
|
|
|
<text x="543" y="96" fill="#27ae60" font-size="14" text-anchor="middle">…</text>
|
|
|
|
<rect x="558" y="78" width="52" height="28" rx="4" fill="#27ae60" opacity="0.15" stroke="#27ae60" stroke-width="1.5"/>
|
|
<text x="584" y="96" fill="#27ae60" font-size="7" text-anchor="middle">CĀⁿ⁻¹B̄</text>
|
|
|
|
<!-- Convolution symbol -->
|
|
<text x="537" y="125" fill="#555" font-size="11" text-anchor="middle">⊛</text>
|
|
<text x="537" y="140" fill="#f39c12" font-size="9" text-anchor="middle">[u₁, u₂, u₃, … , uₙ]</text>
|
|
|
|
<!-- Convolution equation -->
|
|
<text x="537" y="155" fill="#555" font-size="9" text-anchor="middle" font-style="italic">y = K̄ * u (computed via FFT)</text>
|
|
|
|
<!-- Bottom: Mamba selective SSM -->
|
|
<rect x="60" y="170" width="600" height="55" rx="10" fill="#9b59b6" opacity="0.05" stroke="#9b59b6" stroke-width="1.5"/>
|
|
<text x="360" y="190" fill="#9b59b6" font-size="12" font-weight="bold" text-anchor="middle">Mamba: Selective State Spaces</text>
|
|
<text x="360" y="207" fill="#555" font-size="10" text-anchor="middle">B, C, Δ become input-dependent → content-aware gating (like attention, but O(n))</text>
|
|
<text x="360" y="220" fill="#555" font-size="9" text-anchor="middle">Breaks convolution view → uses hardware-aware parallel scan instead of FFT</text>
|
|
|
|
<!-- Comparison boxes -->
|
|
<rect x="60" y="238" width="190" height="42" rx="8" fill="#e74c3c" opacity="0.06" stroke="#e74c3c" stroke-width="1"/>
|
|
<text x="155" y="255" fill="#e74c3c" font-size="9" text-anchor="middle" font-weight="bold">Transformer: O(n²) attn, O(n·d) KV cache</text>
|
|
<text x="155" y="270" fill="#666" font-size="8" text-anchor="middle">Precise content lookup</text>
|
|
|
|
<rect x="265" y="238" width="190" height="42" rx="8" fill="#3498db" opacity="0.06" stroke="#3498db" stroke-width="1"/>
|
|
<text x="360" y="255" fill="#3498db" font-size="9" text-anchor="middle" font-weight="bold">SSM/Mamba: O(n) scan, O(N) state</text>
|
|
<text x="360" y="270" fill="#666" font-size="8" text-anchor="middle">Smooth long-range propagation</text>
|
|
|
|
<rect x="470" y="238" width="190" height="42" rx="8" fill="#27ae60" opacity="0.06" stroke="#27ae60" stroke-width="1"/>
|
|
<text x="565" y="255" fill="#27ae60" font-size="9" text-anchor="middle" font-weight="bold">Hybrid (Jamba/Zamba)</text>
|
|
<text x="565" y="270" fill="#666" font-size="8" text-anchor="middle">Best of both: SSM + sparse attention</text>
|
|
</svg> |