Repository navigation
[CoreAI] Add multithread stress testing and shared op/model suites - #24374
Conversation
Summary: Expose runtime correctness and concurrency failures through repeatable CI coverage across floating-point and quantized execution. Exercise isolated cold and warm cache workloads without changing backend behavior or masking failures. Test Plan: User-run native stress CTest passed in both smoke and stress runs. The shared model/operator suites are collecting failures; recorded results include operator output mismatches and model-load failures, which are intentionally not fixed here. TODO: complete the shared-suite runs and investigate the collected failures. CoreAI-enabled Python runtime registration, native stress-target build, and scoped lint checks passed. Generic Buck validation was unavailable because its Swift owner query failed.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24374
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 2 Pending, 1 Unclassified FailureAs of commit 6009fe6 with merge base 822cb60 ( NEW FAILURE - The following job has failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude review this PR |
|
@claude review this code |
This PR needs a
|
|
Claude finished @metascroy's task in 4m 26s —— View job This adds a good test layer for Core AI and I found no blockers, but the README is out of date in three places, the suite CI has no per-test timeout, and two avg_pool partitioner cases may still be delegated wrongly. Detailed reviewPR Review: #24374SummaryThis PR adds a multithreaded runtime stress test, Code Quality
Infrastructure
Testing
RecommendationApprove Nothing here blocks merging. Before or soon after merge I'd fix the README drift, the missing pytest |
…8 limits - CoreAITester: in fp16 mode, compare each output with atol = max(atol, 0.02 * max|reference|). FP16 rounding error follows the network's activation scale, so small outputs (e.g. cancelling logits) can exceed the shared per-element tolerance; resnet50 flaked with a 0.5 error on logits spanning +/-51. Op-sized outputs keep atol 0.1. - coreai.yml: run all 8 backend-tester jobs concurrently (max-parallel 8). - coreai.yml: allow 23 w8a8 model failures. 7 fail locally; on the xcode-27 runners 19 w8a8 dynamic_shapes models also fail execution with Core AI inferenceFailed(-1).
On the xcode-27 runners, Core AI specialization of Linear(256 -> 1) fails with AIModelError error 1 in every flow, stopping the zero-failure operator jobs and pushing w8a8 operators past its limit. It passes on local Apple silicon, so skip it only when GITHUB_ACTIONS is set.
On the xcode-27 runners, nearest upsample by a fractional scale (1.5) picks different source pixels than PyTorch's floor(i / scale) mapping, failing the zero-failure fp32 and fp16 operator jobs. Integer scales match, and the test passes on local Apple silicon, so skip it only when GITHUB_ACTIONS is set, alongside test_linear_feature_sizes.
This PR mainly adds testing for the Core AI backend: a multithreaded runtime stress test, and Core AI flows in the shared ExecuTorch operator and model test suites. It also fixes the smaller issues that testing found.
Multithreaded stress test
runtime/test/coreai_multithread_test.cpp(CTestcoreai_multithread_test) starts N threads. Each thread repeatedly creates anexecutorch::extension::Module, loads it, runs it and checks the output against expected values. Threads wait at a shared start gate so their loads overlap.runtime/test/export_stress_fixture.pyexports the test model at build time: an fp16 residual MLP with a forced graph break, so the program has two Core AI delegates.COREAI_STRESS_THREADS/COREAI_STRESS_ITERATIONSset the load (default 4 × 10). CI runs 50 × 100.Shared operator and model suites
test/tester.pyaddsCoreAITester, with Core AI stages for quantization (CoreAIQuantize, throughcoreai_opt), lowering (CoreAILower, applying the default passes) and serialization. Each run gets a temporarycoreai_cache_dir, so runs don't share state.backends/test/suite/flows/coreai.pyregisters four flows:coreai_fp32,coreai_fp16,coreai_w8a8andcoreai_w8. Quantized flows skip models with nothing to quantize.index_putwriting the same position twice withaccumulate=False, which PyTorch documents as undefinedavg_pool3d, which has no CPU float16 referenceinception_v3, whose randomly initialized weights overflow float16, so the reference is itself NaNsetup.py/CMakeLists.txtbuild and package the Core AI delegate into the Python runtime whenEXECUTORCH_BUILD_COREAI=ON, so the suites can run models on Core AI.CI failure thresholds
.github/workflows/coreai.ymlruns every suite on every flow (-n auto). The job reads the JSON report and fails if any test errors, no test passes, or more than the allowed number of tests fail:coreai_fp32coreai_fp16coreai_w8coreai_w8a8The zero-failure jobs stop at the first failure (
-x). The w8a8 jobs run to completion so every failure is counted; lower their limits as the failures are fixed. The backend's Python unit tests now also run in parallel.Fixes found by the new tests
alpha: the installed converter ignores a non-1alphaonadd/sub. The newDecomposeAddSubAlphaPassrewritesx ± alpha*yas a multiply followed by a plain add/sub.alphabecomes a lifted constant in the output dtype, so fp16 stays fp16.NormalizeCoreAIOpArgsPasswrites out arguments the converter misreads or crashes on when they're implicit:mean.dim/amax/aminwith dims omitted orNoneceil_modewhen it doesn't change the output shapesqueezenaming a dim whose size isn't 1, which PyTorch treats as a no-opis_coreai_supported_variantkeeps ops the converter would crash on or compute wrongly out of the delegate (they run on CPU instead):index_putwithaccumulate=True, dynamic non-batch dims, or integer indices that leave input dims unindexed (aborts the process in MPSscatter_nd)alphaceil_mode/count_include_pad=Falsecases the converter can't expressexport_hash) is now a hash of the full bundle contents, not the SDK program hash. Two delegates with the same program but different metadata (for example creation timestamps) no longer collide in the NamedDataStore.Test plan
python -m pytest backends/apple/coreai -n auto: 151 passed, including new unit tests for both passes, the variant checks, asset deduplication and dynamic I/O dims.