Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,39 @@ New with Foundry Local (ADRs 2026-10-15-foundry-local-*): `<data>/foundry-local/
builds, the variants the app installs, the library's own data (accelerators, shared by every build) with the core's
`runtime/accelerators.json`, each host's catalog cache (`tmp/<uuid>`, deleted when the host exits), the library's logs —
and `<data>/foundry-local/foundry-local-manifest.cache.json`.
Foundry Local 2.4 (change `upgrade-foundry-local-2-4`): new preparation records are
`foundry-local/runtime/<tag>/<platform>/accelerators.json`; the unversioned record remains exclusive
to 2.1.0 and stays readable after rollback. Preparation, model checks and loads capture a build's identity.
The schema 1 manifest optionally declares `distribution: "atomic-conf"`, restricted to
`https://github.com/AtomicBot-ai/atomic-chat-conf/releases/download/foundry-local-<tag>/<asset>`;
without it the Microsoft URL stays unchanged. C API 2 and 3 are supported. Linux ARM64 needs glibc
2.34 for runtime 2.4.0 (2.28 for 2.1.0); Linux x64 remains at 2.28. Installation validates the loaded
library's normalized runtime version and maximum supported table against the selected release before activation.
Windows x64 2.4.0 bundles Intel OpenVINO 1.8.1 and its dependencies under the build's
`lib/openvino/`. The child host explicitly registers it on the shared ORT environment when
OpenVINO is requested, instead of using the incompatible system WinML EP. Discovery still uses
WinML; the current process reports registered only after the bundled registration succeeds.
Missing Intel files fail OpenVINO preparation with a reinstall instruction; CPU and CUDA do not
load this bundle. Runtime 2.1.0 and other platforms retain their original provider registration.
macOS ARM64 2.4.0 prepares the original Microsoft WebGPU EP 0.2.1 ZIP using the core downloader,
then registers the verified library through ORT API 31 instead of the failing native bootstrap.
Its library cache is `foundry-local/runtime/v2.4.0/macos-arm64/webgpu-ep/0.2.1/`.
Both the archive and native library have pinned sizes and SHA-256 hashes; cache activation is atomic.
Only explicit accelerator preparation may download it. Every model host validates and registers
the cached library locally; an absent or modified library asks for preparation again. Other runtime
versions retain their provider path. The existing accelerator events and control API are unchanged.
Foundry Local 2.4.0 stages pinned NVIDIA CUDA and cuDNN redistributables on
explicit CUDA preparation for Windows and Linux x64 and ARM64. Each complete
runtime set and its notices are cached in
`foundry-local/runtime/v2.4.0/<platform>/cuda/<revision>/`. The revision is
computed from that target's pins. CUDA preparation and model hosts receive the
private cache through the child loader search path. The core checks Linux ARM64
CUDA variants against a minimum runtime of 2.4.0 and requires the CUDA provider
reported by the active build. The existing API is unchanged.
`POST /atomic/v1/models/foundry-local/check` accepts optional `min_runtime_version: "X.Y.Z"`.
An installed runtime below the minimum returns `engine-update-required` with both versions in
`reason`; an absent engine remains `engine-not-installed`. Comparison is numeric and local; omitted
minimum and `0.0.0` retain the old verdicts. Invalid direct minima return `INVALID_ARGUMENT` (400).
New with LiteRT-LM (ADRs 2026-10-21-litert-lm-*): `<data>/litert-lm/{backends,accelerators,models,cache,runtime,tmp,logs}` —
builds, prepared OpenVINO (`accelerators/openvino/<version>/`), the variants the clients install
(`models/<variant_id>/<file>` + `model.yml`), the library's `cache_dir` (CPU XNNPACK caches, about 1 GB per model, named
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
date: 2026-11-10
title: "Prepare Foundry macOS WebGPU through ORT"
---

# 2026-11-10 — Prepare Foundry macOS WebGPU through ORT

- **Context:** Foundry 2.4.0 installs on macOS ARM64, but its native `Manager_DownloadAndRegisterEps` fails with `unknown error` after extracting WebGPU 0.2.1. A typed C++ client reproduces the failure without Bun FFI. The unchanged provider registers through standard ORT API 31 and generates through Foundry 2.4.0/GenAI 0.19.0. This resolves the Mac acceptance limitation recorded in the Foundry upgrade ADR.
- **Decision:** Only for macOS ARM64/runtime 2.4.0, explicitly prepare and register the same Microsoft CDN provider. Reuse the core downloader and regular-file archive extractor, pin both ZIP and dylib sizes/SHA-256, and atomically cache the original library under `foundry-local/runtime/v2.4.0/macos-arm64/webgpu-ep/0.2.1/`. Register it on ORT's shared environment and hold that reference until after the manager and its sessions are released. Report registered only after the real call succeeds. Await asynchronous preparation before emitting readiness or loading a model. Permit downloads only in `foundry-host prepare`; `serve` validates and reuses the cache, with an instruction to prepare again if it is missing or modified.
- **Alternatives:** Retrying native preparation repeats the same failure. Ignoring it and marking the accelerator prepared does not register a usable provider. Mutating Microsoft's private `active` pointer couples our preparation to its bundle lifecycle; 2.1.0 can remove unreferenced generations from that shared directory. The separate build cache avoids that coupling. Changing ORT/GenAI, signatures or published runtime archives is unnecessary.
- **Consequences:** First preparation downloads 3,447,797 bytes; the installed library is 10,432,384 bytes. A changed CDN artifact fails integrity checks instead of silently replacing native code. Each model host verifies the cached dylib and registers it again without fetching. CPU, 2.1.0, other platforms and future runtime versions retain their existing paths. The internal manager method may now return a promise; its synchronous implementations remain supported. Disk failures retain `[disk_*]` tags. Signed desktop application qualification remains a separate consumer check.
- **Evidence:** Ordinary compiled core: prepare → load Qwen3.5 0.8B WebGPU → streamed public `/v1/chat/completions` answer → unload, with all 13 original model-file hashes unchanged. Targeted compiled app-core also prepares and generates from a fresh host; a separate case refuses an unprepared model without creating/downloading an EP cache. Unit tests cover deferred registration, failures, scope, cache reuse, both hash boundaries, tampering, repair and disk errors.
- **Owner:** team.
- **Links:** [Foundry upgrade ADR](2026-11-10-upgrade-foundry-local-with-build-scoped-preparation.md); [disk contract](../contracts.md); `atomic-chat-spec/openspec/changes/upgrade-foundry-local-2-4/rulings/core.md`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
date: 2026-11-10
title: "Upgrade Foundry Local with build-scoped preparation"
---

# 2026-11-10 — Upgrade Foundry Local with build-scoped preparation

- **Context:** Foundry Local 2.4.0 ships as five archives repackaged by conf from Microsoft NuGet packages, with an additional pinned Intel OpenVINO 1.8.1 package for Windows x64. It requires C API 3 and, on Linux ARM64, glibc 2.34. Existing 2.1.0 installations, locally installed models and accelerator preparation must remain usable until an explicit update and after manual rollback.
- **Decision:** Accept the optional schema 1 `distribution: atomic-conf` only in the fixed conf release namespace; absence retains the Microsoft URL. Apply one host/core/API compatibility predicate to manifest candidates and offline active builds, retaining `minCoreVersion` in new install records. Negotiate API 3 before API 2 and require staging's actual library version and supported table to match the selected release before activation. Keep the legacy accelerator record exclusively for 2.1.0; new releases use `runtime/<tag>/<platform>/accelerators.json`. Capture the build for every preparation, model check and load. Add the optional model runtime minimum to the existing check route, comparing runtime versions numerically without a network request.
- **Consequences:** Linux ARM64 with glibc 2.28–2.33 stays on 2.1.0 even if 2.4.0 files are present. A failed staging probe leaves the previous session running. Successful activation may interrupt its response, as before; rollback remains unload plus removal of the new build. Old cores can still read the untouched 2.1.0 preparation record. Foundry's legacy parsed cache omits `schema_version`; only the cache reader restores that discriminator, while network parsing stays strict. Windows DLL search changes run only in the child host, retaining the build's dependencies and inherited PATH while adding CUDA/cuDNN bins through `AddDllDirectory` and `SetDefaultDllDirectories`. Preload Foundry with `LoadLibraryExW(DLL_LOAD_DIR | DEFAULT_DIRS)` before binding its symbols: otherwise a system ORT (1.17.1 on the acceptance host) can replace the bundled ORT and fail initialization with error 1114. A failed CUDA preparation does not block CPU or other accelerators. Real native probes are separate evidence from generation and hardware acceptance; consumer releases remain gated on their own qualification.
- **Windows NPU qualification:** The owner approved adding Intel.ML.OnnxRuntime.EP.OpenVINO 1.8.1 after the system WinML OpenVINO 1.8.95 EP failed on ORT 1.31.0 and 1.31.1 (`OrtEpApi_ReleaseEpContextConfig_SinceV28` unavailable). The same NPU model still generates with 2.1.0/ORT 1.30.0. Downgrading ORT alone is incompatible with GenAI 0.19.0, which needs ORT API 31. Preserve the three Microsoft packages and all signed native bytes; place Intel's Windows natives in `lib/openvino/` with its original license metadata and notices. Use a distinct `foundry-local-win-x64-openvino-1-8-1.zip` asset and retain the original published ZIP. Register the pinned plugin through standard ORT API 31 on its shared process environment. Acquire an environment reference lazily when OpenVINO is requested and release it after the Foundry manager. Do not accept WinML's registration as the bundled EP's readiness or fall back to the incompatible system plugin. Other EPs and 2.1.0 keep their paths. Missing Intel files do not block CPU probes or CUDA preparation. The new archive is 93,972,839 bytes, SHA-256 `23ce1fea75d64254e99042c3e99e1fc2bb0dd5befff07d4a013857920c67b2a1`; the NuGet catalog SHA-512 is pinned in conf. Production core and app-core both generated with the unchanged NPU-only model on Windows. A local download fixture exercised the production installer/hash/staging pipeline before remote publication was explicitly approved. The owner then authorized publication: the corrected archive is now public and its downloaded bytes match the recorded SHA-256. Conf's local candidate selects this asset for Windows x64 only. An audit preserved all five original asset IDs, digests, sizes and modification timestamps; the production manifest remains unchanged pending consumer releases.
- **Additional Mac acceptance:** Public 2.4.0 installation passes on macOS 26.6.2 ARM64, but ordinary core WebGPU preparation fails with `Manager_DownloadAndRegisterEps: unknown error`. The unchanged vendor C API reproduces the same failure in a typed C++ client with shared hosting disabled, without Bun FFI or a progress callback. The CDN download succeeds, and direct registration of its unchanged WebGPU 0.2.1 library in ORT 1.31 succeeds. A diagnostic host using that registration generates a real Qwen3.5 0.8B answer through Foundry 2.4.0/GenAI 0.19.0 (4096 context, 15 completion tokens, stop, exit 0). Early environment creation alone does not fix native preparation. The precise internal exception remains unknown; the ordinary Mac flow is not qualified. No production registration workaround or signing/security change was made. All 13 original model files and the isolated model copy remain unchanged after generation, apart from the explicitly reduced context in the copy before testing.
- **Owner:** team.
- **Links:** `atomic-chat-spec/openspec/changes/upgrade-foundry-local-2-4/{design,tasks}.md`; [control and disk contracts](../contracts.md); [Windows DLL search flags](https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-setdefaultdlldirectories); [per-library dependency precedence](https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexw); [Microsoft regression report](https://github.com/microsoft/foundry-local/issues/1261); [standard EP registration](https://learn.microsoft.com/en-us/windows/ai/new-windows-ml/bring-your-own-eps).
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
date: 2026-11-11
title: "Isolate managed Foundry CUDA DLLs on Windows"
---

# 2026-11-11 — Isolate managed Foundry CUDA DLLs on Windows

Windows does not specify the order among directories registered with
`AddDllDirectory`. Adding the managed cache and installed Toolkit directories
allowed DLLs with the same basename to compete inside the Foundry host.

Core passes the managed cache path explicitly to the Windows preparation and
CUDA model hosts. With that path set, both Windows architectures limit the DLL
search to the Foundry build, the managed CUDA directory and System32. This
keeps the system NVIDIA driver accessible. The legacy discovery path still
serves hosts without a managed CUDA cache. All loader settings are local to the
child process.

- [Microsoft DLL search order](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
date: 2026-11-11
title: "Prepare Foundry CUDA on Linux and ARM64"
---

# 2026-11-11 — Prepare Foundry CUDA on Linux and ARM64

Foundry Local 2.4.0 exposes Microsoft CUDA providers for Windows and Linux on
x64 and ARM64. The x64 providers require CUDA 12. The ARM64 providers require
CUDA 13. Both use cuDNN 9. Native model hosts need the matching libraries before
registering the provider.

The existing CUDA prepare and cache lifecycle now selects a pinned archive set
by the active Foundry build and its platform. Windows ARM64 uses NVIDIA CUDA
13.4 Update 2 and the matching cuDNN 9.25 ZIPs. Linux x64 uses the NVIDIA CUDA
12 and cuDNN 9.20 wheels previously qualified on Ubuntu. Linux ARM64 uses the
CUDA 13.4 and cuDNN 9.25 ARM64 wheels. Wheels are ZIP archives with the runtime
SONAME files already materialized, so core can use its existing streaming ZIP
reader and leave each ELF library under its required loader name. Each archive
has a pinned URL, size, SHA-256, an exact member allowlist and a license notice.

Only the explicit Prepare CUDA flow downloads the archives. The Windows child
uses its private cache through `PATH`, with x64 also using `AddDllDirectory`.
The Linux child gets its cache at the front of `LD_LIBRARY_PATH` before spawn.
The NVIDIA driver remains a system dependency. Windows x64 keeps the existing
cache revision, and macOS continues to use WebGPU.

Linux ARM64 CUDA model checks and loads require Foundry 2.4.0 or newer and use
its actual provider discovery and preparation record. Managed preparation is
pinned to the 2.4.0 release on all four targets.

- [Foundry Local 2.4.0 release notes](https://github.com/microsoft/Foundry-Local/releases/tag/v2.4.0)
- [NVIDIA CUDA 13.4 Update 2 redistribution manifest](https://developer.download.nvidia.com/compute/cuda/redist/redistrib_13.4.2.json)
- [NVIDIA cuDNN 9.25 redistribution manifest](https://developer.download.nvidia.com/compute/cudnn/redist/redistrib_9.25.1.json)
- [NVIDIA cuDNN 9.25 package metadata](https://pypi.org/project/nvidia-cudnn-cu13/9.25.1.1/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
date: 2026-11-11
title: "Prepare Foundry Windows x64 CUDA from NVIDIA"
---

# 2026-11-11 — Prepare Foundry Windows x64 CUDA from NVIDIA

The Foundry Local 2.4.0 Microsoft CUDA provider expects the CUDA 12 and cuDNN 9
runtime libraries to be available on Windows x64. Windows can discover the
provider with just an NVIDIA driver and then fail registration with error 126.

On explicit CUDA preparation for that build and platform, core downloads the
NVIDIA redistribution archives for CUDA Runtime 12.8.90, cuBLAS 12.8.4.1 and
cuDNN 9.20.0.48 for CUDA 12. Core pins the archive URLs, sizes and SHA-256 hashes
from NVIDIA's release manifests. It verifies the archives before streaming the
allowlisted runtime DLLs and NVIDIA notices into a private staging directory,
then publishes the complete set by rename. The download is about 1.2 GB and the
resulting cache is about 1.7 GB. The CUDA provider continues to come from
Microsoft, and the NVIDIA GPU driver comes from the machine.

The prepare host and later CUDA model hosts receive the cache directory through
child `PATH`. The Windows host passes it to `AddDllDirectory`. Model hosts
reuse the installed files locally. Core checks that the CUDA provider is offered
before starting an NVIDIA download. When multiple providers are requested, core
prepares the other providers before it downloads the CUDA runtime and reports
CUDA failures through the existing preparation result.

The same staging lifecycle can support additional platform and architecture
pins once their exact native dependencies and an actual CUDA inference have
been verified. Linux needs its `LD_LIBRARY_PATH` configured before host launch.
Microsoft specifies CUDA 13 with cuDNN 9 on ARM64.

- [Foundry Local 2.4.0 release notes](https://github.com/microsoft/Foundry-Local/releases/tag/v2.4.0)
- [CUDA 12.8 Update 1 redistribution manifest](https://developer.download.nvidia.com/compute/cuda/redist/redistrib_12.8.1.json)
- [cuDNN 9.20 redistribution manifest](https://developer.download.nvidia.com/compute/cudnn/redist/redistrib_9.20.0.json)
10 changes: 10 additions & 0 deletions docs/decisions/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ add a new one that says which record it supersedes.

## Records

- [2026-11-11 — Isolate managed Foundry CUDA DLLs on Windows](2026-11-11-isolate-managed-foundry-cuda-dlls-on-windows.md)

- [2026-11-11 — Prepare Foundry CUDA on Linux and ARM64](2026-11-11-prepare-foundry-cuda-on-linux-and-arm64.md)

- [2026-11-11 — Prepare Foundry Windows x64 CUDA from NVIDIA](2026-11-11-prepare-foundry-windows-x64-cuda-from-nvidia.md)

- [2026-11-10 — Prepare Foundry macOS WebGPU through ORT](2026-11-10-prepare-foundry-macos-webgpu-through-ort.md)

- [2026-11-10 — Upgrade Foundry Local with build-scoped preparation](2026-11-10-upgrade-foundry-local-with-build-scoped-preparation.md)

- [2026-11-10 — Offer the upstream Linux x64 CUDA and Windows arm64 Vulkan builds](2026-11-10-offer-upstream-linux-x64-cuda-and-windows-arm64-vulkan.md)

- [2026-11-07 — Expose typed FastFlowLM launch settings through the core](2026-11-07-expose-flm-launch-settings.md)
Expand Down
Loading
Loading