Cache sorted async dependency vectors - #348
Conversation
48226ab to
2c2b1d0
Compare
AsyncDepsInfo materializes dependency sets in deterministic order, but schedulers query the same entries repeatedly and currently sort on every call. Cache the sorted dependency and consumer vectors lazily. Invalidate affected entries when edges are inserted and clear the caches when dependency maps are optimized or rebuilt. Keep the public value-returning API unchanged. Extend the unit tests to cover cache invalidation, deterministic ordering after duplicate and out-of-order insertions, token-dependency rebuilding, dependency-map optimization, and batched async-operation insertion. Signed-off-by: Xuming <109933710+Mac-Huang@users.noreply.github.com>
2c2b1d0 to
fce7e0e
Compare
|
Update after completing current-base validation at All manual correctness gates now pass, including formatting, focused/full compiler unit tests, all-platform LIT, OpenVINO NPU unit tests, version-matched real-model compiles, and a transient fresh-sort cache-coherence oracle. The performance gate did not pass on current I am keeping the PR in draft and withdrawing the immediate CI request while the change is performance-blocked. The description contains the complete evidence and a targeted-instrumentation/redesign plan; there is no need to spend hosted CI capacity on this head yet. |
Summary
AsyncDepsInfo::getOpDeps()andgetConsumerOps()materialize and sort aDenseSeton every call. The feasible-allocation, prefetch, and scheduling paths query many stable dependency sets repeatedly, reconstructing and sorting the same vectors.This change:
Performance evidence
The previous validation campaign used Qwen2.5-7B INT8 on NPU.5010 with context windows 1024, 2048, 4096, and 8192. It alternated baseline/candidate ordering across three adjacent pairs per window, excluded warmups, and bypassed the UMD cache.
The candidate won all 12 pairs, with a 1.0359x geometric-mean speedup. A gated W2048 CPU profile measured:
FeasibleAllocation: 18.471 s to 7.381 s (60.0% reduction); andcompile_model: 242.647 s to 234.255 s (3.46% improvement).Those measurements predate the current
developbase and are retained as historical evidence only.Current
developrefreshThe final branch was benchmarked directly against
0b38f7d42113ff329ac2bdd33583d123de4ccf2fwith a version-matched OpenVINO 2026.4 C++ harness. The run used one excluded warm-up per arm/window, three adjacent pairs, balanced AB/BA ordering across windows, fresh processes, cold UMD cache, exact artifact hashes, and/usr/bin/time -vRSS.All six measured baseline/candidate pairs had identical 458-pass inventories and report counts. Across both windows, the candidate won 1/6 pairs; its geometric-mean improvement was -0.368%. The RSS gate passed, but the required 2% wall-time improvement did not.
A compile-interval diagnostic profile also did not reproduce the provisional 50% global qsort-family reduction. For one Qwen2.5-7B INT8 W2048 compile per arm at 49 Hz, baseline recorded 24 inclusive qsort-family samples (0.490 sampled CPU seconds) and the candidate recorded 34 (0.694 seconds), an observed reduction of -41.7%. Total sampled CPU and compile wall time were effectively unchanged, pass inventories matched exactly, and compiler-reported
FeasibleAllocationtime improved by 1.88%. Because this is a low-count, fixed-order, global attribution from stripped binaries, it does not isolateAsyncDepsInfoor establish a regression; it shows that the historical global-qsort gate was not met on currentdevelop.The current evidence therefore does not justify promoting this draft for review. A redesign should begin with targeted cache hit/miss, invalidation, and sort-call instrumentation; repeat AB/BA profiles with symbolization before spending the larger model-matrix budget.
Correctness and validation
Validated on NUC16 from final commit
fce7e0e737e3370b9067fa3adecc201753540aed, based directly ondevelopat0b38f7d42113ff329ac2bdd33583d123de4ccf2f:clang-format 18.1.8 and
git diff --check: passed.Focused
MLIR_AsyncDepsInfo.*: 5/5 passed.Complete
npuUnitTests: 7,085/7,085 enabled tests passed; 31 disabled.All-platform LIT validation completed with exit status 0 for every invocation:
UNSUPPORTEDis the expected per-platform filtering of the shared corpus; there were no unexpected failures, unresolved tests, timeouts, or unexpected passes.ov_npu_unit_tests: 1,500 total; 1,463 passed and 37 hardware-dependent tests skipped.Qwen2.5-7B INT8 W2048 PLUGIN real-model correctness smoke: version-matched OpenVINO 2026.4 C++ baseline and candidate compiles both succeeded, each loading exactly its intended compiler artifact. Baseline wall time was 244.495 s; candidate wall time was 245.818 s. These excluded warm-ups are a correctness gate, not performance evidence.
Paired current-upstream performance and peak-RSS campaign completed with exact pass-inventory agreement and acceptable RSS, but the wall-time acceptance gate was not met. The excluded smoke timings above are not performance evidence.
Transient fresh-sort cache-coherence oracle: recomputed and compared the sorted dependency/consumer vector on every lookup; 50 focused test executions, all 7,085 enabled unit tests, and a Qwen2.5-7B W2048 compile passed without a stale-cache finding. The source, unit test, compiler, and runtime compiler were restored to their exact pre-run hashes.
Targeted current-base qsort CPU profile completed with exact compiler/runtime provenance and pass-inventory agreement. The broad global-qsort gate was not met; feature-specific attribution remains inconclusive without symbols or targeted counters.
GitHub-hosted checks awaiting repository approval
The following workflows currently report
action_requiredfor the final SHA and remain unchecked until they are approved and complete:clang-formatworkflow (the manual formatting check above has passed).Expanded profiling plan
The work is split into a bounded merge gate and a broader scale study so that the PR is not justified by one model family:
/usr/bin/time -vRSS. Keepperf stat, compile-intervalperf record, pass timing, qsort samples, async vertices/edges, degree, cache hit/miss, invalidation, allocation, and retained-capacity counters in separate diagnostic runs so instrumentation cannot perturb the wall-time samples.compile_modelwall time on both high-task graphs; no median regression above 3% on either small control; no median peak-RSS growth at or above 5% on the largest graph; and explicit reporting of the O(V + E) cache-memory cost. Blob hashes are recorded for provenance, not compared as a correctness gate, because repeated identical compiler runs are not bit-deterministic.Memory tradeoff
The cache retains sorted vectors alongside the dependency sets, adding O(V + E) storage plus per-entry optional/vector overhead. On the current-base paired run, median maximum RSS changed by -0.483% at W2048 and +0.250% at W1024; the worst paired increase was 2.063%, within the 5% gate.
JIRA ticket
Fixes #342
Target Platform For Release Notes
The implementation is architecture-independent. Hardware performance profiling is performed on NPU.5010; the CI compilation and LIT matrices cover all supported architecture families.
Classification of this Pull Request
AI Assistance