# gizai:host

the one host of a model served as giz's inference worker (gizlang:worker). A worker is its models, a load that makes its engine warm on a GPU, and an executor of jobs (W.Executor) on that engine. The host owns the rest: the GPU, the kernels' tunings in STATE/tune (loaded before the load, saved after it and after each job), the pool given back after each job with the job's peak in the journal (the card is shared), the id giz names the model by, and the ffmpeg program that reads and writes the jobs' media.

```gizlang
import * as Host from "gizai:host";
```

## Types

### `Place`

```gizlang
type Place = { state: string; host: string; port: i64; id: string; ffmpeg: string; }
```

Where a worker serves: its jobs' folder, its address, the id giz names its first model by ("" or the model's own:
the model's), and the program that reads and writes media.

- `state`: `string`
- `host`: `string`
- `port`: `i64`
- `id`: `string`
- `ffmpeg`: `string`

### `Host`

```gizlang
type Host = { sys: System; gpu: Gpu; place: Place; }
```

What a worker's engine is given: the program it runs in, its GPU, and its place.

- `sys`: `gizlang_system.System`
- `gpu`: `M10.Gpu`
- `place`: `M28.Place`

## Functions

### `serve`

```gizlang
function serve<M>(sys: System, name: string, place: Place, models: Vec<W.Model>, capacity: i64, streams: Vec<string>, load: (h: Host) => Result<M, string>, jobs: (h: Host) => W.Executor<M>): i64 throws string
```

Serves `models` (the first under place.id too) at `place`: `load` makes the engine on the host's GPU, warm, and the
executor that `jobs` gives runs the jobs on it, `capacity` held at once (streams: Config.streams). It returns when
the worker stops.

