benchfmt

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Compare external measurements with Go benchmarks

cuptibench-import converts explicit measurements from C or another producer into the same text format as Go benchmarks. It does not run the C program, infer its timing boundaries, or parse an unspecified C tool's output.

From the nvidia module, exercise the synthetic parser fixtures:

go run ./cmd/cuptibench-import ./x/cuptibench/benchfmt/testdata/synthetic-c.json > ~/tmp/cuptibench-c.txt
benchstat ~/tmp/cuptibench-c.txt ./x/cuptibench/benchfmt/testdata/synthetic-go.txt

Both files contain invented numbers for checking the format. These commands produce one comparison row with one sample per arm. Benchstat reports that there are too few samples for a confidence interval or a significant difference.

Canonical input

Supply one JSON document with version: 1, config, and samples. See testdata/synthetic-c.json for a complete fixture. Each sample records:

  • name: the exact Go benchmark name, including its subbenchmark path and processor suffix if present. For example, BenchmarkDecode/full-8. The -8 matches the Go row; it does not claim that the C producer used eight threads. The converter never appends -C or invents a processor count.
  • sample_id and source: identify the original measurement and its artifact.
  • operations: the number of logical operations represented by that sample.
  • scope: full, isolated, or attributed.
  • provenance: source-specific facts such as artifact hash, executable revision, model/input hashes, preparation, stream policy, and timing boundaries.
  • measurements: explicit values, units, kinds, and normalization bases.

Copy the comparison arm's goos, goarch, pkg, and cpu headers into config where appropriate. Benchstat groups differences in these headers into separate tables. Sample provenance is emitted as JSON comments, which retains it without splitting comparison rows by C/Go implementation or run identity.

Normalization and timing

Kind Output unit Permitted basis
host-elapsed ns/op total, per-operation
device-elapsed gpu-ns/op total, per-operation
kernel-duration-sum kernel-sum-ns/op total, per-operation
counter Exact unit; /op when normalized (blk/sm, regs/thr, smem-B, tmem-cols require raw) raw, total, per-operation
rate Exact source unit (tflops, gb/s) raw
ratio Exact source unit (pct-roofline, occ-pct, wave-eff-pct, sm-busy-pct, dram-pct, l2-hit-pct, max-err) raw
delta Signed finite relative unit (speedup-pct) raw

Measurements within each row are emitted in deterministic canonical column order: timing (ns/op, gpu-ns/op, kernel-sum-ns/op), roofline (tflops, gb/s, pct-roofline), occupancy & SM resources (blk/sm, occ-pct, wave-eff-pct, regs/thr, smem-B, tmem-cols), hardware counters (sm-busy-pct, dram-pct, l2-hit-pct), comparison (max-err, speedup-pct), and then any custom units lexicographically. Missing optional metrics (nil pointers) are omitted and never fabricated as zero.

total divides the source value by operations. per-operation and raw preserve the source value. ns/op specifically means the matching Go host timing boundary (including the same submission and completion waits); the converter does not rename an unrelated wall-clock interval to make it compare. Values use float64 precision. A missing value is an error. A measured counter may be zero; a zero elapsed duration is unresolved and rejected.

When comparing cuptibench plans with Config.Operations > 1, Go host ns/op is per benchmark sequence and gpu-ns/op is per logical operation. Match these denominators explicitly. The importer cannot infer a Go plan from a benchmark name or normalize the other comparison file.

One source sample produces one row, even if operations is 128. It does not produce 128 independent statistical samples. To compare repeated runs, retain independent source measurements and give each its own sample ID. Duplicate source/sample/name combinations are rejected.

Match workload scopes and operation definitions before comparing values. A sum of kernel durations is not whole-pass latency when kernels overlap. A host interval is not a CUDA-event interval. Raw CUPTI sequence totals must represent the same sequence size on both arms. The converter enforces declared kinds and normalization; it cannot verify those declarations against an unknown C tool.

CLI

go run ./cmd/cuptibench-import retained-run.json > ~/tmp/cuptibench-c.txt
# Or provide the JSON on standard input:
go run ./cmd/cuptibench-import < retained-run.json

JSON input is limited to 64 MiB, including trailing whitespace, while reading. Invalid or oversized input produces no benchmark text and a nonzero exit status. The format uses standard library Go code and does not require CUDA or CUPTI libraries.

Documentation

Overview

Package benchfmt reads and formats GPU benchmark records in Go benchmark and JSON interchange layouts.

This package is outside the compatibility promise of github.com/tmc/lib/nvidia. Its API may change or be removed in patch releases.

Example
value := float64(200000)
run := Run{Version: 1, Samples: []Sample{{Name: "BenchmarkDecode/full-8", ID: "example-1", Source: "c-run.json", Operations: 100, Scope: "full", Measurements: []Measurement{{Unit: "gpu-ns/op", Value: &value, Basis: "total", Kind: "device-elapsed"}}}}}
var out bytes.Buffer
_ = Write(&out, run)
lines := strings.Split(strings.TrimSpace(out.String()), "\n")
fmt.Println(lines[len(lines)-1])
Output:
BenchmarkDecode/full-8 100 2000 gpu-ns/op

Index

Examples

Constants

View Source
const (
	// Timing units.
	UnitHostNS      = "ns/op"
	UnitGPUNS       = "gpu-ns/op"
	UnitKernelSumNS = "kernel-sum-ns/op"

	// Roofline units.
	UnitTFLOPS      = "tflops"
	UnitGBPerSec    = "gb/s"
	UnitPctRoofline = "pct-roofline"

	// Occupancy and SM resource units.
	UnitBlocksPerSM   = "blk/sm"
	UnitOccupancyPct  = "occ-pct"
	UnitWaveEffPct    = "wave-eff-pct"
	UnitRegsPerThread = "regs/thr"
	UnitSmemBytes     = "smem-B"
	UnitTMEMCols      = "tmem-cols"

	// Hardware counter units.
	UnitSMBusyPct = "sm-busy-pct"
	UnitDRAMPct   = "dram-pct"
	UnitL2HitPct  = "l2-hit-pct"

	// Comparison and verification units.
	UnitMaxErr     = "max-err"
	UnitSpeedupPct = "speedup-pct"
)

Canonical measurement units for Go benchstat GPU kernel benchmarks.

View Source
const (
	KindHostElapsed       = "host-elapsed"
	KindDeviceElapsed     = "device-elapsed"
	KindKernelDurationSum = "kernel-duration-sum"
	KindCounter           = "counter"
	KindRate              = "rate"
	KindRatio             = "ratio"
	KindDelta             = "delta"
)

Canonical Measurement.Kind values.

View Source
const (
	BasisTotal        = "total"
	BasisPerOperation = "per-operation"
	BasisRaw          = "raw"
)

Canonical Measurement.Basis values.

View Source
const (
	DefaultNoiseFloorMargin = 1.25
	DefaultMinNullSamples   = 3
)

Default calibration parameters applied when the corresponding NoiseFloorConfig field is zero.

View Source
const (
	RegimeStockRepeat = "stock_repeat"
	RegimeTP1VsTP4    = "tp1_vs_tp4"
	RegimeSeedRepeat  = "seed_repeat"
)

Common baseline regimes for empirical null-distribution calibration. Callers may supply any non-empty, control-free regime identifier.

View Source
const NoiseFloorSchema = "noise-floor/v1"

NoiseFloorSchema identifies the canonical JSON schema for serialized empirical noise floors.

Variables

View Source
var ErrNoiseFloorRegimeSplit = errors.New("baseline has separate measurement regimes")

ErrNoiseFloorRegimeSplit reports that baseline observations separated into two supported groups. Qualification must treat the result as unproven.

Functions

func DecodeKernelResources

func DecodeKernelResources(r io.Reader, maxThreadsPerSM int) (map[string]KernelMetrics, error)

DecodeKernelResources reads optional kernel occupancy/resource/roofline JSON in either of two layouts:

  1. A direct map of key -> KernelMetrics (e.g. "shape:cand": {"blocks_per_sm": 2, ...}).
  2. A cudaprof "kernels -json" report containing a "kernels" array with per-kernel "resources" objects. When maxThreadsPerSM > 0 and both blocks_per_sm and non-varying threads_per_block are known (and occ_pct is not already set), occ-pct is derived as (blocks_per_sm * threads_per_block) / maxThreadsPerSM * 100.

func DetectJSONFormat

func DetectJSONFormat(data []byte) (string, error)

DetectJSONFormat inspects a JSON document and reports whether it is a canonical "benchfmt" run or a "scoreabba" receipt.

func EncodeNoiseFloor

func EncodeNoiseFloor(w io.Writer, floor NoiseFloor) error

EncodeNoiseFloor validates floor and writes its canonical noise-floor/v1 JSON representation to w. Invalid input writes nothing.

func Float64

func Float64(v float64) *float64

Float64 returns a pointer to v for populating optional Measurement or KernelMetrics fields.

func Write

func Write(w io.Writer, run Run) error

Write validates all samples and emits Go benchmark text. Invalid input writes nothing. Writer failures can leave partial output. Each original sample emits exactly one row; no repetitions or uncertainty estimates are manufactured.

Example
var out bytes.Buffer
fmt.Println(Write(&out, Run{Version: 1}))
Output:
benchfmt: no samples

Types

type FloorVerdict

type FloorVerdict struct {
	Status       VerdictStatus `json:"status"`
	Metric       string        `json:"metric,omitempty"`
	Regime       string        `json:"regime"`
	Observed     float64       `json:"observed"`
	Floor        float64       `json:"floor"`
	RatioToFloor float64       `json:"ratio_to_floor"`
	MarginUsed   float64       `json:"margin_used"`
	Reason       string        `json:"reason,omitempty"`
}

FloorVerdict is the outcome of comparing an observed metric value against a calibrated NoiseFloor.

func EvaluateAgainstFloor

func EvaluateAgainstFloor(observed float64, floor NoiseFloor) FloorVerdict

EvaluateAgainstFloor compares an observed metric value (using its magnitude math.Abs(observed)) against a calibrated NoiseFloor. It returns WITHIN_NOISE when |observed| <= floor.Floor, ABOVE_FLOOR when |observed| > floor.Floor, and UNPROVEN whenever observed is non-finite, floor is invalid/uncalibrated, or a nonzero observation is evaluated against a zero floor.

Example
samples := []NullSample{
	{Metric: "latency_delta_pct", Regime: RegimeStockRepeat, Value: -1.2},
	{Metric: "latency_delta_pct", Regime: RegimeStockRepeat, Value: -0.4},
	{Metric: "latency_delta_pct", Regime: RegimeStockRepeat, Value: 0.8},
	{Metric: "latency_delta_pct", Regime: RegimeStockRepeat, Value: 1.2},
}
floor, _ := CalibrateNoiseFloor(samples, NoiseFloorConfig{Margin: 1.25})
v := EvaluateAgainstFloor(1.0, floor)
fmt.Printf("%s regime=%s margin=%.2f\n", v.Status, v.Regime, v.MarginUsed)
Output:
WITHIN_NOISE regime=stock_repeat margin=1.25

func QualifyAgainstBaseline

func QualifyAgainstBaseline(metric string, repeats []float64, observed float64, cfg NoiseFloorConfig) (FloorVerdict, error)

QualifyAgainstBaseline calibrates repeated positive timings and classifies the signed fractional change of observed from their median. On any calibration error the verdict is UNPROVEN and the floor is empty.

Example
verdict, _ := QualifyAgainstBaseline("latency", []float64{99, 100, 101}, 104, NoiseFloorConfig{})
fmt.Println(verdict.Status)
Output:
ABOVE_FLOOR

type KernelMetrics

type KernelMetrics struct {
	// Roofline metrics.
	TFLOPS      *float64 `json:"tflops,omitempty"`
	GBPerSec    *float64 `json:"gb_per_s,omitempty"`
	PctRoofline *float64 `json:"pct_roofline,omitempty"`

	// Occupancy and SM resource metrics.
	BlocksPerSM   *float64 `json:"blocks_per_sm,omitempty"`
	OccupancyPct  *float64 `json:"occ_pct,omitempty"`
	WaveEffPct    *float64 `json:"wave_eff_pct,omitempty"`
	RegsPerThread *float64 `json:"regs_per_thread,omitempty"`
	SmemBytes     *float64 `json:"smem_bytes,omitempty"`
	TMEMCols      *float64 `json:"tmem_cols,omitempty"`

	// Hardware counter metrics.
	SMBusyPct *float64 `json:"sm_busy_pct,omitempty"`
	DRAMPct   *float64 `json:"dram_pct,omitempty"`
	L2HitPct  *float64 `json:"l2_hit_pct,omitempty"`
}

KernelMetrics holds optional GPU kernel roofline, occupancy, SM resource, and hardware counter measurements. Nil pointers represent unmeasured values and are omitted rather than fabricated as zero.

func (KernelMetrics) IsEmpty

func (k KernelMetrics) IsEmpty() bool

IsEmpty reports whether all optional metric pointers are nil.

func (KernelMetrics) Measurements

func (k KernelMetrics) Measurements() []Measurement

Measurements converts all non-nil fields of k into canonical Measurements in deterministic column order. Nil pointers are omitted; non-nil invalid values (such as NaN, Inf, negative counts, or out-of-range percentages) are retained so Write rejects them strictly.

func (KernelMetrics) Merge

func (k KernelMetrics) Merge(fallback KernelMetrics) KernelMetrics

Merge returns a copy of k with any nil fields populated from non-nil fields in fallback. Existing non-nil fields in k are preserved.

type Measurement

type Measurement struct {
	Unit  string   `json:"unit"`
	Value *float64 `json:"value"`
	Basis string   `json:"basis"`
	Kind  string   `json:"kind"`
}

Measurement is an explicitly classified number. Value is required; a nil pointer represents missing data and cannot become a measured zero.

Basis is total, per-operation, or raw. Total divides by Sample.Operations; the other bases preserve Value. Total applies only to additive counters and elapsed durations and requires an output unit ending in /op.

Kind is counter, host-elapsed, device-elapsed, kernel-duration-sum, rate, ratio, or delta. Timing units are respectively ns/op, gpu-ns/op, and kernel-sum-ns/op. Delta permits signed finite relative values (such as speedup-pct) with raw basis; all other kinds require nonnegative values. These labels describe producer assertions, not validation of its instruments.

Example
n := float64(4096)
m := Measurement{Unit: "bytes/op", Value: &n, Basis: "total", Kind: "counter"}
fmt.Println(m.Unit, m.Basis)
Output:
bytes/op total

func BlocksPerSM

func BlocksPerSM(v float64) Measurement

BlocksPerSM constructs a resident thread-blocks-per-SM measurement (blk/sm).

func DRAMPct

func DRAMPct(v float64) Measurement

DRAMPct constructs a DRAM throughput hardware counter percentage measurement (dram-pct).

func DeviceNS

func DeviceNS(v float64, basis string) Measurement

DeviceNS constructs a device-elapsed timing measurement (gpu-ns/op).

func GBPerSec

func GBPerSec(v float64) Measurement

GBPerSec constructs a roofline memory bandwidth measurement (gb/s).

func HostNS

func HostNS(v float64, basis string) Measurement

HostNS constructs a host-elapsed timing measurement (ns/op).

func KernelSumNS

func KernelSumNS(v float64, basis string) Measurement

KernelSumNS constructs a summed kernel-duration timing measurement (kernel-sum-ns/op).

func L2HitPct

func L2HitPct(v float64) Measurement

L2HitPct constructs an L2 cache hit-rate percentage measurement (l2-hit-pct).

func MaxErr

func MaxErr(v float64) Measurement

MaxErr constructs a maximum numerical parity error measurement (max-err).

func OccupancyPct

func OccupancyPct(v float64) Measurement

OccupancyPct constructs an SM warp occupancy percentage measurement (occ-pct).

func PctRoofline

func PctRoofline(v float64) Measurement

PctRoofline constructs a roofline attainment percentage measurement (pct-roofline).

func RegsPerThread

func RegsPerThread(v float64) Measurement

RegsPerThread constructs a registers-per-thread resource measurement (regs/thr).

func SMBusyPct

func SMBusyPct(v float64) Measurement

SMBusyPct constructs an SM-active hardware counter percentage measurement (sm-busy-pct).

func SmemBytes

func SmemBytes(v float64) Measurement

SmemBytes constructs a shared-memory-bytes-per-block resource measurement (smem-B).

func SortMeasurements

func SortMeasurements(ms []Measurement) []Measurement

SortMeasurements returns a new slice ordered in canonical GPU benchmark column order (timing, roofline, occupancy and SM resources, hardware counters, comparison metrics, then any custom units lexicographically).

func SpeedupPct

func SpeedupPct(v float64) Measurement

SpeedupPct constructs a signed relative speedup percentage measurement (speedup-pct). Positive values indicate speedup; negative values indicate regression.

func TFLOPS

func TFLOPS(v float64) Measurement

TFLOPS constructs a roofline compute throughput measurement (tflops).

func TMEMCols

func TMEMCols(v float64) Measurement

TMEMCols constructs a Tensor Memory columns-per-block measurement (tmem-cols).

func WaveEffPct

func WaveEffPct(v float64) Measurement

WaveEffPct constructs a grid wave-efficiency percentage measurement (wave-eff-pct).

type NoiseFloor

type NoiseFloor struct {
	Schema   string  `json:"schema"`
	Metric   string  `json:"metric"`
	Regime   string  `json:"regime"`
	N        int     `json:"n"`
	Median   float64 `json:"median"`
	MAD      float64 `json:"mad"`
	P95      float64 `json:"p95"`
	P99      float64 `json:"p99"`
	Max      float64 `json:"max"`
	Margin   float64 `json:"margin"`
	MinFloor float64 `json:"min_floor"`
	Floor    float64 `json:"floor"`
}

NoiseFloor is a calibrated empirical null distribution for one metric and baseline regime. It serializes under the "noise-floor/v1" schema.

func CalibrateNoiseFloor

func CalibrateNoiseFloor(samples []NullSample, cfg NoiseFloorConfig) (NoiseFloor, error)

CalibrateNoiseFloor computes a robust empirical null distribution from baseline repeats for a single metric and regime:

floor = max(p95 * margin, min_floor)

It fails closed on empty, under-sampled, non-finite (NaN/Inf), mixed-metric, mixed-regime, regime splits, or invalid configuration inputs.

Example
samples := []NullSample{
	{Metric: "kl_divergence", Regime: RegimeTP1VsTP4, Value: 0.08},
	{Metric: "kl_divergence", Regime: RegimeTP1VsTP4, Value: 0.10},
	{Metric: "kl_divergence", Regime: RegimeTP1VsTP4, Value: 0.12},
	{Metric: "kl_divergence", Regime: RegimeTP1VsTP4, Value: 0.14},
}
floor, err := CalibrateNoiseFloor(samples, NoiseFloorConfig{Margin: 1.25})
if err != nil {
	fmt.Println("error:", err)
	return
}
vOK := EvaluateAgainstFloor(0.14, floor)
vReg := EvaluateAgainstFloor(0.35, floor)
fmt.Printf("%s %s %s\n", floor.Schema, vOK.Status, vReg.Status)
Output:
noise-floor/v1 WITHIN_NOISE ABOVE_FLOOR

func DecodeNoiseFloor

func DecodeNoiseFloor(r io.Reader) (NoiseFloor, error)

DecodeNoiseFloor reads one canonical noise-floor/v1 JSON document, rejecting unknown fields, unsupported schemas, trailing documents, invalid statistics, and inputs larger than 64 MiB.

func (NoiseFloor) Validate

func (f NoiseFloor) Validate() error

Validate checks that f is a well-formed, finite noise-floor/v1 record.

type NoiseFloorCalibrator

type NoiseFloorCalibrator struct {
	Config NoiseFloorConfig
}

NoiseFloorCalibrator calibrates empirical null distributions and evaluates candidate observations against calibrated floors. Its zero value uses DefaultNoiseFloorMargin and DefaultMinNullSamples.

func (NoiseFloorCalibrator) Calibrate

func (c NoiseFloorCalibrator) Calibrate(samples []NullSample) (NoiseFloor, error)

Calibrate computes a NoiseFloor using the calibrator's Config.

func (NoiseFloorCalibrator) Evaluate

func (NoiseFloorCalibrator) Evaluate(observed float64, floor NoiseFloor) FloorVerdict

Evaluate compares observed against floor.

type NoiseFloorConfig

type NoiseFloorConfig struct {
	// Margin multiplies empirical p95 to compute the calibrated floor.
	// Must be >= 1 when set; zero defaults to DefaultNoiseFloorMargin.
	Margin float64 `json:"margin"`
	// MinFloor lower-bounds the calibrated floor:
	// floor = max(p95 * margin, min_floor). Must be finite and >= 0.
	MinFloor float64 `json:"min_floor"`
	// MinSamples is the minimum number of null samples required.
	// Must be >= 1 when set; zero defaults to DefaultMinNullSamples.
	MinSamples int `json:"min_samples"`
}

NoiseFloorConfig controls empirical noise-floor calibration. Zero values for Margin and MinSamples select DefaultNoiseFloorMargin and DefaultMinNullSamples.

type NullSample

type NullSample struct {
	Metric string  `json:"metric"`
	Regime string  `json:"regime"`
	Value  float64 `json:"value"`
}

NullSample is one baseline measurement drawn from a null regime (such as repeated stock runs or TP1-vs-TP4 equivalence runs). Calibration operates on math.Abs(Value) so both unsigned divergences (KL, L-inf, token-flip rate) and symmetric signed deltas (for example +-1.2% latency delta) produce a nonnegative noise floor.

type Run

type Run struct {
	Version int               `json:"version"` // Must be 1.
	Config  map[string]string `json:"config"`
	Samples []Sample          `json:"samples"`
}

Run is a set of independently retained external measurements. Config contains the same file headers as the Go arm (for example goos, goarch, pkg, cpu). Source-specific provenance belongs in Samples, not Config.

Example
r := Run{Version: 1, Config: map[string]string{"pkg": "example.com/decode"}}
fmt.Println(r.Config["pkg"])
Output:
example.com/decode

func ConvertScoreABBA

func ConvertScoreABBA(receipt ScoreABBAReceipt, opts ScoreABBAOptions) (Run, error)

ConvertScoreABBA converts a decoded ScoreABBAReceipt (plus optional verdict receipt and joined kernel resource metrics) into a canonical benchfmt.Run.

Each shape stat emits two Go benchmark rows: baseline (arm=base) and candidate (arm=cand), suitable for direct comparison with `benchstat -col /arm`. Missing fields (nil pointers) are omitted and never fabricated as zero.

func Decode

func Decode(r io.Reader) (Run, error)

Decode reads one canonical JSON Run, rejecting unknown fields, unsupported versions, trailing documents, and input larger than 64 MiB (including trailing whitespace). Input is bounded while reading, before decoding can accumulate an unbounded document. Write performs semantic validation before output.

Example
run, err := Decode(strings.NewReader(`{"version":1,"samples":[]}`))
fmt.Println(len(run.Samples), err)
Output:
0 <nil>

type Sample

type Sample struct {
	Name         string            `json:"name"`
	ID           string            `json:"sample_id"`
	Source       string            `json:"source"`
	Operations   int64             `json:"operations"`
	Scope        string            `json:"scope"`
	Provenance   map[string]string `json:"provenance"`
	Measurements []Measurement     `json:"measurements"`
}

Sample is one measurement of a named workload. Name is the exact Go benchmark name, including its subbenchmark path and processor suffix when present. ID and Source identify the original sample; repeated IDs for the same source and name are rejected. Scope distinguishes full, isolated, or attributed work.

Example
s := Sample{Name: "BenchmarkDecode/full-8", ID: "run-1", Operations: 128}
fmt.Println(s.Name, s.Operations)
Output:
BenchmarkDecode/full-8 128

type ScoreABBANVML

type ScoreABBANVML struct {
	Available     bool     `json:"available"`
	DriverVersion string   `json:"driver_version,omitempty"`
	DeviceName    string   `json:"device_name,omitempty"`
	Samples       int      `json:"samples,omitempty"`
	SMClockMHzMin int      `json:"sm_clock_mhz_min,omitempty"`
	SMClockMHzMax int      `json:"sm_clock_mhz_max,omitempty"`
	MaxPowerW     *float64 `json:"max_power_w,omitempty"`
	ThrottleHits  int      `json:"throttle_hits,omitempty"`
}

ScoreABBANVML captures the optional NVML telemetry summary recorded alongside a ScoreABBA benchmark metadata receipt.

type ScoreABBAOptions

type ScoreABBAOptions struct {
	// Source identifies the input artifact in Sample.Source (default "scoreabba.json").
	Source string
	// BenchmarkPrefix is the Go benchmark name prefix (default "BenchmarkScoreABBA").
	BenchmarkPrefix string
	// Package sets the optional "pkg" config header.
	Package string
	// SlotFilter, when non-empty, restricts output to the named slot.
	SlotFilter string
	// Verdict optionally merges a standalone ScoreABBA verdict receipt (such as
	// slot*_verdict.json) into the converted run's config headers and provenance.
	Verdict *ScoreABBAVerdictReceipt
	// Resources optionally joins occupancy, SM resource, roofline, and hardware
	// counter metrics onto matching rows. Keys are merged in precedence order
	// (more specific keys fill unset fields first):
	//   "<slot>/<shape>:<arm>", "<slot>/<shape>", "<shape>:<arm>", "<shape>", "<slot>:<arm>", "<slot>", "<arm>"
	// where <arm> is "base" or "cand".
	Resources map[string]KernelMetrics
}

ScoreABBAOptions controls conversion of a ScoreABBAReceipt into a canonical benchfmt.Run.

type ScoreABBAReceipt

type ScoreABBAReceipt struct {
	DeviceName         string                          `json:"device_name,omitempty"`
	Arch               string                          `json:"arch,omitempty"`
	TorchVersion       string                          `json:"torch_version,omitempty"`
	NVRTCVersion       string                          `json:"nvrtc_version,omitempty"`
	GPULockHeld        string                          `json:"gpu_lock_held,omitempty"`
	NVMLDriver         string                          `json:"nvml_driver,omitempty"`
	NVMLDevice         string                          `json:"nvml_device,omitempty"`
	ScorerBinarySHA256 string                          `json:"scorer_binary_sha256,omitempty"`
	NVML               *ScoreABBANVML                  `json:"nvml,omitempty"`
	Verdict            *ScoreABBAVerdictResult         `json:"result,omitempty"`
	Slots              map[string][]ScoreABBAShapeStat `json:"slots,omitempty"`
}

ScoreABBAReceipt holds decoded ScoreABBA metadata, shape statistics across one or more slots, and an optional verdict result.

func DecodeScoreABBA

func DecodeScoreABBA(r io.Reader) (ScoreABBAReceipt, error)

DecodeScoreABBA reads a ScoreABBA metadata receipt (such as tileir_benchmark_meta.json), a wrapped verdict receipt (such as slot*_verdict.json), or a standalone ScoreABBAVerdictResult JSON.

type ScoreABBAShapeStat

type ScoreABBAShapeStat struct {
	ShapeName     string         `json:"shape_name"`
	HeldOut       *bool          `json:"held_out,omitempty"`
	ParityPassed  *bool          `json:"parity_passed,omitempty"`
	Operations    int64          `json:"operations,omitempty"`
	MaxErr        *float64       `json:"max_err,omitempty"`
	MedAUS        *float64       `json:"med_a_us,omitempty"`
	MedBUS        *float64       `json:"med_b_us,omitempty"`
	MedANS        *float64       `json:"med_a_ns,omitempty"`
	MedBNS        *float64       `json:"med_b_ns,omitempty"`
	DeltaUS       *float64       `json:"delta_us,omitempty"`
	SpeedupRatio  *float64       `json:"speedup_ratio,omitempty"`
	SpeedupPct    *float64       `json:"speedup_pct,omitempty"`
	ATFLOPS       *float64       `json:"a_tflops,omitempty"`
	BTFLOPS       *float64       `json:"b_tflops,omitempty"`
	AGBPerS       *float64       `json:"a_gb_per_s,omitempty"`
	BGBPerS       *float64       `json:"b_gb_per_s,omitempty"`
	APctRoofline  *float64       `json:"a_pct_roofline,omitempty"`
	BPctRoofline  *float64       `json:"b_pct_roofline,omitempty"`
	BaseMetrics   *KernelMetrics `json:"a_resources,omitempty"`
	CandMetrics   *KernelMetrics `json:"b_resources,omitempty"`
	ErrVsFP32Ref  *float64       `json:"err_vs_fp32_ref,omitempty"`
	ErrVsCuBLASLt *float64       `json:"err_vs_cublaslt,omitempty"`
}

ScoreABBAShapeStat is one per-shape ABBA comparison entry from a kernel benchmark metadata receipt (such as tileir_benchmark_meta.json).

type ScoreABBAVerdictReceipt

type ScoreABBAVerdictReceipt struct {
	OSScorerUID        int                     `json:"os_scorer_uid,omitempty"`
	OSEUID             int                     `json:"os_euid,omitempty"`
	WorkerUID          int                     `json:"worker_uid,omitempty"`
	GPULockHeld        string                  `json:"gpu_lock_held,omitempty"`
	NVMLDriver         string                  `json:"nvml_driver,omitempty"`
	NVMLDevice         string                  `json:"nvml_device,omitempty"`
	ForeignApps        *int                    `json:"foreign_apps,omitempty"`
	ScorerBinarySHA256 string                  `json:"scorer_binary_sha256,omitempty"`
	Result             *ScoreABBAVerdictResult `json:"result,omitempty"`
	AllUIDChecksOK     *bool                   `json:"all_uid_checks_ok,omitempty"`
}

ScoreABBAVerdictReceipt mirrors a wrapped ScoreABBA verdict receipt file (such as slot*_verdict.json) or a standalone ScoreABBAVerdictResult JSON.

func DecodeScoreABBAVerdict

func DecodeScoreABBAVerdict(r io.Reader) (ScoreABBAVerdictReceipt, error)

DecodeScoreABBAVerdict reads a standalone ScoreABBA verdict receipt JSON (either wrapped in {"result": {...}} or a flat ScoreABBAVerdictResult).

type ScoreABBAVerdictResult

type ScoreABBAVerdictResult struct {
	Verdict          string   `json:"verdict"`
	Outcome          string   `json:"outcome"`
	ParityPassed     *bool    `json:"parity_passed,omitempty"`
	HeldOutPassed    *bool    `json:"held_out_passed,omitempty"`
	MeanSpeedupPct   *float64 `json:"mean_speedup_pct,omitempty"`
	MedianSpeedupPct *float64 `json:"median_speedup_pct,omitempty"`
	MeanDeltaNS      *float64 `json:"mean_delta_ns,omitempty"`
	MedianDeltaNS    *float64 `json:"median_delta_ns,omitempty"`
	StdErrNS         *float64 `json:"std_err_ns,omitempty"`
	TStat            *float64 `json:"t_stat,omitempty"`
	ValidBlocks      int64    `json:"valid_blocks,omitempty"`
	RejectedBlocks   int64    `json:"rejected_blocks,omitempty"`
	ThrottledSamples int64    `json:"throttled_samples,omitempty"`
	ScorerDigest     string   `json:"scorer_digest,omitempty"`
	ProbeDigest      string   `json:"probe_digest,omitempty"`
	ReferenceDigest  string   `json:"reference_digest,omitempty"`
	DeviceArch       string   `json:"device_arch,omitempty"`
	Reason           string   `json:"reason,omitempty"`
}

ScoreABBAVerdictResult mirrors the JSON output of hotreload.ScoreABBA without importing or forking nvidia/x/cuda/hotreload.

type VerdictStatus

type VerdictStatus string

VerdictStatus classifies an observed metric against a calibrated NoiseFloor.

const (
	VerdictWithinNoise VerdictStatus = "WITHIN_NOISE"
	VerdictAboveFloor  VerdictStatus = "ABOVE_FLOOR"
	VerdictUnproven    VerdictStatus = "UNPROVEN"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL