Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions research/native-history-setup-cache/BENCHMARK.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
{
"errors": 0,
"executable": "/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12",
"optimized": false,
"platform": "macOS-27.0.1-arm64-arm-64bit",
"python": "3.12.15 (main, Oct 14 2026, 00:55:37) [Clang 23.1.3 ]",
"samples": [
{
"mode": "baseline",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 1.246776457875967,
"statistics": {
"cache": {
"currsize": 0,
"hits": 0,
"maxsize": 256,
"misses": 0
},
"mode": "baseline"
},
"trial": 0
},
{
"mode": "cached",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 0.9610304171219468,
"statistics": {
"cache": {
"currsize": 58,
"hits": 158,
"maxsize": 256,
"misses": 58
},
"mode": "cached"
},
"trial": 0
},
{
"mode": "baseline",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 1.281701625091955,
"statistics": {
"cache": {
"currsize": 0,
"hits": 0,
"maxsize": 256,
"misses": 0
},
"mode": "baseline"
},
"trial": 1
},
{
"mode": "cached",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 1.0426137920003384,
"statistics": {
"cache": {
"currsize": 58,
"hits": 158,
"maxsize": 256,
"misses": 58
},
"mode": "cached"
},
"trial": 1
},
{
"mode": "baseline",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 1.304742000065744,
"statistics": {
"cache": {
"currsize": 0,
"hits": 0,
"maxsize": 256,
"misses": 0
},
"mode": "baseline"
},
"trial": 2
},
{
"mode": "cached",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 1.0262446249835193,
"statistics": {
"cache": {
"currsize": 58,
"hits": 158,
"maxsize": 256,
"misses": 58
},
"mode": "cached"
},
"trial": 2
},
{
"mode": "baseline",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 1.2796051658224314,
"statistics": {
"cache": {
"currsize": 0,
"hits": 0,
"maxsize": 256,
"misses": 0
},
"mode": "baseline"
},
"trial": 3
},
{
"mode": "cached",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 0.9767264169640839,
"statistics": {
"cache": {
"currsize": 58,
"hits": 158,
"maxsize": 256,
"misses": 58
},
"mode": "cached"
},
"trial": 3
},
{
"mode": "baseline",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 1.2514010828454047,
"statistics": {
"cache": {
"currsize": 0,
"hits": 0,
"maxsize": 256,
"misses": 0
},
"mode": "baseline"
},
"trial": 4
},
{
"mode": "cached",
"output_sha256": "31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d",
"returncode": 0,
"seconds": 0.966591291828081,
"statistics": {
"cache": {
"currsize": 58,
"hits": 158,
"maxsize": 256,
"misses": 58
},
"mode": "cached"
},
"trial": 4
}
],
"schema": "native-history-setup-benchmark/v1",
"source_sha256": {
"SOURCES.json": "a8665633efa339149c3e1b936b0770a8f1de1a914538ed79c85e01f3f8a2e6c7",
"benchmark.py": "97bc142fe47b2911dae2f7695cae9cbb106bf3235a09dd9d66cea9ded6238f78",
"run.py": "78a2b5038354facf910908af2d9a533d759d444b79edd5ffce1122916cf77606"
},
"summary": {
"baseline": {
"maximum_seconds": 1.304742000065744,
"median_seconds": 1.2796051658224314,
"minimum_seconds": 1.246776457875967
},
"cached": {
"maximum_seconds": 1.0426137920003384,
"median_seconds": 0.9767264169640839,
"minimum_seconds": 0.9610304171219468
},
"fraction_less_time": 0.23669703510745088
},
"timed_region": "fresh interpreter, authentication and complete direct caller"
}
133 changes: 133 additions & 0 deletions research/native-history-setup-cache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Reuse native-map setup in the complete full-history caller

The complete PR5447 direct-history caller takes **23.67% less wall time** with
an invocation-owned cache of exact native-map construction. Five alternating
fresh-process runs per side give medians of 1.279605 s and 0.976726 s. Baseline
range is 1.246776 to 1.304742 s; cached range is 0.961030 to 1.042614 s. All ten
complete executions succeed with identical scientific stdout bytes.
[BENCHMARK.json](BENCHMARK.json) is generated by the retained harness and binds
its source hashes.

Claim type: scoped implementation-preservation proof, finite conformance and
local performance evidence. This is a newly posed runtime question on the
unchanged predecessor caller. No new kernel theorem, kappa or supplier admission
is claimed.

## Change and preservation argument

The complete caller initializes three separate native registries for its
provider-backward, source-backward and source-forward cases. They request 216
native constructions but use only 58 distinct binary maps. The adapter reuses
158 exact results. It neither caches history rows nor shares native registries.

The pinned `monomial.native(columns)` function is deterministic. It reads nine
binary map columns and returns one immutable 1,024-byte signed permutation.
The key snapshots all nine columns, so equal keys have equal outputs. Each miss
calls the original function. Each hit returns the bytes that function would
construct. Mutating an input list cannot change a stored tuple key; callers
cannot mutate returned bytes. Exceptions are not cached. Capacity is 256 entries,
and the cache is cleared on every invocation exit, including exceptional exits.

Every `intern` call therefore receives the original bytes in the original order.
Operator IDs, products, scalar rows, histories and final output remain the same.
This implication does not depend on a small-width sample. The adapter
authenticates all seven external inputs before installing reuse and runs the
original `verify_kernel.py` unchanged. Its three complete cases, literal
permutation checks, equations, frozen-result comparison and four original
controls still execute.

## Evidence and measurement

The new verifier compares original and cached construction on 300 distinct
invertible nine-dimensional unitriangular maps. It checks full-key reuse,
256-entry capacity, eviction, mutable lists, restored contents and independent
cache owners. Six malformed inputs reject at the boundary. Two singular-map
executions retain the original exception and leave no cached value.

Both complete callers must agree byte for byte and match every field of the
predecessor's frozen result. Their stdout SHA256 is
`31116d29f77eaa5732cc76eb0c716c808f063c195e2aa886f4993ea33f51d29d`.
The cached path must record exactly 58 misses and 158 hits. The verifier
authenticates the generated measurement against its implementation, harness and
manifest, and recomputes the measurement summary. Timing itself is not a CI gate.

Local measurement uses CPython 3.12.15, standard library, macOS arm64 and 18
logical CPUs. Initial load averages were 2.86, 2.41 and 1.74; other work could
run concurrently. Alternating sides exposes both to that load. Their observed
ranges are disjoint. Each subprocess includes startup, authentication and the
entire direct caller inside the timed region. Baseline uses the same adapter
without installing reuse. Neither side skips checks or uses a cross-process
cache. All ten return codes are zero. Profiler runs are excluded from samples.

The initial complete profile identifies 216 `monomial.native` calls; a separate
cached profile has 58. Fraction arithmetic remains a larger cost after reuse.
The repeated setup is only part of the complete caller. This explains a bounded
end-to-end saving and does not predict a twofold speedup. The first improvement
is packaged without further arithmetic optimization.

## Reproduce

From the repository root on the recorded machine:

```sh
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -B research/native-history-setup-cache/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -W error -O -B research/native-history-setup-cache/verify.py
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/native-history-setup-cache
/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/native-history-setup-cache --check-source-history
```

Direct status is `PASS_NATIVE_HISTORY_SETUP_CACHE`: 300 maps, eight rejecting
executions, two complete callers, 58 misses and 158 hits. Registered status is
`PASS_REGISTERED_RESEARCH_PACKAGE`. Other machines may substitute CPython 3.12.

Run the complete cached caller or generate a new measurement outside the checkout:

```sh
python3.12 -W error -B research/native-history-setup-cache/run.py --mode cached
python3.12 -W error -B research/native-history-setup-cache/benchmark.py --output /absolute/scratch/new-benchmark.json
```

The harness refuses to overwrite its output. For a diagnostic profile, insert
`-m cProfile -o /absolute/scratch/profile.pstats` before `run.py`. Profiler timings
are not comparable to the retained uninstrumented samples.

## Limits and code discipline

Timing is local to this complete direct caller and environment. Other PR5447
commands, selected cold replay, physical native admission, compiler closure,
ownership, precision/tape and analytic recovery remain unrun or inherited.
Independent human and formal proof-kernel review are unclaimed. No predecessor
source, credit line or selected-frontier file changes.

The adapter accepts nine integer columns in `[0,512)`; invertibility retains the
original check. Retained payload is at most 256 times 1,024 bytes plus bounded
keys and bookkeeping. Python allocation is a managed-runtime deviation from
fixed allocation. Finite loops are bounded by 300 maps, 36 triangular positions,
six malformed inputs and two singular executions. Benchmarking runs ten children
with 120-second timeouts. New functions fit within 60 lines. Standard import
loading and `runpy` load only the pinned modules, a bounded dynamic-loading
deviation with no generated code. Explicit exceptions remain active under `-O`.
Warning-strict normal and optimized replay supply the interpreted diagnostics.

## Open next questions

1. Can exact rational row arithmetic reduce the remaining complete caller cost?
Start with a new cached profile and preserve all scientific output. No such
implementation or measurement is supplied here.
2. Should a future native compiler expose an invocation-owned operator factory?
First specify its exact key, lifetime and source invalidation on one consumer.
Shared API design and other caller replays remain open.

Structured questions are in [TASK.json](TASK.json).

## Credit and sources

The adapter, preservation argument, conformance checks and measurements were
produced by Nick Petalas. Memoization is classical; priority for it is unclaimed.

Credit THU New Media Research Center / thu-nmrc PR5447 for the native algebra,
complete caller, kernel proofs and controls; Mark / Matarener PR5427 for event
and ownership semantics; Dillon Amburgey PR5402, Cao Yifan PR4610, Cinna Davis,
zxv, David Ganz, Jacob Alan Sussman, Ali Romman and the retained
native/query/compiler lineage. Their original files and credit are unchanged.
Exact main-branch pins and hashes are in [SOURCES.json](SOURCES.json). Apache-2.0.
60 changes: 60 additions & 0 deletions research/native-history-setup-cache/SOURCES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"schema_version": 1,
"base_commit": "2485805a6d47f36ea83ddde6327d453ac82d44dc",
"files": [
{
"path": "certificates/selected-result.json",
"usage": "provenance",
"git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a",
"sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa"
},
{
"path": "docs/research/agent-task-catalog.json",
"usage": "provenance",
"git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec",
"sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81"
},
{
"path": "research/kappa-round3-warp-20261022/ACTUAL-WORD.json.gz",
"usage": "input",
"git_blob": "46d929df83817b85a5387bcdb9745e0627d6366e",
"sha256": "7679daa4ec6a40f56fc7f0202379a6f454310e94945aba4f48beaaaafb838d05"
},
{
"path": "research/native-rank8-helper-provider/WORD.json.gz",
"usage": "input",
"git_blob": "f3111b47e89496da8ca0ee45b2e4b258c0634d8e",
"sha256": "7dc356001ed597ad6fc9fd3e0bc6ff7e3ec3a580a579a956827aa17fccfdd2dc"
},
{
"path": "research/physical-zqy-scalar-span/KERNEL-RESULT.json",
"usage": "input",
"git_blob": "f57f4accbc0d334db480d2b31db4185420654567",
"sha256": "0d56847d579aa195c6ee462a631a5ccdbfbb128dccc26503dbdc481963b6cab8"
},
{
"path": "research/physical-zqy-scalar-span/KERNEL.json",
"usage": "input",
"git_blob": "cd699656f9192ccf6d462a45617b5e56d6799dfb",
"sha256": "ad403cdd98975ae9a8033afff5a86f96d055e44c5be19c1f171387cf26cd3b81"
},
{
"path": "research/physical-zqy-scalar-span/monomial.py",
"usage": "input",
"git_blob": "1a4483808478808784fe6b3e0b88cdc959752a66",
"sha256": "87cdb1688b841891eccefdcaebe67b97a6c86b7af676bbbb667d1d5ee5d45d3e"
},
{
"path": "research/physical-zqy-scalar-span/native.py",
"usage": "input",
"git_blob": "0784aa84b7bd49454e57530be3ded522313a91f8",
"sha256": "1bad1ffe747c3977d1a6bc1cfa9faa4127e38cbf49d7fcf4ae8060fbc7f67d4e"
},
{
"path": "research/physical-zqy-scalar-span/verify_kernel.py",
"usage": "input",
"git_blob": "036d1f199f03a2a3e2792e33d28c6e5a7e4d26c2",
"sha256": "29af4fd8536aa10d8ed0459087744fd077113073ec7e3a682fde970593fd857d"
}
]
}
Loading