experiment

package
v0.6.21 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 7 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.

Documentation

Overview

Package experiment defines the portable contract, arm, sample, and receipt types shared by the mlxperf optimization arena and its measurement harnesses.

A Receipt is the canonical result of one measured experiment. It binds a Workload identity, the raw Sample records in execution order, every typed Refusal raised while measuring or analyzing, and a final verdict. Receipts are sealed with a SHA-256 digest over their canonical JSON form so a receipt cannot be edited after the fact without detection.

The zero value of every type here is not meaningful; construct receipts by measuring an experiment (see github.com/tmc/apple/x/armbench) or by decoding a sealed receipt with ParseReceipt, which verifies the digest.

Index

Constants

View Source
const (
	// VerdictFaster means the candidate beat the baseline beyond the noise
	// measured by the duplicate control.
	VerdictFaster = "faster"
	// VerdictSlower means the candidate lost to the baseline.
	VerdictSlower = "slower"
	// VerdictNoWinner means no performance conclusion is possible: the
	// claimed delta does not exceed the control gap.
	VerdictNoWinner = "no-winner"
	// VerdictRefused means a gate refused the experiment; there is no score.
	VerdictRefused = "refused"
)

Receipt verdicts.

View Source
const (
	RefusalUnequalWork         = "unequal-work"
	RefusalCorrectnessFailed   = "correctness-failed"
	RefusalMissingControl      = "missing-duplicate-control"
	RefusalImpossibleByteRate  = "impossible-byte-rate"
	RefusalContaminatedHost    = "contaminated-host"
	RefusalIdenticalArms       = "identical-arms"
	RefusalInsufficientSamples = "insufficient-samples"
	RefusalIdentityDrift       = "identity-drift"
)

Refusal reasons. These are contract, not prose: analysis code switches on them.

View Source
const Schema = "mlxperf.receipt/v1"

Schema is the receipt schema identifier written into every receipt.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArmKind

type ArmKind string

ArmKind classifies an arm's role in an experiment.

const (
	// ArmBaseline is the immutable reference arm.
	ArmBaseline ArmKind = "baseline"
	// ArmCandidate is the arm under test.
	ArmCandidate ArmKind = "candidate"
	// ArmDuplicate is an identical duplicate control used to estimate
	// harness noise. An experiment without one may not conclude performance.
	ArmDuplicate ArmKind = "duplicate"
)

type Receipt

type Receipt struct {
	Schema    string    `json:"schema"`
	CreatedAt time.Time `json:"created_at"`
	Workload  Workload  `json:"workload"`
	Label     string    `json:"label,omitempty"`
	Samples   []Sample  `json:"samples"`
	Refusals  []Refusal `json:"refusals,omitempty"`
	Verdict   string    `json:"verdict"`
	Winner    string    `json:"winner,omitempty"`
	Digest    string    `json:"digest"`
}

Receipt is the canonical result of one measured experiment.

func ParseReceipt

func ParseReceipt(b []byte) (*Receipt, error)

ParseReceipt decodes a JSON-encoded receipt and verifies its schema and digest. A receipt that fails verification is returned alongside the error so callers can retain the tampered evidence.

func (*Receipt) HasRefusal

func (r *Receipt) HasRefusal(reason string) bool

HasRefusal reports whether a refusal with the given reason was recorded.

func (*Receipt) Marshal

func (r *Receipt) Marshal() ([]byte, error)

Marshal canonicalizes and seals the receipt, then encodes it as JSON.

func (*Receipt) Refused

func (r *Receipt) Refused() bool

Refused reports whether any refusal was recorded.

func (*Receipt) Seal

func (r *Receipt) Seal() error

Seal computes the digest over the canonical form of the receipt (with the digest field cleared) and stores it.

func (*Receipt) Verify

func (r *Receipt) Verify() error

Verify checks that a sealed receipt still matches its digest.

type Refusal

type Refusal struct {
	Reason string `json:"reason"`
	Detail string `json:"detail,omitempty"`
}

Refusal is a typed reason the arena declined to rank or promote. A refusal replaces a score; it never annotates one.

func (Refusal) Error

func (r Refusal) Error() string

type Sample

type Sample struct {
	Arm       string           `json:"arm"`
	Kind      ArmKind          `json:"kind"`
	Round     int              `json:"round"`
	Order     int              `json:"order"`
	Elapsed   time.Duration    `json:"elapsed"`
	WorkUnits int64            `json:"work_units"`
	Bytes     map[string]int64 `json:"bytes,omitempty"`
	Output    string           `json:"output,omitempty"`
	Verdict   Verdict          `json:"verdict"`
	Note      string           `json:"note,omitempty"`
}

Sample is one measured arm execution with its order and environment observations.

type Verdict

type Verdict string

Verdict records the correctness outcome of one sample.

const (
	VerdictPass Verdict = "pass"
	VerdictFail Verdict = "fail"
)

type Workload

type Workload struct {
	ID        string           `json:"id"`
	WorkUnits int64            `json:"work_units"`
	Bytes     map[string]int64 `json:"bytes,omitempty"`
}

Workload identifies what was measured. Any change to identity, work units, or byte accounting creates a new workload; receipts for different workloads are never comparable.

Jump to

Keyboard shortcuts

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