> For the complete documentation index, see [llms.txt](https://docs.eyepop.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eyepop.ai/deploying/on-premise/optimize.md). Agents can also search and read this documentation through its [MCP server](https://docs.eyepop.ai/~gitbook/mcp).

# Optimize Models

Compile and quantize models for the machine's accelerator

The runtime can compile each model for this machine's accelerator, and quantize it to 8-bit integers while it does. What that gains depends on the platform:

| Platform                | Effect                                                                                                               |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `cuda`, `cuda-jetpack6` | Usually higher throughput. Compiling takes minutes per model on a desktop GPU, and around 8 minutes on a Jetson Orin |
| `openvino`              | Mainly a faster start, since the compiled model loads quicker; throughput stays about the same                       |
| `qnn`                   | Compiles in seconds per model                                                                                        |
| `cpu`                   | Nothing to compile for                                                                                               |

**Quantization** (`int8`) usually raises throughput further and uses less memory, but it can change results slightly. Compare the results on your own media before you use it in production.

Compiled models are kept on the machine and reused by every later start. The work is paid again only for new models (a new pop or ability), a change of quantization, or a different kind of device.

There are two ways to optimize.

**`--optimize-at-startup true`** makes the instance compile its models before it reports healthy. The first start after you turn it on, change the pop, or change the quantization waits until every model is compiled; later starts reuse the compiled models. Until then the instance is not serving, so give that first start a long enough [`--wait`](https://docs.eyepop.ai/deploying/on-premise/settings.md#wait).

**`eyepop instance optimize`** compiles the models of the pop the instance serves now, while it keeps running. The instance must be running and healthy. It keeps serving the models it loaded until it restarts, so restart it afterwards; the restart is quick, because the compiled models are ready:

```bash
eyepop instance optimize
eyepop instance restart
```

Ctrl-C stops `instance optimize`. Models it finished stay compiled; the one in progress is not.

## Recommended flow

1. **While you experiment**, leave `optimize-at-startup` off. You change the pop often at this stage, and every change restarts in seconds instead of waiting for a compile.
2. **Once you settle on a pop**, measure what optimizing gives on this hardware: note the throughput, run `eyepop instance optimize` and `eyepop instance restart`, and measure again.
3. **For production**, if it is worth it, turn it on with `eyepop instance set --optimize-at-startup true`. Then a pop change, a new machine, or a cleared model cache compiles before serving, instead of serving uncompiled models. Expect the first start after each of those to take as long as compiling does.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eyepop.ai/deploying/on-premise/optimize.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
