appcause

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT 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.

Documentation

Overview

Package appcause holds the application cause document, dispatch.app-cause.v1, and the beat, launch.beat.v1, that a launcher inside the job writes and an adapter reads: their types, strict decoders and writers, and Refine, the one rule by which a document refines a scheduler's cause.

Both schemas are fixed from R1: a change to their members is a new schema name. The package imports the standard library and model only, so the writer (go/launch) and the readers (the adapters) share one definition (go/dispatch spec 0001 D1, 0003 D2; go/launch spec 0001 D6, D7).

Index

Constants

View Source
const (
	BeatSchema     = "launch.beat.v1"
	MaxBeatSize    = 512
	BeatLinePrefix = "LAUNCH-BEAT "
)

BeatSchema is the beat's schema name, MaxBeatSize the bound on its encoding, and BeatLinePrefix what starts a beat line in a Kubeflow rank 0 log (go/launch spec 0001 D6).

View Source
const (
	Schema  = "dispatch.app-cause.v1"
	MaxSize = 2048
)

Schema is the cause document's schema name, and MaxSize the bound on its whole encoding.

View Source
const (
	HeartbeatOn  = "on"
	HeartbeatOff = "off"

	GPUNVML     = "nvml"
	GPUAbsent   = "absent"
	GPUNotBuilt = "not-built"
	GPUOff      = "off"

	SourceErrorJSON = "error-json"
	SourceNCCL      = "nccl"
	SourceStderr    = "stderr"
	SourceNVML      = "nvml"
)

The values of Document.Heartbeat, Document.GPU and Evidence.Source.

Variables

View Source
var (
	ErrTooLarge     = fmt.Errorf("%w: appcause: over its size bound", model.ErrInvalid)
	ErrSchema       = fmt.Errorf("%w: appcause: not this schema", model.ErrInvalid)
	ErrMalformed    = fmt.Errorf("%w: appcause: malformed", model.ErrInvalid)
	ErrInconsistent = fmt.Errorf("%w: appcause: inconsistent", model.ErrInvalid)
)

The decoders' sentinels, each wrapping model.ErrInvalid.

Functions

func Encode

func Encode(d Document, redact func(string) string) ([]byte, error)

Encode writes d as the launcher does (go/launch spec 0001 D7): every string through redact first, then each control character in free text as a space, then the caps, then, while the encoding exceeds MaxSize, the oldest evidence dropped, then the second fault, then the summary halved. It refuses what Decode would.

func EncodeBeat

func EncodeBeat(b Beat) ([]byte, error)

EncodeBeat writes b, refusing what DecodeBeat would.

func WriteFile

func WriteFile(path string, b []byte) error

WriteFile writes b to path in place: truncate, one write, then fsync. Not by rename, because on Kubeflow path is the container's termination-message file, a mount point a rename fails on (go/launch spec 0001 D7).

Types

type Beat

type Beat struct {
	Schema     string `json:"schema"`
	Seq        uint64 `json:"seq"`
	Step       int    `json:"step"`
	Phase      string `json:"phase"`
	Nodes      int    `json:"nodes"`
	StaleAfter int    `json:"staleAfter"`
}

Beat is one launch.beat.v1 beat: proof the launcher is alive, which an adapter judges on its own clock, never on a time written on a compute node. Seq rises on every write, and StaleAfter is whole seconds.

func DecodeBeat

func DecodeBeat(b []byte) (Beat, error)

DecodeBeat reads one beat as Decode reads a document, bounded by MaxBeatSize.

func ParseBeatLine

func ParseBeatLine(line string) (Beat, bool, error)

ParseBeatLine decodes a log line that starts with BeatLinePrefix, and is false for any other.

type Class

type Class string

Class is the launcher's own refinement of a kind, versioned with this schema, never a record.

const (
	ClassException        Class = "exception"
	ClassSignalled        Class = "signalled"
	ClassLaunchError      Class = "launch-error"
	ClassUnclassified     Class = "unclassified"
	ClassHung             Class = "hung"
	ClassCollectiveFailed Class = "collective-failed"
	ClassGPUFault         Class = "gpu-fault"
	ClassGPUOutOfMemory   Class = "gpu-out-of-memory"
)

The classes: the first four refine KindNonZeroExit, and each other kind takes its own name.

type Document

type Document struct {
	Schema     string     `json:"schema"`
	Phase      Phase      `json:"phase"`
	Kind       Kind       `json:"kind,omitempty"`
	Class      Class      `json:"class,omitempty"`
	Summary    string     `json:"summary,omitempty"`
	At         time.Time  `json:"at"`
	Attempt    string     `json:"attempt"`
	Epoch      string     `json:"epoch"`
	Node       string     `json:"node,omitempty"`
	NodeRank   *int       `json:"nodeRank,omitempty"`
	ExitCode   *int       `json:"exitCode,omitempty"`
	LastStep   *int       `json:"lastStep,omitempty"`
	LastPhase  string     `json:"lastPhase,omitempty"`
	LastBeatAt time.Time  `json:"lastBeatAt,omitzero"`
	Heartbeat  string     `json:"heartbeat"`
	GPU        string     `json:"gpu"`
	Signal     *Signal    `json:"signal,omitempty"`
	Evidence   []Evidence `json:"evidence,omitempty"`
	Faults     []Fault    `json:"faults,omitempty"`
}

Document is one dispatch.app-cause.v1 document. Its members and their bounds are fixed for v1 (go/launch spec 0001 D7).

func Decode

func Decode(b []byte) (Document, error)

Decode reads one dispatch.app-cause.v1 document strictly: its size, then its schema alone, then every member, refusing an unknown one at any level, then each member's bound, then the members' consistency. Its times are in UTC.

func Refine

func Refine(sched model.Cause, exec model.ExecutionObs, doc []byte, found bool) (model.Cause, Document, bool)

Refine is the one rule by which the document an execution's launcher wrote refines the scheduler's cause sched (go/dispatch spec 0003 D2). doc is what the adapter read, up to MaxSize+1 bytes, and found whether there was a file to read.

It returns the cause to report, the decoded document (zero when it did not decode), and whether the document was used. The result keeps sched's provenance, exit code and time, and its kind is always one this build defines.

func (Document) Cause

func (d Document) Cause() (model.CauseKind, bool)

Cause maps the document's kind to the model.CauseKind this build names, and is false for a kind it does not, such as R2's four on R1. It never returns a kind for which Valid is false.

type Evidence

type Evidence struct {
	Source string `json:"source"`
	Rank   *int   `json:"rank,omitempty"`
	Line   string `json:"line"`
}

Evidence is one line the launcher found, oldest first in Document.Evidence.

type Fault

type Fault struct {
	GPU string `json:"gpu"`
	Xid []int  `json:"xid,omitempty"`
}

Fault is a GPU's Xid errors.

type Kind

type Kind string

Kind is the launcher's cause kind, by name. It is never a model.CauseKind, so that a name this build's model does not define still decodes and re-encodes (go/launch spec 0001 D15).

const (
	KindNone             Kind = "none"
	KindNonZeroExit      Kind = "non-zero-exit"
	KindHung             Kind = "hung"
	KindCollectiveFailed Kind = "collective-failed"
	KindGPUFault         Kind = "gpu-fault"
	KindGPUOutOfMemory   Kind = "gpu-out-of-memory"
)

The six kinds v1 takes; any other name is refused.

type Phase

type Phase string

Phase is how far the launcher got: a document left before PhaseEnded means it was killed.

const (
	PhaseStarted   Phase = "started"
	PhaseSignalled Phase = "signalled"
	PhaseEnded     Phase = "ended"
)

The phases.

type Signal

type Signal struct {
	At             time.Time `json:"at"`
	CheckpointStep *int      `json:"checkpointStep,omitempty"`
}

Signal is when the launcher was first signalled, and the step its checkpoint holds.

Jump to

Keyboard shortcuts

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