Documentation
¶
Overview ¶
Package launch is the entrypoint inside a distributed training job: a static launcher that runs torchrun under dispatch's execution identity, turns the scheduler's SIGTERM into one checkpoint request inside its kill window, detects hangs from a payload heartbeat, and leaves a cause document the adapter reads back.
Spec: https://gitlab.com/phpboyscout/go/launch/-/wikis/specs/0001-the-launcher. The package's public surface is the binary's: the command line, launch.yaml and the documents.
It must build with CGO_ENABLED=0, so it runs on any training image.
Index ¶
- Constants
- Variables
- func ControlDir(getenv func(string) string, attempt string, nodeRank int) string
- func OutputDir(c *config.Checkpoint, attempt string) string
- func ParseSrunVersion(out string) (major, minor int, err error)
- func RankEnv(train *config.Train, c *config.Checkpoint, ...) map[string]string
- func RendezvousPort(ctx context.Context, configured int) (int, error)
- func ResolveProcsPerNode(train *config.Train, mode Mode, getenv func(string) string) (int, error)
- func ServeConfig(s *config.Serve) serve.Config
- func ServeTempDir(getenv func(string) string) string
- type Agent
- type CheckpointDone
- type Coordinator
- type CoordinatorInput
- type DocumentHeader
- func (h DocumentHeader) Ended(o Outcome) appcause.Document
- func (h DocumentHeader) LaunchFailed(now time.Time, exitCode int, err error) appcause.Document
- func (h DocumentHeader) Signalled(at time.Time) appcause.Document
- func (h DocumentHeader) Stalling(stall Stall, at time.Time) appcause.Document
- func (h DocumentHeader) Started(now time.Time) appcause.Document
- type Finding
- type Grace
- type HeartbeatWatch
- type Identity
- type KubeflowInput
- type Mode
- type NodeEnd
- type NodeInput
- type Outcome
- type PlanInput
- type Publisher
- type Pulse
- type RankLogs
- type Reaper
- type Rendezvous
- type ResumeFetch
- type ResumeShare
- type ServePlan
- type Site
- type Stall
- type StepAction
- type StepBounds
- type StepWatch
- func (w *StepWatch) Line(line string, now time.Time)
- func (w *StepWatch) Merge(h DocumentHeader, srunExit int, now time.Time) (appcause.Document, int)
- func (w *StepWatch) NodesAlive(now time.Time) int
- func (w *StepWatch) Progress() (int, string)
- func (w *StepWatch) Signalled(now time.Time)
- func (w *StepWatch) StepID() string
- func (w *StepWatch) Tick(now time.Time) StepAction
- type TorchrunParams
- type TrainPlan
- type WatchLoop
- type Window
Constants ¶
const ( ExitUsage = 64 ExitSoftware = 70 ExitHung = 124 ExitSignal = 143 )
Exit codes the launcher chooses for itself (spec 0001 D12).
const ( EnvOutputDir = "LAUNCH_OUTPUT_DIR" EnvResumeFrom = "LAUNCH_RESUME_FROM" EnvHeartbeatFile = "LAUNCH_HEARTBEAT_FILE" EnvCheckpointRequest = "LAUNCH_CHECKPOINT_REQUEST" EnvCheckpointDone = "LAUNCH_CHECKPOINT_DONE" )
Variables the launcher gives every rank.
const ( ResumeUnresolved = "unresolved" ResumeNone = "none" )
The values of TrainPlan.ResumePoint.
Variables ¶
var ErrRefused = errors.New("launch refused")
ErrRefused wraps every refusal to start, which the command line exits 64 on (spec 0001 D12).
var ErrReportUnwritten = errors.New("node report not written")
ErrReportUnwritten says the node's report did not reach stdout. A coordinator names a missing report and decides by srun's exit (D1), so it says nothing about the run and leaves the exit code alone.
var ErrResumeAnswer = errors.New("the resume point node rank 0 served can't be used")
ErrResumeAnswer says an answer from node rank 0 can't be used: asking again would get the same one, so a fetch gives up at once. An answer from another attempt could resume from another execution's save (D4).
Functions ¶
func ControlDir ¶
ControlDir is this execution's directory on this node: a rank's control files need no shared filesystem, and a save's own directory is the job's. The node rank keeps nodes apart where TMPDIR is shared after all, and the attempt is escaped as it names one path part.
func OutputDir ¶
func OutputDir(c *config.Checkpoint, attempt string) string
OutputDir is the folder a framework must write its saves to (spec 0001 D4, 0001 D16).
func ParseSrunVersion ¶
ParseSrunVersion reads `srun --version`, and refuses an answer it cannot parse rather than guess.
func RankEnv ¶
func RankEnv(train *config.Train, c *config.Checkpoint, attempt, resumeFrom, controlDir string) map[string]string
RankEnv is what the launcher adds to torchrun's environment. train.env is the job's own, and the launcher's names win because D3 refuses those names in train.env.
func RendezvousPort ¶
RendezvousPort is the configured port, or with 0 one the kernel just chose (D4). Another process can take a chosen port before torchrun binds it, and is_host makes that fail rather than join its store.
func ResolveProcsPerNode ¶
ResolveProcsPerNode takes train.procsPerNode, or the scheduler's value, and refuses rather than guess from the GPUs it can see (open question 11).
func ServeConfig ¶
ServeConfig turns the serve section into what package serve runs.
func ServeTempDir ¶
ServeTempDir is where a serve keeps its manifest: $TMPDIR, or the system's.
Types ¶
type Agent ¶
type Agent struct {
Header DocumentHeader
// Argv and Env are torchrun's command and whole environment.
Argv []string
Env []string
// Output takes torchrun's stdout and stderr: on Slurm the agent's own stdout carries reports.
Output io.Writer
Grace Grace
Logs *RankLogs
// Heartbeat is nil without a heartbeat section.
Heartbeat *config.Heartbeat
HeartbeatFile string
// ControlDir holds those files, for RemoveControlDir.
ControlDir string
// CheckpointRequest and CheckpointDone are the payload's two control files.
CheckpointRequest string
CheckpointDone string
// Signals carries SIGTERM and the coordinator's SIGUSR1.
Signals <-chan os.Signal
// Prepare runs after the started document and before torchrun, and returns the argv and environment
// to run it with, once they depend on what the nodes agree. Nil keeps Argv and Env.
Prepare func(context.Context) ([]string, []string, error)
// Publisher is set on node rank 0 of a checkpointing job.
Publisher *Publisher
// Emit publishes one encoded document: the cause file on Kubeflow, a node report on Slurm.
Emit func(appcause.Phase, []byte) error
// GPU reads health, and nil reads none, leaving Header.GPU as the caller set it. Run closes it.
GPU gpu.Reader
// GPURequired is gpu.health: required, which refuses to start without a first reading.
GPURequired bool
// GPUReadBound is how long a reading may take; zero means 2 s, as the last one falls inside the
// scheduler's kill window.
GPUReadBound time.Duration
// Pulse is the agent's stdout lines, or nil.
Pulse *Pulse
// Tick is how often logs and the heartbeat are read; zero means every second.
Tick time.Duration
// Now is the clock; nil means time.Now.
Now func() time.Time
// Reaper is the launcher's reaper if it already has one. Without one, Run starts its own when it
// is PID 1 (D1).
Reaper *Reaper
// SignalProcess sends torchrun its signal; nil means the process's own Signal. Standard signals
// coalesce, so a test can count them only here.
SignalProcess func(*os.Process, os.Signal) error
// contains filtered or unexported fields
}
Agent is the per-node half of the launcher (spec 0001 D1): it runs torchrun, watches it, and turns a signal or a hang into one request to the ranks.
func NewKubeflowAgent ¶
func NewKubeflowAgent(in KubeflowInput) (*Agent, error)
NewKubeflowAgent builds the agent for one pod and makes its control directory, from the plan `launch train -print` shows. There is no coordinator here: each agent writes its own document, and the adapter merges them (D1).
func NewSlurmAgent ¶
NewSlurmAgent builds the agent for one node of an srun step and makes its control directory. The directory must not exist: a leftover error file would be read as this run's, and on a shared /tmp someone else may have made it.
func (*Agent) RemoveControlDir ¶
func (a *Agent) RemoveControlDir()
RemoveControlDir ends this run's use of the directory: a shared TMPDIR would otherwise keep one for every execution, and the document already carries what its files said.
type CheckpointDone ¶
CheckpointDone is what a payload's done file says: the save is complete on every rank (spec 0001 D5).
func ReadCheckpointDone ¶
func ReadCheckpointDone(path string) (*CheckpointDone, error)
ReadCheckpointDone reads the done file, and returns nil when there is none. A path that leaves the output directory is refused, since it is about to be published.
type Coordinator ¶
type Coordinator struct {
Nodes int
Site Site
// AgentArgv is `launch agent` and its flags, which srun runs once per node.
AgentArgv []string
// Prepare resolves what every agent must agree on and returns it as more flags, or nil for none.
// It runs after the started document, so a failure or a signal during it is recorded.
Prepare func(context.Context) ([]string, error)
Bounds StepBounds
Header DocumentHeader
Env []string
// Output is srun's stderr, and where the coordinator says what it did.
Output io.Writer
// Signals carries the scheduler's SIGTERM.
Signals <-chan os.Signal
// Emit publishes one encoded document, the cause file.
Emit func(appcause.Phase, []byte) error
// Srun and Scancel are the commands' paths; empty means the PATH's.
Srun string
Scancel string
// MergeBound is how long after killing the step the document may wait for srun; zero means 900 ms,
// since the scheduler's kill window may be running.
MergeBound time.Duration
// BeatFile is where the supervisor reads the beat (D6); empty writes none.
BeatFile string
// BeatEvery is how often it is written; zero means D6's 30 s.
BeatEvery time.Duration
// Tick is how often the bounds are judged; zero means every 100 ms.
Tick time.Duration
// Now is the clock; nil means time.Now.
Now func() time.Time
// contains filtered or unexported fields
}
Coordinator starts one agent per node with srun and writes the execution's one document (spec 0001 D1). It exists only on Slurm, where dispatch runs the command once.
func NewCoordinator ¶
func NewCoordinator(in CoordinatorInput) (*Coordinator, error)
NewCoordinator builds the coordinator from the plan `launch train -print` shows, so that the two make the same refusals. It starts nothing.
func (*Coordinator) Run ¶
func (c *Coordinator) Run() int
Run runs the step to its end and returns the coordinator's exit code.
func (*Coordinator) SrunArgv ¶
func (c *Coordinator) SrunArgv() []string
SrunArgv is D1's srun line. --ignore-signals exists only from 26.05, where srun would otherwise turn the scheduler's SIGTERM into SIGKILL for its tasks.
type CoordinatorInput ¶
type CoordinatorInput struct {
Plan PlanInput
Environ []string
Output io.Writer
Signals <-chan os.Signal
// Executable and ConfigPath are this binary and the launch.yaml, which every agent runs in turn.
Executable string
ConfigPath string
// Srun is the command's path; empty means the PATH's.
Srun string
// ChoosePort picks the rendezvous port; nil means RendezvousPort.
ChoosePort func(context.Context, int) (int, error)
}
CoordinatorInput is what `launch train` is given on Slurm, beyond what a plan reads.
type DocumentHeader ¶
type DocumentHeader struct {
Identity Identity
Node string
NodeRank *int
// Heartbeat and GPU are the appcause values: on or off, and nvml, absent, not-built or off.
Heartbeat string
GPU string
}
DocumentHeader is what every cause document of one agent's run says about itself (spec 0001 D7).
func (DocumentHeader) Ended ¶
func (h DocumentHeader) Ended(o Outcome) appcause.Document
Ended is the document's last write. The kind after a signal follows D7: a failure classified before the signal keeps its kind, and otherwise the run was stopped, not failed. kind none is only for torchrun exiting 0 with no signal, so what a succeeding run printed on its way is not a cause.
func (DocumentHeader) LaunchFailed ¶
LaunchFailed is the document of the launcher's own failure (D12, exit 70).
func (DocumentHeader) Signalled ¶
func (h DocumentHeader) Signalled(at time.Time) appcause.Document
Signalled is written on the first signal.
func (DocumentHeader) Stalling ¶
Stalling is written when the agent judges a hang, before it stops torchrun, so a kill during the grace still leaves the finding. The phase stays started: nothing has signalled the launcher, and an unfinished phase is what tells the adapter this classification was never completed (D7).
type Finding ¶
type Finding struct {
// At is when the agent first saw the failure, not when the process exited, since an agent that
// waits out a grace exits later than the failure it saw.
At time.Time
Kind appcause.Kind
Class appcause.Class
Summary string
Evidence []appcause.Evidence
Faults []appcause.Fault
}
Finding is one thing that went wrong on a node, or across nodes once merged (spec 0001 D8).
func ClassifyNode ¶
ClassifyNode is one node's findings: each rank's, then the GPU faults, or the unclassified fallback for a non-zero exit with nothing to show for it.
func MergeFindings ¶
MergeFindings applies D8's rule, on the agent and on the coordinator alike: the earliest finding is the cause, a tie falls to tieOrder, and the rest go in the summary as a count and the first two. It reports false when there is nothing to merge.
type Grace ¶
type Grace struct {
// Payload is g: the most the ranks get.
Payload int `json:"payload"`
// PublishBudget is P: the save's publication, 0 with no checkpoint.
PublishBudget int `json:"publishBudget"`
// StopWait is how long a coordinator waits for reports: g + 4 + P.
StopWait int `json:"stopWait"`
}
Grace is how D5's window is spent. All are whole seconds, since --shutdown-timeout is an integer.
func ComputeGrace ¶
ComputeGrace applies g = min(signal.grace, K − 7 − P). A checkpointing job the window cannot honour is refused unless signal.grace: 0s says no save is wanted (open question 19), since a checkpoint contract that cannot be kept is a silent loss. noGrace names why a Slurm site gives no grace at all, or is empty.
func (Grace) TorchrunWait ¶
TorchrunWait is how long an agent waits for torchrun before SIGKILL: g + 2.
type HeartbeatWatch ¶
type HeartbeatWatch struct {
// contains filtered or unexported fields
}
HeartbeatWatch judges the payload's heartbeat file (spec 0001 D6). It is called on a ticker, and stops being called at the first signal, since the grace is D5's.
func NewHeartbeatWatch ¶
NewHeartbeatWatch watches path, judged from when torchrun started.
func (*HeartbeatWatch) LastStep ¶
func (h *HeartbeatWatch) LastStep() *int
LastStep is the last completed step a beat named, or nil.
func (*HeartbeatWatch) Notes ¶
func (h *HeartbeatWatch) Notes() []string
Notes are what the file held that the watch could not take at face value, for the document's evidence.
func (*HeartbeatWatch) Observe ¶
func (h *HeartbeatWatch) Observe(now time.Time) (Stall, bool)
Observe reads the file and reports a stall once no beat has come within the limit that applies.
func (*HeartbeatWatch) Phase ¶
func (h *HeartbeatWatch) Phase() string
Phase is the phase the last understood beat named.
type Identity ¶
type Identity struct {
Attempt string
JobID string
Submission string
Epoch string
// CauseFile is where this execution's document goes.
CauseFile string
}
Identity is what dispatch tells an execution about itself (spec 0003 D8, spec 0001 D4, D14 A).
type KubeflowInput ¶
type KubeflowInput struct {
Plan PlanInput
Environ []string
Stdout io.Writer
Stderr io.Writer
Signals <-chan os.Signal
}
KubeflowInput is what `launch train` is given in a pod, beyond what a plan reads.
type Mode ¶
type Mode string
Mode is which half of the launcher this process is (spec 0001 D1).
The modes launch train can detect.
type NodeInput ¶
type NodeInput struct {
File *config.File
Getenv func(string) string
Environ []string
Hostname func() (string, error)
Stdout io.Writer
Stderr io.Writer
Signals <-chan os.Signal
// Endpoint is the coordinator's host and chosen port.
Endpoint string
Nodes int
Procs int
// NoGrace is the site's reason it gives no grace, from the coordinator's one reading of srun.
NoGrace string
ResumeFrom string
// NVMLBuilt is whether this binary has the nvml build tag, and GPU its reader.
NVMLBuilt bool
GPU gpu.Reader
}
NodeInput is what `launch agent` is given. Procs and Nodes come from the coordinator, because inside a step SLURM_NTASKS_PER_NODE describes the step, one agent per node, and not the job.
type Outcome ¶
type Outcome struct {
Now time.Time
// ExitCode is torchrun's exit status.
ExitCode int
// Cause is the node's findings merged, or nil.
Cause *Finding
// SignalAt is the first signal's time, and zero with none. A signal that arrived after torchrun
// exited 0 is not one: the run had already succeeded (D5, step 1).
SignalAt time.Time
// CheckpointStep is the done file's step, or nil.
CheckpointStep *int
LastStep *int
// Stall is set when the launcher stopped a hung run, and carries the beat's last state.
Stall *Stall
// StallAt is when the agent judged it.
StallAt time.Time
}
Outcome is how a run ended.
type PlanInput ¶
type PlanInput struct {
File *config.File
Getenv func(string) string
Hostname func() (string, error)
// SrunVersion is the output of `srun --version`. Only a coordinator asks.
SrunVersion func() (string, error)
// NVMLBuilt is whether this binary has the nvml build tag, and GPU the reader it opened here.
NVMLBuilt bool
GPU gpu.Reader
}
PlanInput is what a plan reads, so that nothing but SrunVersion reaches outside the process.
type Publisher ¶
type Publisher struct {
// Helper is the command, usually one path.
Helper []string
Checkpoint *config.Checkpoint
// Creds is checkpoint.creds, resolved.
Creds string
OutputDir string
// Budget is P, the bound on publishing the grace save.
Budget time.Duration
Env []string
Output io.Writer
// Zero means D4's values, which a test shortens.
Backoff []time.Duration
FinalPassLength time.Duration
FinalPassDrain time.Duration
StopWatchWait time.Duration
// contains filtered or unexported fields
}
Publisher drives dispatch's publish helper on node rank 0.
func NewSlurmPublisher ¶
func NewSlurmPublisher(c *config.Checkpoint, getenv func(string) string, environ []string, output io.Writer, attempt string, grace Grace) (*Publisher, error)
NewSlurmPublisher is the helper as the coordinator and node rank 0 both run it.
func (*Publisher) FinalPass ¶
FinalPass runs one bounded watch once torchrun has exited, whose first scan is immediate and whose drain follows the signal, so a save made while watch was down is published even if no restart caught it. A signal cuts it short, and it reports false: the run has already ended and must exit inside the scheduler's window. dispatch has no one-shot verb yet (D14 H), hence the fixed length.
func (*Publisher) PublishSave ¶
func (p *Publisher) PublishSave(done *CheckpointDone) error
PublishSave publishes the grace save, bounded by the budget since the kill window is spent by it.
func (*Publisher) Resolve ¶
Resolve runs the helper's resolve once, so every node resumes from the same save (D4). An empty location means a fresh start. Any failure stops the launch, as go/dispatch 0001 D16 requires.
func (*Publisher) StartWatch ¶
StartWatch runs watch beside training and restarts it whenever it exits.
type Pulse ¶
type Pulse struct {
// Out is the agent's stdout.
Out io.Writer
// AliveLine names the node and its Slurm step on LAUNCH-ALIVE, before the progress, on Slurm; empty
// on Kubeflow.
AliveLine string
// Beat turns on the LAUNCH-BEAT line, for the agent at node rank 0 on Kubeflow.
Beat bool
// Zero means D1's and D6's intervals, which a test shortens.
AliveEvery time.Duration
BeatEvery time.Duration
// WriteBound is how long an alive or beat line may take; zero means 5 s.
WriteBound time.Duration
// FinalPatience and FinalHurry bound the report and the shutdown together, without and with a
// signal: 30 s and 1 s when zero. A signal starts the scheduler's kill window, and one read during
// the wait shortens it.
FinalPatience time.Duration
FinalHurry time.Duration
// contains filtered or unexported fields
}
Pulse writes an agent's stdout. It runs on its own goroutine because the agent's main loop blocks while stopping torchrun and through the final publish pass, up to 190 s on S3, and the coordinator calls a node gone after 120 s of silence.
func (*Pulse) Report ¶
Report writes the node report, once, at phase ended: earlier phases mean nothing to a coordinator that decides by exits and reports.
func (*Pulse) SetProgress ¶
SetProgress records what the next alive line and beat say. The beat measures the launcher, whatever the payload is doing, so seq rises regardless.
type RankLogs ¶
type RankLogs struct {
// contains filtered or unexported fields
}
RankLogs reads what torchrun's ranks leave under --log-dir, as it appears, so that a failure is dated when the agent first saw it. The layout is <log-dir>/<run id>/attempt_0/<local rank>/.
func NewRankLogs ¶
NewRankLogs reads the logs under dir, which need not exist yet.
type Reaper ¶
type Reaper struct {
// contains filtered or unexported fields
}
Reaper reaps orphans for a launcher running as PID 1 (spec 0001 D1), where a rank's stray child would otherwise stay a zombie for the container's life. A wait-for-any would steal the status of the launcher's own children, so it reaps by pid, and every child it does not own starts through it. A nil Reaper starts and waits plainly.
func StartReaper ¶
StartReaper reaps until End. every is the scan's interval, and zero means every second.
type Rendezvous ¶
Rendezvous is how an agent's torchrun finds the others on Slurm. A nil Rendezvous means Kubeflow, whose PET_* variables torchrun reads itself.
type ResumeFetch ¶
type ResumeFetch struct {
// Endpoint is PET_MASTER_ADDR and the resume port.
Endpoint string
NodeRank int
Attempt string
// Timeout is rendezvous.joinTimeout. Rank 0 resolves before it serves, so that time counts too.
Timeout time.Duration
// Every is how soon to ask again; zero means every second.
Every time.Duration
}
ResumeFetch is another node's request for the resume point (D4).
type ResumeShare ¶
type ResumeShare struct {
// contains filtered or unexported fields
}
ResumeShare is node rank 0's listener for the resume point, bound before Serve so that a port in use stops the launch, naming the port (D4).
func ListenResumeShare ¶
func ListenResumeShare(ctx context.Context, port int) (*ResumeShare, error)
ListenResumeShare binds the resume port on every interface: PET_MASTER_ADDR is this pod's name, and which of its addresses that resolves to is the cluster's.
func (*ResumeShare) Close ¶
func (s *ResumeShare) Close() error
Close gives the port back, for a launch that stops before Serve.
func (*ResumeShare) Serve ¶
func (s *ResumeShare) Serve(ctx context.Context, attempt, location string, nodes int, wait time.Duration) ([]int, error)
Serve answers every other node of a job of two or more once it asks, and returns with its listener closed. The connections it answered stay in TIME_WAIT for a while, so a payload given this port needs SO_REUSEADDR to bind it. It ends once node ranks 1 to nodes-1 have each fetched, a retry counting once, or when wait passes. It returns the ranks that hadn't: they refuse to start for themselves, so that costs this node nothing but the rendezvous's own failure (D4). Only ctx ending is an error.
type ServePlan ¶
type ServePlan struct {
URL string `json:"url"`
Models []string `json:"models"`
Manifest string `json:"manifest"`
VLLM []string `json:"vllm"`
Env map[string]string `json:"env"`
Command []string `json:"command,omitempty"`
}
ServePlan is what launch serve -print shows.
type Site ¶
type Site struct {
Version string `json:"version"`
Tracker string `json:"tracker"`
// IgnoreSignals runs srun with --ignore-signals=SIGTERM,SIGHUP,SIGQUIT, from 26.05.
IgnoreSignals bool `json:"ignoreSignals"`
// Setsid runs srun in its own session, so proctrack/pgid does not signal it on 25.11.
Setsid bool `json:"setsid"`
// NoGrace is why srun would kill its tasks on the scheduler's SIGTERM, or empty.
NoGrace string `json:"noGrace,omitempty"`
// ConfFile and ConfModified are the cgroup.conf followed, recorded so a grace misled by an edit
// slurmd has not loaded can be traced.
ConfFile string `json:"confFile,omitempty"`
ConfModified time.Time `json:"confModified,omitzero"`
}
Site is what D1's table says about one Slurm site.
func DetectSite ¶
DetectSite applies D1's table. The tracker comes from DISPATCH_SLURM_PROCTRACK, because the adapter's preflight has it; SignalChildrenProcesses comes from this node's cgroup.conf, because scontrol show config never prints it. Anything not understood makes the site no-grace.
type Stall ¶
type Stall struct {
// LastBeatAt is when the agent saw the file last change, and zero if it never appeared.
LastBeatAt time.Time
LastPhase string
LastStep *int
Limit time.Duration
}
Stall is a hang the watch found.
type StepAction ¶
type StepAction struct {
// StopAgents sends srun SIGUSR1. It is set at most once.
StopAgents bool
// KillStep ends the step with scancel, naming StepWatch.StepID, or kills srun when no agent has
// named a step. It is set at most once.
KillStep bool
}
StepAction is what the coordinator must do to its srun now.
type StepBounds ¶
type StepBounds struct {
// StopWait follows a failure or a signal.
StopWait time.Duration
// SuccessWait follows a first successful report: torchrun's exit barrier, node rank 0's final
// watch pass, and 10 s.
SuccessWait time.Duration
}
StepBounds are how long a coordinator waits for its agents (spec 0001 D1).
type StepWatch ¶
type StepWatch struct {
// contains filtered or unexported fields
}
StepWatch is the coordinator's reading of srun's stdout and what it decides from it (spec 0001 D1). It owns no process and no clock: the caller feeds it lines and ticks from one goroutine.
func NewStepWatch ¶
func NewStepWatch(tasks int, bounds StepBounds, started time.Time) *StepWatch
NewStepWatch starts every task's silence clock at started, as srun starts.
func (*StepWatch) Line ¶
Line takes one line of srun's stdout. A task is who srun's label says, never what the line claims, and a line that is not exactly an agent's is evidence.
func (*StepWatch) Merge ¶
Merge is the execution's one document and the coordinator's exit code, once srun has exited and its stdout has been read to EOF: exits decide the outcome, not reports (D1).
func (*StepWatch) NodesAlive ¶
NodesAlive is how many nodes sent a LAUNCH-ALIVE in the last minute, for the beat (D6).
func (*StepWatch) Progress ¶
Progress is the highest step in any node's latest alive line and that node's phase, for the beat (D1, D6). Only some nodes may hold a heartbeat, so one node's word is not enough. A tie goes to the lowest node rank, so the phase doesn't flicker between nodes.
func (*StepWatch) Signalled ¶
Signalled is the coordinator's own SIGTERM. The agents normally have it too (D1), and one that does takes the SIGUSR1 as the same request, so sending it needs no way to tell them apart.
type TorchrunParams ¶
type TorchrunParams struct {
Torchrun string
Attempt string
Grace Grace
LogDir string
ProcsPerNode int
Rendezvous *Rendezvous
Train *config.Train
ResumeFlag string
ResumeFrom string
}
TorchrunParams is everything torchrun's command line depends on.
func (TorchrunParams) Argv ¶
func (p TorchrunParams) Argv() []string
Argv is the agent's command for torchrun, from D4 and D5. train.command runs verbatim: --no-python stops torchrun prefixing python -u.
type TrainPlan ¶
type TrainPlan struct {
Mode Mode `json:"mode"`
Attempt string `json:"attempt"`
Epoch string `json:"epoch"`
CauseFile string `json:"causeFile"`
Node string `json:"node"`
Site *Site `json:"site,omitempty"`
Grace Grace `json:"grace"`
Nodes int `json:"nodes,omitempty"`
Rendezvous string `json:"rendezvous,omitempty"`
// PortChosenAtStart says Rendezvous has no real port yet (D4).
PortChosenAtStart bool `json:"portChosenAtStart,omitempty"`
ResumeEndpoint string `json:"resumeEndpoint,omitempty"`
// ResumePoint is ResumeUnresolved with a checkpoint section, since resolving runs the helper.
ResumePoint string `json:"resumePoint"`
ProcsPerNode int `json:"procsPerNode"`
GPU string `json:"gpu"`
ControlDir string `json:"controlDir"`
LogDir string `json:"logDir"`
Torchrun []string `json:"torchrun"`
Env map[string]string `json:"env"`
// contains filtered or unexported fields
}
TrainPlan is `launch train -print`: what a run would do here, with nothing started (D2). On Slurm it shows node rank 0's torchrun.
type WatchLoop ¶
type WatchLoop struct {
// contains filtered or unexported fields
}
WatchLoop is watch beside training.
func (*WatchLoop) Cease ¶
func (w *WatchLoop) Cease()
Cease stops restarts and sends a running watch SIGTERM, which makes its last scan.
func (*WatchLoop) Degraded ¶
Degraded says how often watch exited early, and why it last did, or is empty.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
launch
command
Command launch is the entrypoint inside a distributed training job (go/launch spec 0001).
|
Command launch is the entrypoint inside a distributed training job (go/launch spec 0001). |
|
Package config reads launch.yaml (go/launch spec 0001 D3) and refuses whatever it does not understand, reporting every refusal with its path.
|
Package config reads launch.yaml (go/launch spec 0001 D3) and refuses whatever it does not understand, reporting every refusal with its path. |
|
Package gpu is the launcher's view of GPU health (go/launch spec 0001 D9).
|
Package gpu is the launcher's view of GPU health (go/launch spec 0001 D9). |
|
internal
|
|
|
fakevllm
Package fakevllm is a stand-in for vLLM that tests start as a real child process.
|
Package fakevllm is a stand-in for vLLM that tests start as a real child process. |
|
Package nccl recognises the failures PyTorch and NCCL print, from a table of literals read at one PyTorch release (go/launch spec 0001 D8).
|
Package nccl recognises the failures PyTorch and NCCL print, from a table of literals read at one PyTorch release (go/launch spec 0001 D8). |
|
Package serve runs vLLM as a child, says when it is ready, and writes the manifest go/assess reads (spec 0001 D10).
|
Package serve runs vLLM as a child, says when it is ready, and writes the manifest go/assess reads (spec 0001 D10). |