11import { formatNumber , getDisplayLabel } from '@/lib/utils' ;
22import { isPersistedBenchmarkId } from '@/lib/benchmark-id' ;
3+ import type { Locale } from '@/lib/i18n' ;
34
45import type { HardwareConfig , InferenceData , OverlayData } from '@/components/inference/types' ;
56import { parallelismLabel } from '@/components/inference/utils/parallelism-label' ;
@@ -29,6 +30,8 @@ export interface TooltipConfig {
2930 * call so we don't ship megabytes of profile JSONL just for this check).
3031 */
3132 hasTrace ?: boolean ;
33+ /** Page locale for tooltip metadata labels. Defaults to English. */
34+ locale ?: Locale ;
3235}
3336
3437export interface OverlayTooltipConfig extends TooltipConfig {
@@ -90,24 +93,84 @@ export const fmt = (v: number): string => {
9093 return String ( rounded ) ;
9194} ;
9295
96+ const CACHE_STRINGS = {
97+ en : {
98+ offloadType : 'Offload Type' ,
99+ offloadBackend : 'Offload Backend' ,
100+ transferEngine : 'KV Cache Transfer Engine' ,
101+ gpuHitRate : 'GPU Cache Hit Rate' ,
102+ cpuHitRate : 'CPU Cache Hit Rate' ,
103+ theoreticalHitRate : 'Theoretical Cache Hit Rate' ,
104+ none : 'None' ,
105+ } ,
106+ zh : {
107+ offloadType : '卸载类型' ,
108+ offloadBackend : '卸载后端' ,
109+ transferEngine : 'KV Cache 传输引擎' ,
110+ gpuHitRate : 'GPU Cache 命中率' ,
111+ cpuHitRate : 'CPU Cache 命中率' ,
112+ theoreticalHitRate : '理论 Cache 命中率' ,
113+ none : '无' ,
114+ } ,
115+ } as const ;
116+
117+ const CACHE_IMPLEMENTATION_LABELS : Record < string , string > = {
118+ hicache : 'HiCache' ,
119+ lmcache : 'LMCache' ,
120+ mooncake : 'Mooncake' ,
121+ mori : 'MoRI' ,
122+ moriio : 'MoRI-IO' ,
123+ 'mori-io' : 'MoRI-IO' ,
124+ nixl : 'NIXL' ,
125+ 'vllm-native' : 'vLLM Native' ,
126+ 'vllm-simple' : 'vLLM Simple' ,
127+ } ;
128+
129+ const cacheImplementationLabel = ( value : string ) : string =>
130+ CACHE_IMPLEMENTATION_LABELS [ value . toLowerCase ( ) ] ?? value ;
131+
132+ const offloadTypeLabel = ( value : string , locale : Locale ) : string => {
133+ if ( value . toLowerCase ( ) === 'dram' ) return 'DRAM' ;
134+ if ( value . toLowerCase ( ) === 'none' ) return CACHE_STRINGS [ locale ] . none ;
135+ return value . toUpperCase ( ) ;
136+ } ;
137+
93138/**
94- * Agentic-only tooltip rows: offload mode, KV cache hit rates, request
95- * success, token totals. Returns an empty string for non-agentic rows .
139+ * Cache configuration and hit-rate rows shared by fixed-sequence, agentic,
140+ * official, comparison, and unofficial-run tooltips .
96141 */
97- const generateAgenticHTML = ( d : InferenceData ) : string => {
98- if ( d . benchmark_type !== 'agentic_traces' ) return '' ;
99-
142+ const generateCacheMetadataHTML = ( d : InferenceData , locale : Locale ) : string => {
143+ const t = CACHE_STRINGS [ locale ] ;
100144 const parts : string [ ] = [ ] ;
101- if ( d . offload_mode ) {
102- parts . push ( tooltipLine ( 'Offload Mode' , d . offload_mode . toUpperCase ( ) ) ) ;
145+ if ( d . kv_offloading ) {
146+ parts . push ( tooltipLine ( t . offloadType , offloadTypeLabel ( d . kv_offloading , locale ) ) ) ;
147+ }
148+ if ( d . kv_offload_backend ) {
149+ const backend = cacheImplementationLabel ( d . kv_offload_backend ) ;
150+ const version = d . kv_offload_backend_version ? ` ${ d . kv_offload_backend_version } ` : '' ;
151+ parts . push ( tooltipLine ( t . offloadBackend , `${ backend } ${ version } ` ) ) ;
152+ }
153+ if ( d . is_multinode && d . kv_p2p_transfer ) {
154+ parts . push ( tooltipLine ( t . transferEngine , cacheImplementationLabel ( d . kv_p2p_transfer ) ) ) ;
103155 }
104156
105157 const gpuHit = formatPct ( d . server_gpu_cache_hit_rate ) ;
106158 const cpuHit = formatPct ( d . server_cpu_cache_hit_rate ) ;
107- const theoHit = formatPct ( d . theoretical_cache_hit_rate ) ;
108- if ( gpuHit ) parts . push ( tooltipLine ( 'GPU Cache Hit Rate' , gpuHit ) ) ;
109- if ( cpuHit ) parts . push ( tooltipLine ( 'CPU Cache Hit Rate' , cpuHit ) ) ;
110- if ( theoHit ) parts . push ( tooltipLine ( 'Theoretical Cache Hit Rate' , theoHit ) ) ;
159+ const theoreticalHit = formatPct ( d . theoretical_cache_hit_rate ) ;
160+ if ( gpuHit ) parts . push ( tooltipLine ( t . gpuHitRate , gpuHit ) ) ;
161+ if ( cpuHit ) parts . push ( tooltipLine ( t . cpuHitRate , cpuHit ) ) ;
162+ if ( theoreticalHit ) parts . push ( tooltipLine ( t . theoreticalHitRate , theoreticalHit ) ) ;
163+ return parts . join ( '' ) ;
164+ } ;
165+
166+ /**
167+ * Agentic-only request success and token totals. Cache metadata is rendered
168+ * separately because fixed-sequence rows can carry it too.
169+ */
170+ const generateAgenticHTML = ( d : InferenceData ) : string => {
171+ if ( d . benchmark_type !== 'agentic_traces' ) return '' ;
172+
173+ const parts : string [ ] = [ ] ;
111174
112175 if ( d . num_requests_total !== undefined && d . num_requests_successful !== undefined ) {
113176 const successPct =
@@ -212,6 +275,7 @@ export const generateTooltipContent = (config: TooltipConfig): string => {
212275 runUrl,
213276 hasTrace,
214277 } = config ;
278+ const locale = config . locale ?? 'en' ;
215279
216280 return `
217281 <div style="background: var(--popover); border: 1px solid var(--border); border-radius: 8px; padding: 12px; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); user-select: ${ isPinned ? 'text' : 'none' } ;">
@@ -258,6 +322,7 @@ export const generateTooltipContent = (config: TooltipConfig): string => {
258322 <div style="color: var(--muted-foreground); font-size: 11px; margin-bottom: 4px;">
259323 <strong>Precision:</strong> ${ d . precision . toUpperCase ( ) }
260324 </div>
325+ ${ generateCacheMetadataHTML ( d , locale ) }
261326 ${ generateAgenticHTML ( d ) }
262327 ${ runLinkHTML ( runUrl ) }
263328 ${ viewChartsButtonHTML ( isPinned , Boolean ( hasTrace ) , d . id ) }
@@ -283,6 +348,7 @@ export const generateTooltipContent = (config: TooltipConfig): string => {
283348 */
284349export const generateOverlayTooltipContent = ( config : OverlayTooltipConfig ) : string => {
285350 const { data : d , isPinned, xLabel, yLabel, overlayData } = config ;
351+ const locale = config . locale ?? 'en' ;
286352 const hwConfig = overlayData . hardwareConfig [ d . hwKey ] ;
287353 const perRow = overlayData . getRunForRow ?.( d ) ;
288354 const branch = perRow ?. branch ?? overlayData . label ;
@@ -316,6 +382,7 @@ export const generateOverlayTooltipContent = (config: OverlayTooltipConfig): str
316382 <div style="color: var(--muted-foreground); font-size: 11px; margin-bottom: 4px;">
317383 <strong>Precision:</strong> ${ d . precision . toUpperCase ( ) }
318384 </div>
385+ ${ generateCacheMetadataHTML ( d , locale ) }
319386 ${ generateAgenticHTML ( d ) }
320387 </div>
321388 ` ;
@@ -339,6 +406,7 @@ export const generateGPUGraphTooltipContent = (config: TooltipConfig): string =>
339406 runUrl,
340407 hasTrace,
341408 } = config ;
409+ const locale = config . locale ?? 'en' ;
342410
343411 return `
344412 <div style="background: var(--popover); border: 1px solid var(--border); border-radius: 8px; padding: 12px; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); user-select: ${ isPinned ? 'text' : 'none' } ;">
@@ -385,6 +453,7 @@ export const generateGPUGraphTooltipContent = (config: TooltipConfig): string =>
385453 <div style="color: var(--muted-foreground); font-size: 11px; margin-bottom: 4px;">
386454 <strong>Precision:</strong> ${ d . precision . toUpperCase ( ) }
387455 </div>
456+ ${ generateCacheMetadataHTML ( d , locale ) }
388457 ${ generateAgenticHTML ( d ) }
389458 ${ runLinkHTML ( runUrl ) }
390459 ${ viewChartsButtonHTML ( isPinned , Boolean ( hasTrace ) , d . id ) }
0 commit comments