\documentclass[tikz,border=2pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage{amsmath}
\usepackage{amssymb}
\usetikzlibrary{arrows.meta,positioning,calc,fit,backgrounds,decorations.pathreplacing}

\definecolor{hkink}{RGB}{28,36,49}
\definecolor{hkgray}{RGB}{91,103,119}
\definecolor{hkline}{RGB}{126,137,151}
\definecolor{hkblue}{RGB}{43,111,179}
\definecolor{hkteal}{RGB}{24,137,128}
\definecolor{hkorange}{RGB}{214,120,39}
\definecolor{hkviolet}{RGB}{125,82,169}
\definecolor{hkgreen}{RGB}{62,142,83}
\definecolor{hkyellow}{RGB}{245,196,84}
\definecolor{rawlow}{RGB}{207,224,242}
\definecolor{rawmid}{RGB}{116,166,213}
\definecolor{rawhigh}{RGB}{43,111,179}
\definecolor{disc}{RGB}{224,142,58}
\definecolor{keep}{RGB}{70,155,92}

\begin{document}
\begin{tikzpicture}[
    x=1cm,
    y=1cm,
    >=Latex,
    font=\sffamily\footnotesize,
    line/.style={-{Latex[length=2.1mm,width=1.45mm]}, draw=hkink, line width=0.52pt},
    softline/.style={-{Latex[length=2mm,width=1.35mm]}, draw=hkline, line width=0.45pt, dashed},
    box/.style={draw=hkline, line width=0.48pt, rounded corners=2pt, align=center, inner sep=3.4pt, minimum height=0.92cm},
    io/.style={box, fill=hkgray!10, minimum width=1.95cm},
    processbox/.style={box, fill=hkblue!10, minimum width=2.05cm},
    refine/.style={box, fill=hkviolet!10, minimum width=2.18cm},
    guard/.style={box, fill=hkyellow!25, minimum width=2.1cm},
    output/.style={box, fill=hkgreen!12, minimum width=2.05cm},
    theory/.style={box, fill=hkorange!10, draw=hkorange!75!black, minimum width=7.35cm, minimum height=0.82cm},
    tag/.style={font=\sffamily\tiny\bfseries, text=hkgray},
    tinylabel/.style={font=\sffamily\tiny, text=hkgray}
]

\node[io] (prefill) at (0,0) {\textbf{Prefill}\\full KV cache\\$V=\{1,\ldots,N\}$};
\node[processbox] (score) at (2.45,0) {\textbf{Base scorer}\\raw tensor\\$\mathbf{s}_{\ell,h,i}$};

\node[refine] (hub) at (5.0,0) {\textbf{Local hubs}\\1D max-pool\\$M_{\ell,h,i}$};
\node[refine] (smd) at (7.35,0) {\textbf{SMD}\\hub keeps $s$\\neighbor $\gamma s$};
\node[refine] (calib) at (9.75,0) {\textbf{Head calibration}\\selectivity $c_{\ell,h}$\\$u=\beta\tilde{s}$};
\node[refine] (gate) at (12.15,0) {\textbf{Gate}\\$\lambda=r^p$\\$z=(1-\lambda)s+\lambda u$};

\node[output] (prune) at (14.55,0) {\textbf{Prune}\\top-$B$ by $z$\\evict rest};
\node[output] (compressed) at (16.85,0) {\textbf{Retained KV}\\set $S$\\$|S|\le B$};

\node[guard] (protect) at (9.75,-1.55) {\textbf{Protected bypass}\\attention sinks\\recent local window};
\node[theory] (objective) at (8.65,1.65) {\textbf{Conceptual guide: score-weighted local coverage}\\[-0.15em]
    $F_{\mathrm{sub}}(S)=\sum_{i\in V}\max_{j\in S}w_{i,j}$
    \quad diminishing returns over local neighborhoods};

\begin{scope}[on background layer]
    \node[draw=hkviolet!65, fill=hkviolet!4, rounded corners=3pt, inner sep=7pt, fit=(hub)(smd)(calib)(gate)] (hubkvbox) {};
    \node[tag, anchor=south west] at ($(hubkvbox.north west)+(0.07,0.03)$) {HubKV one-pass score refinement};
\end{scope}

\draw[line] (prefill) -- (score);
\draw[line] (score) -- (hub);
\draw[line] (hub) -- (smd);
\draw[line] (smd) -- (calib);
\draw[line] (calib) -- (gate);
\draw[line] (gate) -- (prune);
\draw[line] (prune) -- (compressed);

\draw[softline] (objective.south) -- node[tinylabel, right, xshift=0.03cm] {proxy for marginal gain} (smd.north);
\draw[softline] (protect.east) -| node[tinylabel, pos=0.24, below] {$z=1$} (gate.south);

\node[tinylabel, anchor=north] at (16.85,-0.75) {decode interface};
\draw[softline] (compressed.south) -- ++(0,-0.36);

% Raw clustered profile
\node[tag, anchor=west] at (1.25,-2.23) {raw score clusters};
\draw[hkline!55, line width=0.35pt] (1.25,-2.05) -- (3.35,-2.05);
\foreach \x/\h/\c in {
    0/0.15/rawlow,1/0.22/rawlow,2/0.34/rawmid,3/0.82/rawhigh,
    4/0.72/rawhigh,5/0.61/rawmid,6/0.20/rawlow,7/0.18/rawlow,
    8/0.58/rawmid,9/0.78/rawhigh,10/0.69/rawhigh,11/0.24/rawlow}
{
    \draw[draw=none, fill=\c] ({1.45+\x*0.145},-2.05) rectangle ++(0.095,\h);
}
\draw[decorate, decoration={brace, amplitude=2pt}, draw=hkblue!80, line width=0.38pt]
    (1.86,-1.05) -- node[tinylabel, above=0.03cm] {redundant local mass} (2.42,-1.05);
\draw[decorate, decoration={brace, amplitude=2pt}, draw=hkblue!80, line width=0.38pt]
    (2.66,-1.13) -- (3.09,-1.13);

% SMD repulsion profile
\node[tag, anchor=west] at (5.15,-2.23) {SMD soft local repulsion};
\draw[hkline!55, line width=0.35pt] (5.15,-2.05) -- (8.25,-2.05);
\foreach \x/\h/\c in {
    0/0.16/rawlow,1/0.22/rawlow,2/0.26/disc,3/0.84/hkorange,
    4/0.31/disc,5/0.25/disc,6/0.18/rawlow,7/0.17/rawlow,
    8/0.29/disc,9/0.80/hkorange,10/0.32/disc,11/0.20/rawlow}
{
    \draw[draw=none, fill=\c] ({5.42+\x*0.205},-2.05) rectangle ++(0.13,\h);
}
\foreach \x in {3,9}
{
    \fill[hkorange!95!black] ({5.485+\x*0.205},-1.08) circle (1.4pt);
}
\foreach \x in {2,4,5,8,10}
{
    \draw[disc!95!black, line width=0.35pt] ({5.485+\x*0.205},-1.72) -- ++(0,-0.17);
}
\node[tinylabel, anchor=west] at (7.92,-1.36) {$\times\gamma$};

% Retained representatives
\node[tag, anchor=west] at (13.1,-2.23) {retained representatives};
\draw[hkline!55, line width=0.35pt] (13.1,-2.05) -- (16.85,-2.05);
\foreach \x in {0,...,17}
{
    \draw[draw=hkline!35, fill=hkgray!8, line width=0.25pt] ({13.25+\x*0.19},-2.05) rectangle ++(0.12,0.32);
}
\foreach \x in {2,7,12,16}
{
    \draw[draw=keep!80!black, fill=keep!75, line width=0.28pt] ({13.25+\x*0.19},-2.05) rectangle ++(0.12,0.54);
}
\draw[softline] (prune.south) -- ++(0,-0.72);

\node[tinylabel, anchor=north] at (0,-0.74) {context tokens};
\node[tinylabel, anchor=north] at (2.45,-0.74) {layer/head/token scores};
\node[tinylabel, anchor=north] at (14.55,-0.74) {Top-K interface};

\end{tikzpicture}
\end{document}
