Experimental compiler and diagnostic harness — not a production optimiser. Final classification: narrow engineering tool.
An architecture-blind compiler prototype that analyses deterministic torch.export graphs, derives named-input dependency regions, synthesises exact Core AI execution strategies and selects work from the inputs that changed. Automatic factoring succeeded on CLIP and EfficientSAM. The proposed general adaptive runtime did not: on CLIP, physical memory followed packaged portfolio size despite only three live function handles.
The project deliberately stops at that boundary. It does not claim that caching, graph partitioning, multifunction models or incremental inference are novel.
Multimodal applications often hold one input fixed while another changes: many prompts against one image, or repeated text against new images. A monolith recomputes everything. Hand-written split models can reuse the stable branch, but they encode architecture knowledge and are easy to invalidate incorrectly.
This prototype asks a stricter question: can an exported graph itself prove which regions are reusable, generate several semantically equivalent plans, and share cached results only under a complete canonical contract?
flowchart LR
A["Deterministic torch.export graph"] --> B["Named-input dependency analysis"]
B --> C["Legal region boundaries"]
C --> D["Canonical region contracts"]
D --> E["Exact strategy synthesis"]
E --> F["Dominance and budget gates"]
F --> G["Change-aware runtime selection"]
G --> H["Core AI named functions"]
D --> I["Versioned tensor cache"]
I --> G
H --> J["Measured residency limit"]
- No CLIP- or EfficientSAM-specific partition hints: dependency regions came from exported graph structure and named inputs.
- One canonical callable identity per reusable region across strategies.
- Cross-strategy sharing only when graph, parameters, guards, ordered tensor contracts, effects and numerical configuration match.
- Original input guards and every public/intermediate tensor boundary validated fail-closed.
- Monolith retained for cold start and all-inputs-changed execution.
- Hard logical tensor-cache and callable-residency budgets, lazy loading, eviction accounting, conservative dominance and online selection.
- CLIP: 17/17 bit-exact strategies. EfficientSAM: 17/17 bit-exact strategies.
Correctness-safe dominance removed zero strategies. The final CLIP asset therefore retained 17 strategies and 22 canonical functions. A 1,220 MB logical handle budget kept only three functions live, yet process peak RSS was 14,456,012,800 B (14.456 GB, 13.464 GiB), slightly above the 14,405,255,168 B reproduced eager control. Retained RSS also rose from 6,692,192,256 B to 7,437,877,248 B.
In plain terms: physical memory followed packaged portfolio size, not active canonical regions. Lazy Python handles and logical eviction did not provide deterministic physical unload. CLIP also lost to its packaged monolith on p50, p95 and mean latency. That kills the general portfolio-runtime claim.
See the residency negative result for the controlled smaller-package diagnostic and why its unsafe pruning code is not published.
Steady metrics exclude the configured warm-up requests. Byte values and complete samples are checked against committed evidence.
| Model | Final portfolio | Exactness | Adaptive p50 / p95 / mean | Forced packaged monolith p50 / p95 / mean | Process peak / RSS after | Peak live |
|---|---|---|---|---|---|---|
| CLIP | 17 strategies / 22 functions | 17/17 bit-exact | 12.446 / 23.895 / 13.760 ms | 11.252 / 14.190 / 11.678 ms | 14,456,012,800 B / 7,437,877,248 B | 3 |
| EfficientSAM | 17 strategies / 28 functions | 17/17 bit-exact | 45.694 / 168.552 / 59.212 ms | 156.661 / 171.035 / 157.873 ms | 1,814,806,528 B / 1,064,009,728 B | 3 |
EfficientSAM retained useful reuse relative to its unusually slow packaged monolith, but its 45.694 ms adaptive p50 was slower than the 31.319 ms manual cached-image reference and roughly matched the 47.067 ms seeded automatic reference. One positive model does not rescue the failed general scaling criterion.
Requirements: Python 3.11–3.13, PyTorch 2.7–2.9 and NumPy 2.x. The portable path requires no Apple tooling or model download.
git clone https://github.com/CodingCossack/changeaware-coreai.git
cd changeaware-coreai
uv sync --extra dev --no-editable
.venv/bin/python examples/synthetic_factoring.py
.venv/bin/python -m pytestThe synthetic example exports a three-input graph, compiles dependency-derived strategies, changes only prompt, reuses an exact cached region and checks the result bit-for-bit.
For a non-editable install:
uv build
uv venv .wheel-venv --python 3.12
uv pip install --python .wheel-venv/bin/python dist/changeaware_coreai-0.1.0-py3-none-any.whl
.wheel-venv/bin/python examples/synthetic_factoring.pyThe published measurements used Apple silicon, macOS with Xcode 27.0 beta build 27A5218g, Python 3.12.11, PyTorch 2.9.0, coreai-core 1.0.0b2 and coreai-torch 0.4.1. Native dependencies are optional and unavailable on ordinary Linux CI.
uv sync --extra dev --extra coreai --extra models --no-editable
.venv/bin/python scripts/check_environment.py --json
.venv/bin/python scripts/export_clip.py --help
.venv/bin/python scripts/export_efficient_sam.py --help
.venv/bin/python scripts/benchmark_coreai.py --helpAssets default to ignored artifacts/ paths. Model weights and generated .aimodel bundles are never committed. Exact commands, pinned revisions and evidence boundaries are in reproducibility.
Useful today:
- inspecting named-input dependency structure in deterministic exported graphs;
- auditing exact partition boundaries and cache invalidation contracts;
- generating and comparing execution plans;
- diagnosing Core AI multifunction residency;
- small deployments where a fixed, deliberately tiny plan set is known in advance.
Not established:
- production reliability or broad model support;
- deterministic Core AI physical-memory eviction;
- useful global strategy pruning without contextual or model-specific knowledge;
- a general latency or asymptotic memory improvement.
- Architecture
- Canonical identity, invalidation, guards and boundaries
- Experiments and methodology
- Core AI residency negative result
- Prior art and contribution boundary
- Reproducibility
- Checked evidence
Project code is Apache-2.0. See LICENSE and THIRD_PARTY_NOTICES.md. Apple, EfficientSAM, OpenAI CLIP and Hugging Face assets retain their upstream terms; none are redistributed. This project is not endorsed by those organisations.