Table of Contents

Method WarmUpEmbeddingsAtStartup

Namespace
Qavren.Edge.Embeddings.Onnx
Assembly
Qavren.Edge.Embeddings.Onnx.dll

WarmUpEmbeddingsAtStartup(EdgeBuilder, string?)

Startup order SessionWarmUp (220). Builds this registration's tokenizer, so the first user-visible call does not pay vocabulary parsing. Off by default, because it forces provisioning and spec 10 keeps that lazy. Idempotent: a second call for the same registration adds no second task.

public static EdgeBuilder WarmUpEmbeddingsAtStartup(this EdgeBuilder builder, string? name = null)

Parameters

builder EdgeBuilder

The Qavren.Edge builder.

name string

The keyed registration to warm, or null for the unkeyed one.

Returns

EdgeBuilder

The same builder.

Remarks

Two deviations from spec 7 and 14.1 live here, and both are deliberate.

1. It registers ONE task, not two. Spec 7 presents this and Qavren.Edge.Onnx's WarmUpSessionAtStartup as independent opt-ins, so this method no longer calls that one on the caller's behalf. It used to, and the coupling was wrong twice over: L0 registers its task with AddSingleton rather than a TryAdd, so an app that opted into both - or called this method twice - got duplicate order-220 session tasks. An app that wants the graph loaded at startup as well calls builder.WarmUpSessionAtStartup(preset.Manifest.ModelId) itself, which is the shape spec 7 describes.

2. It runs no dummy batch, which spec 7 and spec 14.1's order table both require ("builds the tokenizer, acquires the session and embeds one short string"). It cannot, and the blocker is a layer boundary rather than an omission: embedding one string means IOnnxSessionHost.AcquireAsync, which awaits IEdgeHost.EnsureStartedAsync, and a startup task awaiting startup deadlocks on its own completion. The load path that skips that await, OnnxSessionHost.AcquireCoreAsync, is internal to Qavren.Edge.Onnx, and that assembly grants InternalsVisibleTo to test assemblies only - so no member of this package can drive a session load at startup. Closing this needs an owner ruling: either spec 7 and 14.1 drop the dummy batch, or Qavren.Edge.Onnx exposes a load path L1 can reach. Until then a first embed pays the graph load, the CoreML compile and the first Run; only vocabulary parsing is pre-paid.

Exceptions

InvalidOperationException

No AddOnnxEmbeddings call on this builder carries name. The preset to warm comes from that registration, so the order of the two calls matters.