Advanced

How Primordial manages AI models.

Learn when models are downloaded, loaded, shared, protected during active work, and removed from memory.

Activation is required

Installing or running models requires accepted evaluation activation. See Evaluation Keys to activate Primordial for development and device testing.

Downloading and loading are separate

Downloaded means verified model files are installed for offline use. Loaded means the model is in memory and ready to run. Installation never loads a model, and loading never downloads one.

Downloads can continue in the background

On iOS, configure background downloads once as shown in AI Model Setup. Transfers can continue through ordinary suspension and system termination. A user force-quit cancels them.

If the system terminates the app, call the same makeAvailable capability after relaunch. Primordial reuses completed files and finalizes any remaining model metadata.

Models are shared across clients

Copies of PrimordialClient share one runtime. When they use the same model, Primordial shares its model weights and coordinates access instead of loading duplicate copies.

Active work protects models

Primordial prevents a model from being unloaded, replaced, or removed while an operation is using it. Loading a model through the advanced API keeps it in memory until you unload it or Primordial responds to system pressure.

Some models cannot run together

Workflows that use your data prepare embeddings before starting generation. Generation and speech models do not remain in memory together. If active work prevents Primordial from switching models, the operation returns resourceConflict.

Primordial frees memory automatically

When your app enters the background, the Mac sleeps, or the system reports memory pressure, Primordial unloads models that are not being used. Active work completes or cancels normally and is never removed from memory unexpectedly.

Check whether a model is in memory

let residency = await primordial.advanced.generation.residency()
print(residency.state)

Residency is separate from installation: a downloaded model can be unloaded. To update your interface whenever the model's memory state changes, observe residencyUpdates():

for await residency in primordial.advanced.generation.residencyUpdates() {
    updateModelStatus(residency.state)
}

The stream immediately provides the model's current state, then reports future changes such as loading and unloading. Stop the observing task when the interface no longer needs updates. Stopping observation does not affect the model.

Show storage used by AI models

Use allocated bytes for the number shown in storage UI. The total counts shared model identities once.

let storage = try await primordial.ai.storageUsage()
print(ByteCountFormatter.string(fromByteCount: storage.total.allocatedBytes, countStyle: .file))

For a per-model breakdown, inspect resources or filter by model kind:

for resource in storage.resources(for: .generation) {
    print(resource.model.identifier, resource.usage.allocatedBytes)
}

Every resource configured for this client is listed, including an inactive generation fallback. isActive means selected by configuration, not currently loaded in memory. System-owned models report zero Primordial-managed bytes.