slot

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package slot enforces modeld's single active local model invariant.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Service)

Option configures a slot Service.

func WithBackend

func WithBackend(backend string) Option

WithBackend records the backend mode for Status.

func WithClock added in v0.32.6

func WithClock(now func() time.Time) Option

WithClock overrides the time source (tests).

func WithDataRoot added in v0.33.0

func WithDataRoot(root string) Option

func WithIdleTTL added in v0.32.6

func WithIdleTTL(ttl time.Duration) Option

WithIdleTTL sets how long a resident model may sit idle before the background reaper releases it (freeing device memory so the GPU can return to idle). Zero (the default) disables idle reaping. Reaping requires StartReaper.

func WithModelsDir added in v0.34.0

func WithModelsDir(dir string) Option

WithModelsDir overrides the models directory a request with an empty Path resolves against. Unset falls back to <dataRoot>/<modelstore.DefaultSubdir>.

func WithOwner

func WithOwner(owner string) Option

WithOwner records the owner instance expected on direct calls. The gRPC layer also fences requests; this keeps direct tests and future in-process callers honest.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service wraps a backend transport.Service and exposes it as one active model slot. The wrapped backend still owns native inference; this layer owns residency cardinality, generation fencing, and switch/unload safety.

func New

func New(backend transport.Service, opts ...Option) *Service

New returns a transport service that allows only one active resident model.

func (*Service) Describe

Describe stays side-effect-free: it never evicts the resident session.

  • Same identity resident: the truthful answer is what that session actually resolved at open — a live recompute would be encumbered by the session's own footprint and report a uselessly small hypothetical (the "panel shows 439 while the session serves 2891" bug).
  • Different identity resident: pass the resident session's footprint as ReclaimableBytes so the backend's free-memory snapshot reflects what an actual OpenSession would see after the switch closed the old session.

func (*Service) DiskStats added in v0.34.0

func (s *Service) DiskStats(ctx context.Context) (transport.NodeDiskStats, error)

DiskStats implements transport.NodeAdmin.

func (*Service) Embed

func (*Service) ListModels added in v0.34.0

func (s *Service) ListModels(ctx context.Context) ([]transport.NodeModel, error)

ListModels implements transport.NodeAdmin by delegating to the node's model store admin.

func (*Service) LoadModel

func (*Service) OpenSession

func (*Service) ReceiveModel added in v0.34.0

func (s *Service) ReceiveModel(ctx context.Context, manifest transport.PushManifest, r io.Reader) (transport.PushResult, error)

ReceiveModel implements transport.NodeAdmin.

func (*Service) RemoveModel added in v0.34.0

func (s *Service) RemoveModel(ctx context.Context, name string) error

RemoveModel implements transport.NodeAdmin. It rejects the deletion if the target model is currently resident in the slot, avoiding underneath-the-GPU file removal.

func (*Service) StartReaper added in v0.32.6

func (s *Service) StartReaper(ctx context.Context)

StartReaper runs the idle-reaper loop until ctx is canceled. While modeld holds the lease it periodically releases a resident model that has sat idle past the configured TTL, so device memory is freed and the GPU can return to idle (the 24/7-on-a-laptop case). It is a no-op when the TTL is zero. The tick is CPU-only and never touches the GPU.

func (*Service) Status

func (s *Service) Status(ctx context.Context) (transport.DaemonStatus, error)

func (*Service) UnloadModel

func (s *Service) UnloadModel(ctx context.Context, req transport.UnloadModelRequest) error

Jump to

Keyboard shortcuts

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