Skip to content

Commit d8c2b8a

Browse files
committed
feat(ui/circuits): add isFromQkTracing field for filtering (untested)
1 parent 99d5f4c commit d8c2b8a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ui-ssr/src/components/circuits/link-graph/link-graph.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function topologicalSort(
9898
}
9999

100100
const LinkGraphComponent: React.FC<LinkGraphProps> = ({
101-
data,
101+
data: rawData,
102102
visState,
103103
onNodeClick,
104104
onNodeHover,
@@ -112,6 +112,15 @@ const LinkGraphComponent: React.FC<LinkGraphProps> = ({
112112
},
113113
)
114114

115+
const data = useMemo(() => {
116+
const nodes = rawData.nodes.filter((n) => !n.isFromQkTracing)
117+
const nodeIds = new Set(nodes.map((n) => n.nodeId))
118+
const edges = rawData.edges.filter(
119+
(e) => nodeIds.has(e.source) && nodeIds.has(e.target),
120+
)
121+
return { ...rawData, nodes, edges }
122+
}, [rawData])
123+
115124
// 1. Calculate stats about context counts and total units needed
116125
const { calculatedCtxCounts, totalUnits } = useMemo(() => {
117126
if (!data.nodes.length) {

ui-ssr/src/types/circuit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const FeatureNodeSchema = z.object({
1919
activation: z.number(),
2020
feature: FeatureSchema,
2121
qkTracingResults: QKTracingResultsSchema.nullish(),
22+
isFromQkTracing: z.boolean().default(false),
2223
})
2324

2425
export type FeatureNode = z.infer<typeof FeatureNodeSchema>
@@ -29,6 +30,7 @@ export const TokenNodeSchema = z.object({
2930
layer: z.number(),
3031
ctxIdx: z.number(),
3132
token: z.string(),
33+
isFromQkTracing: z.boolean().default(false),
3234
})
3335

3436
export type TokenNode = z.infer<typeof TokenNodeSchema>
@@ -38,6 +40,7 @@ export const ErrorNodeSchema = z.object({
3840
nodeId: z.string(),
3941
layer: z.number(),
4042
ctxIdx: z.number(),
43+
isFromQkTracing: z.boolean().default(false),
4144
})
4245

4346
export type ErrorNode = z.infer<typeof ErrorNodeSchema>
@@ -49,6 +52,7 @@ export const LogitNodeSchema = z.object({
4952
ctxIdx: z.number(),
5053
tokenProb: z.number(),
5154
token: z.string(),
55+
isFromQkTracing: z.boolean().default(false),
5256
})
5357

5458
export type LogitNode = z.infer<typeof LogitNodeSchema>

0 commit comments

Comments
 (0)