Documentation
¶
Overview ¶
Package outputcontract defines pure-stdlib recorded output contracts, two-fill write-domain classification, and bounded FP32 comparison policies shared between nvidia/x/cuda/cudatest and nvidia/x/isa/ptx.
Index ¶
- Variables
- func CompareCUDAOutputFP32(actual, expected []float32, p CUDAOutputPolicy) error
- func IsDigest(s string) bool
- func ValidateTwoFill(t TwoFill) error
- type CUDAOutputMismatch
- type CUDAOutputPolicy
- type Contract
- type CoverageReport
- type Geometry
- type Kind
- type PairedReport
- type Range
- type RecordedOutput
- type TwoFill
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCUDAOutput = errors.New("invalid CUDA output comparison")
ErrInvalidCUDAOutput distinguishes a malformed policy or readback from a numerical mismatch. An empty domain is valid only when Elements is zero and both buffers are empty.
Functions ¶
func CompareCUDAOutputFP32 ¶
func CompareCUDAOutputFP32(actual, expected []float32, p CUDAOutputPolicy) error
CompareCUDAOutputFP32 checks every declared logical element. It does not normalize buffers, establish that elements were written, or replace trace hashing. Invalid reference values under the chosen policy are input errors; invalid actual values are mismatches.
func ValidateTwoFill ¶
ValidateTwoFill checks admission invariants for a two-fill spec before running or classifying readbacks.
Types ¶
type CUDAOutputMismatch ¶
type CUDAOutputMismatch struct {
Index int
Actual, Expected float32
ActualBits, ExpectedBits uint32
Policy CUDAOutputPolicy
}
CUDAOutputMismatch retains the first bad logical index, FP32 values and bits, and the policy identities. It reports output disagreement, not bad input.
func (*CUDAOutputMismatch) Error ¶
func (m *CUDAOutputMismatch) Error() string
Error describes the first disagreement including its reproducible identities.
type CUDAOutputPolicy ¶
type CUDAOutputPolicy struct {
Target, DType, MathMode string
SourceDigest, InputDigest string
Elements int
Absolute, Relative float64
NaN, Infinity, Zero string
}
CUDAOutputPolicy identifies a bounded CUDA FP32 comparison. Its zero value is invalid. SourceDigest and InputDigest are lowercase SHA-256 receipts; Target and MathMode describe the actual compiled consumer, not a default. NaN is "reject" or "semantic" (both values NaN, without payload equality). Infinity is "reject" or "same-sign". Zero is "equal" or "bits". Finite values pass when abs(actual-expected) <= Absolute + Relative * max(abs(actual), abs(expected)). The implementation rearranges this formula to avoid overflowing a tolerance product or sum.
type Contract ¶
type Contract struct {
Buffer string
Elements int
Domain []Range
Kind Kind
Atomic, Reduction bool
ExpectedWriters uint64
Deterministic bool
}
Contract declares a buffer's write domain and writer semantics. Elements includes padding; Domain excludes it and must be sorted, nonoverlapping and nonempty. Atomic and Reduction require WriterCount or Accumulated.
type CoverageReport ¶
type CoverageReport struct {
Contract Contract
Arm string
Geometry Geometry
Unwritten, Nondeterministic []Range
SourceDigest, InputDigest, Target, MathMode string
}
CoverageReport separates write-domain failures from nondeterministic readbacks. Numerical correctness must be checked independently.
func ClassifyTwoFill ¶
func ClassifyTwoFill(t TwoFill) (CoverageReport, error)
ClassifyTwoFill checks recorded readbacks without touching hardware. Invalid admission is an error, never an empty successful report.
type Geometry ¶
type Geometry struct{ Grid, Block [3]uint32 }
Geometry records the admitted launch dimensions, rather than deriving them from the logical domain.
type PairedReport ¶
type PairedReport struct {
Written CoverageReport
NumericalMismatch *CUDAOutputMismatch
}
PairedReport keeps written-domain and numerical findings separate. A nil NumericalMismatch means the admitted numerical comparison passed; it says nothing about whether the launch wrote the output.
func CheckOutput ¶
func CheckOutput(t TwoFill, ordinary []uint32, p CUDAOutputPolicy) (PairedReport, error)
CheckOutput checks a recorded ordinary readback numerically using the integrated CUDA output policy and checks the two-fill readbacks for writes. Policy.Elements is the number of domain elements, excluding declared padding. All execution identities must match. NumericalMismatch.Index is the logical buffer index, not a flattened-domain index.
type Range ¶
type Range struct{ Start, End int }
Range is a half-open logical element interval [Start, End).
type RecordedOutput ¶
type RecordedOutput struct {
PTXDigest string
TwoFill TwoFill
Ordinary []uint32
Policy CUDAOutputPolicy
}
RecordedOutput retains the completed readbacks and policy used to check a campaign run. PTXDigest identifies the runner's loaded PTX; SourceDigest in TwoFill identifies the CUDA source. Neither digest substitutes for the other. These are producer claims, not independent device or process attestation. A campaign snapshots its slices when the runner returns. The runner must complete device work before returning and must not mutate evidence concurrently.
type TwoFill ¶
type TwoFill struct {
Contract Contract
FillA, FillB uint32
Reference, ReadbackA, ReadbackB []uint32
Geometry Geometry
SourceDigest, InputDigest string
Target, MathMode string
}
TwoFill records reference and readback bits from two executions with the same admitted inputs, artifact, launch geometry and contract.