Documentation
¶
Overview ¶
Package admission provides resource-scoped, priority-aware admission for realtime model work.
Priority is explicit provenance supplied by the runtime (for example, interactive ASR versus speculative preparation versus background reasoning). The governor never inspects prompt or transcript content. Work is admitted at safe points, and preemption is cooperative through lease cancellation.
Index ¶
- Variables
- type Class
- type ClassTiming
- type Config
- type ContinuationProvider
- type Governor
- type Lease
- type PerceptionProvider
- func (provider *PerceptionProvider) Descriptor() v1.Descriptor
- func (provider *PerceptionProvider) Finalize(ctx context.Context, finalSample uint64) (v1.PerceptionRevision, error)
- func (provider *PerceptionProvider) PushFrame(ctx context.Context, frame v1.AudioFrame) ([]v1.PerceptionRevision, error)
- type Request
- type Snapshot
- type SpeechProvider
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPreempted is the cancellation cause used when higher-priority work // needs capacity held by a cooperative lower-priority lease. ErrPreempted = errors.New("resource lease preempted by higher-priority work") // ErrAdmissionDeadline indicates that work did not begin by its declared // admission deadline. ErrAdmissionDeadline = errors.New("resource admission deadline exceeded") )
Functions ¶
This section is empty.
Types ¶
type Class ¶
type Class uint8
Class is a runtime-declared scheduling class. The numeric ordering is part of the scheduler contract: larger values are admitted first.
type ClassTiming ¶
type ClassTiming struct {
Admitted uint64 `json:"admitted"`
Released uint64 `json:"released"`
Preemptions uint64 `json:"preemptions"`
WaitTotalMS float64 `json:"wait_total_ms"`
WaitMaxMS float64 `json:"wait_max_ms"`
ServiceTotalMS float64 `json:"service_total_ms"`
ServiceMaxMS float64 `json:"service_max_ms"`
PreemptionToReleaseTotalMS float64 `json:"preemption_to_release_total_ms"`
PreemptionToReleaseMaxMS float64 `json:"preemption_to_release_max_ms"`
}
ClassTiming is fixed-memory admission telemetry. Wait covers request enqueue through lease grant. Service covers grant through the holder's Release safe point, so it includes provider work and cancellation acknowledgement.
type Config ¶
Config defines one resource domain, such as a co-located GPU. Capacity and costs are abstract integer units. ReservedInteractive prevents background and speculative work from consuming all capacity, while interactive and urgent work may use the complete capacity.
type ContinuationProvider ¶
type ContinuationProvider struct {
Provider continuation.Provider
Governor *Governor
Request Request
}
ContinuationProvider admits every model continuation through one resource governor. Class and cost come from deployment configuration, never prompt classification.
func (*ContinuationProvider) Continue ¶
func (provider *ContinuationProvider) Continue(ctx context.Context, request continuation.Request, emit continuation.Emit) (continuation.Completion, error)
func (*ContinuationProvider) Descriptor ¶
func (provider *ContinuationProvider) Descriptor() continuation.Descriptor
type Governor ¶
type Governor struct {
// contains filtered or unexported fields
}
Governor owns admission state for one bounded resource domain.
func NewGovernor ¶
NewGovernor creates a deterministic safe-point scheduler.
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
Lease is cooperative ownership of admitted capacity.
func (*Lease) Context ¶
Context is cancelled when the caller, its deadline, or higher-priority preemption asks the work to stop.
type PerceptionProvider ¶
type PerceptionProvider struct {
Provider v1.PerceptionProvider
Governor *Governor
Request Request
}
PerceptionProvider protects every stateful ASR boundary. Interactive ASR should normally be non-preemptible so a cancelled chunk cannot corrupt a provider session.
func (*PerceptionProvider) Descriptor ¶
func (provider *PerceptionProvider) Descriptor() v1.Descriptor
func (*PerceptionProvider) Finalize ¶
func (provider *PerceptionProvider) Finalize(ctx context.Context, finalSample uint64) (v1.PerceptionRevision, error)
func (*PerceptionProvider) PushFrame ¶
func (provider *PerceptionProvider) PushFrame(ctx context.Context, frame v1.AudioFrame) ([]v1.PerceptionRevision, error)
type Request ¶
Request declares resource demand independently of semantic input. Deadline orders queued work and bounds admission. Callers should also put the same deadline on the parent context when it must bound execution.
type Snapshot ¶
type Snapshot struct {
Capacity int `json:"capacity"`
ReservedInteractive int `json:"reserved_interactive"`
Used int `json:"used"`
LowerPriorityUsed int `json:"lower_priority_used"`
Running map[string]int `json:"running"`
Waiting map[string]int `json:"waiting"`
Admitted uint64 `json:"admitted"`
Released uint64 `json:"released"`
Preemptions uint64 `json:"preemptions"`
CancelledWaiters uint64 `json:"cancelled_waiters"`
DeadlineMisses uint64 `json:"deadline_misses"`
Classes map[string]ClassTiming `json:"classes,omitempty"`
}
Snapshot is safe operational telemetry; it contains no model input.
type SpeechProvider ¶
type SpeechProvider struct {
Provider v1.StreamingSpeechProvider
Governor *Governor
Request Request
}
SpeechProvider admits one complete streaming synthesis lease. The lease is held until the terminal chunk or error so capacity reflects actual work.
func (*SpeechProvider) Descriptor ¶
func (provider *SpeechProvider) Descriptor() v1.Descriptor
func (*SpeechProvider) Stream ¶
func (provider *SpeechProvider) Stream(ctx context.Context, plan v1.SpeechPlan, emit func(v1.SpeechChunk) error) error
func (*SpeechProvider) Synthesize ¶
func (provider *SpeechProvider) Synthesize(ctx context.Context, plan v1.SpeechPlan) ([]v1.SpeechChunk, error)
Synthesize preserves the stable non-streaming convenience surface while holding exactly the same one-request lease as Stream.