Skip to content

fix(embedding): explain no-AVX CPUs on Windows instead of raw LiteRT error - #13

Open
RGB-loop wants to merge 1 commit into
mainfrom
fix-win-cpu-unsupported-message
Open

RGB-loop wants to merge 1 commit into
mainfrom
fix-win-cpu-unsupported-message

Conversation

@RGB-loop

Copy link
Copy Markdown
Owner

Fixes the failure reported in V2EX t/1248449 reply #7: LiteRT: failed to create cpu engine on Windows — model present, won't load, semantic search silently dead.

Cause. The prebuilt LiteRT-LM library hard-requires AVX on x64 (the same floor we mapped for Synology: J4125/J4025/J3455/N5105 etc.). Linux pre-checks /proc/cpuinfo and disables the semantic channel with an explanation; Windows had no check, so old CPUs got the raw engine error and no guidance.

Fix. After both backends fail to create an engine on win32-x64, ask IsProcessorFeaturePresent(PF_AVX_INSTRUCTIONS_AVAILABLE) via koffi — trusted only on build ≥ 19041 (Win10 2004, where the feature id was added). If AVX is missing, latch the existing cpuUnsupported state: status bar / settings / image-search notice explain it, the indexer skips the semantic channel, OCR / face / filename / tag search keep working, and the provider is dropped so nothing keeps retrying.

Deliberately diagnosis-after-failure, never a preemptive block: Hyper-V can mask AVX from this API on CPUs that do have it (e.g. reports of Ryzen 3950X reading false), and pre-2004 builds return false for unknown ids — a false 'no AVX' here can only relabel an already-failing machine, never disable a working one.

Tests. cpu.test.ts extended for the error classifier; typecheck + core suite pass (sprite.test.ts fails only without ffmpeg-static's postinstall binary, unrelated).

…error

A V2EX user (t/1248449 #7) hit 'LiteRT: failed to create cpu engine' on
Windows — the model is present but the prebuilt LiteRT-LM library needs
AVX, same hard floor we mapped for Synology NAS boxes. Linux already
pre-checks /proc/cpuinfo; Windows has no equivalent, so after both
backends fail to create an engine we now ask IsProcessorFeaturePresent
(PF_AVX_INSTRUCTIONS_AVAILABLE, trusted only on Win10 2004+ builds) and,
if AVX is missing, flip the existing cpuUnsupported state: status bar /
settings explain the situation, the indexer stops retrying, and OCR /
face / filename / tag search keep working.

Diagnosis runs only after failure, never preemptively — Hyper-V can mask
AVX from the API on CPUs that have it, and older builds return false for
unknown feature ids.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant