Repository navigation
Description
Found while fixing #973 (#975). Not a regression: it fails the same way on LiteRT-LM v0.17.0-8 and v0.18.0. Tracker: #966.
What happens. On a platform without the temp cache default (every native platform except macOS and Android), loading a .litertlm-named bundle from a directory the process cannot write, with ModelParams.liteRtLmCacheDir unset and ComputeDevice.gpu, fails on first use:
LlamaUnsupportedException: ComputeDevice.gpu was requested, but LiteRT-LM could not create a gpu engine on <os>. … LiteRT-LM engine creation failed for backend "gpu" and model "Qwen3-0.6B.litertlm". The GPU delegate may not support this device, OS, model, or bundle; try backend "cpu". Load with ComputeDevice.cpu to tell them apart.
The message does not mention the cache, because no cache directory was passed. The same load on ComputeDevice.cpu works, uncached.
Cause. With no cache directory the runtime caches next to the model file. The GPU backend fails engine creation when it cannot write its weight and program caches there; the CPU backend tolerates it. Passing the runtime's ":nocache" cache directory makes the GPU load work, uncached.
Evidence (Qwen3 0.6B, macOS arm64 Metal, LiteRtLmService(useTempCacheDir: false), directory mode 555):
| Runtime | Case | Result |
|---|---|---|
v0.18.0 (ce8843fc8) |
Qwen3-0.6B.litertlm, no cache dir, GPU |
FAIL |
v0.17.0-8 (f3e15d95c) |
same | FAIL |
v0.18.0 |
same, cache dir forced to :nocache |
OK |
v0.18.0 |
same bundle in a writable directory, GPU | OK, caches written next to the bundle |
v0.18.0 |
Qwen3-0.6B.litertlm, mode 555, no cache dir, CPU |
OK, nothing written |
Not verified. Measured only on macOS with the temp cache default switched off, a configuration no platform ships. iOS (Metal, model in the read-only app bundle), Linux GPU and Windows GPU share the Dart default but were not run. The iOS case is the likely real-world one and needs a device run before this is treated as confirmed there.
Workarounds. Set liteRtLmCacheDir to a writable directory, or use ComputeDevice.cpu.
Options.
- Apply the probe from fix: run a LiteRT-LM bundle named without .litertlm uncached in a read-only directory #975 to named bundles as well: when no cache directory is configured and the process cannot write the model's directory, pass
":nocache". The GPU load then works uncached. This changes released behaviour (a load that threw now succeeds without caches) and adds anaccess(2)call per engine create on default loads. - Keep the failure and add a cache hint to the message when the model's directory is not writable.
- Document it only.
Decision needed: whether to change released behaviour (option 1).
Activity
test: add a device E2E for a LiteRT-LM bundle in a read-only directory
leehack commentedon Oct 14, 2026
Confirmed on a physical iPhone 16 Pro (
LlamaUnsupportedException, Test Lab matrix-3u3efzv5h4qbi, test from #1023). Proposed fix for 0.13.0: pass:nocachewhen the model directory is unwritable and no cache directory is set; it only turns a loud failure into success, so it is not a 0.12.1 item.fix: run a read-only .litertlm LiteRT-LM bundle uncached when no cach…