Skip to main content

GPUTraceAnomalyScoring

Overview​

GPUTraceAnomalyScoring scores every canonical span against dense peer-group baselines. The scoring policy is explicit and replaceable: duration deviation and error-rate deviation have independent weights, duration can be slow-only or two-sided, and the caller owns the threshold.

At a glance

QuestionAnswer
ProblemScore canonical spans against explicit peer-group duration and error baselines.
Reads / writesReads span metrics, group IDs, and baselines; writes per-span scores, anomaly mask, and summary.
OwnershipPublic inputs and outputs are caller-owned; scratch storage is graph-owned transient memory.
Output contractSource-aligned scores/mask plus a compact maximum and validation summary.
Expected workLinear scoring plus bounded summary reduction.
ChunksPreserves declared views and source identity; it does not implicitly concatenate or repack chunks.
Conditions / budgetsSupports maximumRowsPerPass and resumable publication of complete generations.
Neighborhoodpeer baselines + trace columns → GPUTraceAnomalyScoring → filter, color, label, or aggregation.

When to use​

Use this contributor after a grouping or comparison stage has produced explicit peer baselines. It is intended for explainable policy scores, not model training or an embedded observability policy.

Usage​

import {gpuTraceAnomalyScoring, type GPUTraceAnomalyScoringResult} from '@luma.gl/graph/gpu-trace';

graph.add(gpuTraceAnomalyScoring, {
id: 'anomalies',
groupIndices,
durations,
errorMask,
selection, // optional source-aligned flags from gpuTraceTimeWindow or another producer
baselineDurationMeans,
baselineDurationStandardDeviations,
baselineErrorRates,
threshold: 3,
maximumRowsPerPass: 262_144,
output: {summary}
});
const result = graph.getContribution<GPUTraceAnomalyScoringResult>('anomalies');

In this example, summary is a caller-owned four-word GPU view for compact readback. Omitted outputs are graph-owned. Pass the result views to downstream GPU passes before compiling. result.stats describes the operation's static sizing.

Baselines may come from a saved trace, a deployment cohort, or another GPU Core aggregation. The primitive does not embed one observability product's grouping or anomaly semantics.

Score​

For each valid span, the default slow-only score is:

durationWeight × max((duration - peerMean) / max(peerDeviation, floor), 0)
+ errorWeight × abs(errorValue - peerErrorRate)

Set durationMode: 'two-sided' to use the absolute duration z-score. Invalid group indices, durations, or baselines produce a zero score, stay out of the mask, and set a validation flag.

Trace Viewer snapshots the completed scope's resident group summaries to prepare its synthetic peer cohort. Comparison and anomaly scoring share those baseline views. When the user chooses a measured interval, scoring also reuses the completed analytics selection for that interval. Other scopes use the current aggregates as the baseline and score the full trace.

Supply selection to score a subset without compacting the input. It accepts a zero/nonzero uint32 column with the canonical row and chunk order. Unselected rows return zero scores and mask values and do not contribute to the summary, including validation flags. The maximum still reports a canonical span ID. An empty selection returns 0xffffffff for that ID.

When the source uses multiple chunks, pass matching interval vectors to gpuTraceTimeWindow and retrieve getContribution<GPUTraceTimeWindowResult<'vector'>>(id).output. The result retains the input chunk lengths, including empty chunks, and can feed scoring and time buckets in the same command graph.

Inputs and outputs​

ViewMeaning
scoresNonnegative policy score per canonical span
anomalyMaskOne when the score reaches threshold
summary[0]Number of thresholded anomalies
summary[1]Maximum score encoded as positive f32 bits
summary[2]Lowest canonical index attaining the maximum score
summary[3]Invalid-group, invalid-duration, invalid-baseline, and overflow flags

The per-span outputs remain GPU-resident for rendering, filtering, label priority, or follow-up aggregation. A UI can sample only the four-word summary.

Scoring, summary reduction, and stable maximum selection publish invocation bounds to the command graph. maximumRowsPerPass optionally turns each source chunk and full-output reduction into smaller resumable nodes. Applications can combine that with compiledGraph.createExecution(...), submit one bounded step at a time, and cancel between steps without exposing partial results as a completed analysis.

Execution and ownership​

The contributor adds graph work only. Source columns and public outputs are caller-owned; graph scratch may use transient allocations. Submission, cancellation, and publication remain with the application.

Capacity, validation, and failure behavior​

Invalid groups, durations, and baselines are excluded and reported through summary flags. Output capacity is fixed by the canonical span count compiled into the graph.

Performance​

Work is linear in the canonical span count. The selection preserves source positions and is applied during summary reduction. Use maximumRowsPerPass and resumable execution for large global analyses.

Limitations​

Peer construction and baseline policy are intentionally outside this contributor. Scores identify statistical deviation under the supplied policy; they do not establish causality.

Comparison workflow​

Use stable operation dictionary IDs as groupIndices, produce baseline columns from the reference trace, and score the current trace without CPU row materialization. The same score and mask columns can feed GPUTraceAggregation, histograms, semantic colors, and selection workflows. Compose GPUTraceComparison in the same command graph when the UI also needs group-level count, duration, and error-rate deltas.