Skip to content

[Engine] perf(weights): check source file identity once, when the file is opened - #340

Merged
linyubupa merged 2 commits into
mainfrom
fix/weights-identity-once
Nov 23, 2026
Merged

linyubupa merged 2 commits into
mainfrom
fix/weights-identity-once

Conversation

@hattori7243

@hattori7243 hattori7243 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What & why

Two changes in edge0-infer/, one commit each.

perf(weights): check source file identity once, when the file is opened.
After every expert write, Weights::complete reopened each source file by path and compared
both the open handle's and the reopened file's identity (fstat) with the one recorded at
begin_write, which itself called fstat on every write. On the 35B slot path this runs on every
synchronous expert load, about 39 times per decode token. Identity is now taken once when a
source file is opened and cached with its handle; writes reuse it. A source file modified while
the engine is running is no longer detected, so the storage test case for that is removed, and
the read-batch test now checks that a repeated write opens and stats nothing.

fix(cli): link the Android CLI at API 28.
serve_delegate_process.cpp calls posix_spawn_file_actions_addchdir_np, which Android
provides only from API 34. The android-cpu preset targets API 28 and has failed to link since
5c7f5c2. Android, like iOS, does not run the external engine's preparation scripts, so it now
takes the same ENOTSUP path.

Area

  • Engine, CLI or server (edge0-infer/)
  • Model asset tools (edge0-infer/tools/assets/)
  • Chat app examples (edge0-infer/examples/)
  • Model docs (docs/)
  • edge0-strata/
  • Other

How was it tested?

macOS (M5, 16 GB, Metal):

  • cmake --build build/mac-metal and ctest --test-dir build/mac-metal -L "L0|L1": 106/106 passed.

  • edge0-infer bench --model <Edge0 35B> --user-file tests/fixtures/bench/library-report-prompt-head.txt --warmup 10 --ntok 100 --runs 1 --breakdown
    (627-token input), main and this branch alternated, 3 runs each:

    decode tok/s expert wait (median)
    main 17.69 / 17.88 / 18.83 14.2–16.0 ms
    this branch 20.01 / 19.95 / 20.26 11.5–12.3 ms

Android (HONOR BRM-AN00, Snapdragon SM8975, CPU):

  • cmake --preset android-cpu && cmake --build build/android-cpu (API 28): builds and links.
  • On the device: moe_test_weights_storage and moe_test_weights_read_batch pass.
  • edge0-infer forward --device cpu --threads 4 on a 627 + 120 token sequence with cached expert
    reads: logits.f32 is byte-identical between main (with the API 28 fix) and this branch.

After every expert write, Weights::complete reopened each source file by
path and compared both the open handle's and the reopened file's identity
with the one recorded at begin_write, which itself called fstat on every
write. On the 35B slot path this runs on every synchronous expert load,
about 39 times per decode token.

Identity is now taken once when a source file is opened and cached with
its handle; writes reuse it. A source file modified while the engine is
running is no longer detected, so the storage test case for that is
removed, and the read-batch test now checks that a repeated write opens
and stats nothing.
serve_delegate_process.cpp calls posix_spawn_file_actions_addchdir_np,
which Android provides only from API 34. The android-cpu preset targets
API 28 and has failed to link since 5c7f5c2. Android, like iOS, does not
run the external engine's preparation scripts, so it now takes the same
ENOTSUP path.
@hattori7243
hattori7243 requested a review from shuk777 as a code owner November 23, 2026 10:11
@github-actions github-actions Bot added the engine edge0-infer engine, CLI, or server label Nov 23, 2026
@linyubupa
linyubupa merged commit 7c0dd3e into main Nov 23, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine edge0-infer engine, CLI, or server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants