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
124 changes: 124 additions & 0 deletions .github/workflows/nor18r-runtime-memory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: NOR-18R source-locked CPU runtime bigint and memory benchmark

on:
push:
paths:
- 'research/nor18r_runtime/**'
- '.github/workflows/nor18r-runtime-memory.yml'
pull_request:
paths:
- 'research/nor18r_runtime/**'
- '.github/workflows/nor18r-runtime-memory.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
arithmetic-parity-private-future-isolation:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Validate native exact mask, cached masks, integer inverse operand sizes and sealed target
run: python -m unittest research.nor18r_runtime.test_runtime -v

frozen-original-public-receipt-independent-audit:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Independently reconstruct all original public sources and first-hosted CPU / bigint / RAM metrics
run: |
python research/nor18r_runtime/receipt_audit.py --check \
--archive research/nor18r_runtime/results/nor18r_original_hosted.zip

source-locked-64-case-cpu-bigint-memory:
needs: arithmetic-parity-private-future-isolation
runs-on: ubuntu-latest
timeout-minutes: 50
env:
PYTHONHASHSEED: '0'
OPENBLAS_NUM_THREADS: '1'
OMP_NUM_THREADS: '1'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Rebuild only public fixture from original NOR-18 heldout 288-case receipts
run: |
python research/nor18r_runtime/benchmark.py --check \
--make-fixture /tmp/nor18r_public_fixture.json
- name: Benchmark matched public CPU algorithms with seven trials and isolated RSS workers
run: |
python research/nor18r_runtime/benchmark.py --check \
--fixture /tmp/nor18r_public_fixture.json \
--repetitions 7 --warmups 2 --out /tmp/nor18r_full.json
- name: Audit public-only provenance, timed repeated measures, peak memory and bigint work
run: |
python - <<'PY'
from pathlib import Path
from hashlib import sha256
from collections import Counter
import json,math
fixture=Path('/tmp/nor18r_public_fixture.json').read_bytes()
raw=Path('/tmp/nor18r_full.json').read_bytes()
public=json.loads(fixture)
z=json.loads(raw)
assert public['schema']=='nor18r.public_fixture_64_cases_from_original_288.v1'
assert public['no_hidden_query_outputs_or_planted_program_identities']
assert public['NOR18_original_evidence_sha256']=='9905aa23466b98ba2068e6daf9206d35c453b8b3b75bd27c3ab7ff8f0db4041b'
assert len(public['cases'])==64
assert z['schema']=='nor18r.executable_cpu_bigint_memory_source_locked.v1'
assert z['original_NOR18_full_JSON_SHA256']==public['NOR18_original_evidence_sha256']
assert z['fixture_sha256']==sha256(fixture).hexdigest()
assert z['fixture_cases']==len(z['per_case'])==64
assert z['timed_repetitions']==7 and z['untimed_warmups_per_case_per_algorithm']==2
assert z['modes']==['independent16','cached16','prefix160','prefix176']
assert z['source_families']=={'late_source':32,'signed':16,'rational':16}
assert len(set(x['full_public_input_sha256'] for x in z['per_case']))==64
assert len({x['cohort'] for x in z['per_case']})==4
assert z['primary_cohort_block_bootstrap']['draws']==4096
assert z['scope']['future_outputs_and_private_generator_programs_not_in_fixture']
assert z['scope']['exact_public_mask_and_certificate_match_original_for_every_mode']
assert z['scope']['time_includes_python_bigint_implementation_effects']
assert z['scope']['RSS_and_tracemalloc_measured_in_separate_untimed_passes']
for r in z['per_case']:
assert r['algorithm_result_parity_all_modes']
assert len(r['measured_ns'])==4
for mode in z['modes']:
assert len(r['measured_ns'][mode])==7
for timing in r['measured_ns'][mode]:
assert timing['total_ns']==timing['query_ns']+timing['verification_ns']+timing['certificate_ns']
assert timing['total_ns']>0
assert r['median_ns'][mode]['total_ns']>0
assert r['untimed_tracemalloc'][mode]['mask']==r['reference_full_public_accept_mask']
assert r['bigint_operand_width_ledger']['per_mode'][mode]['R_integer_multiplications_executed']>0
assert r['bigint_operand_width_ledger']['per_mode'][mode]['R_operand_bitwidth_product_proxy']>0
for mode,value in z['isolated_process_RSS_KiB'].items():
assert mode in z['modes']
assert value['cases']==64
print('NOR18R HOST',z['host'])
print('NOR18R MEASURED COMPLETE CPU SPEEDUP',z['primary_median_paired_total_speedup'])
print('NOR18R PAIRED CACHED FASTER',z['primary_cached_faster_cases'],'/64')
print('NOR18R COHORT BLOCK BOOTSTRAP 95%',z['primary_cohort_block_bootstrap'])
print('NOR18R REGISTERED PRIMARY PASS',z['primary_preregistered_passed'])
print('NOR18R MODE FULL RESULTS',z['summary_all'])
print('NOR18R FAMILY RESULTS',z['summary_by_family'])
print('NOR18R ISOLATED RSS KiB',z['isolated_process_RSS_KiB'])
print('NOR18R FIXTURE SHA256',len(fixture),sha256(fixture).hexdigest())
print('NOR18R FULL BENCHMARK SHA256',len(raw),sha256(raw).hexdigest())
PY
- uses: actions/upload-artifact@v4
with:
name: nor18r-original-public-only-64-case-fixture-and-timing-results
path: |
/tmp/nor18r_public_fixture.json
/tmp/nor18r_full.json
101 changes: 101 additions & 0 deletions research/nor18r_runtime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# NOR-18R: executable CPU, bigint, and memory audit of cached exact verification

**Preregistered 16 November 2026 before opening measured NOR-18R CPU timings.** Follows merged [NOR-18 #175](https://github.com/MoralityLabAI/Compactification-Theory/pull/175) and [MathCan cached-verifier work theorem #94](https://github.com/patrickdugan/MathCan/pull/94).

NOR-18 measured **coefficient-operation work**, finding that one cached degree-192 sixteen-template public screen gave the entire certifiable 48/192 late-source subset at an eight-unit proxy cap. The mathematical work saving from sharing four unary public transforms is exact for that declared proxy. NOR-18R measures real Python 3.12 CPU execution, time per checked public case, Python-traced peak temporary allocation, isolated-process maximum resident memory and the actual integer operand sizes encountered by the reciprocal (\`R\`) recurrence.

## Frozen test sources and execution

Use the **original NOR-18 held-out 288-case record**, preserved at \`research/nor18_costed_prefix/results/nor18_full.zip\`. Require the original uncompressed 12,896,423-byte JSON SHA-256:

\`9905aa23466b98ba2068e6daf9206d35c453b8b3b75bd27c3ab7ff8f0db4041b\`.

Regenerate the exact public source cases from NOR-18's frozen generator and seeds. Verify **every** reconstructed public source hash against its corresponding archived first-run record before selecting the benchmark subset. In each of four cohorts, take the first eight late_source, first four signed and first four rational entries in the original cohort order. This fixes **64 public-distinct benchmark sources**, with 32 late_source, 16 signed and 16 rational cases. Store only degree-192 public input/output demonstrations, degree-256 *public query input*, the publicly derived header, source family and archival source digest. The planted program and withheld future query output remain excluded from every benchmark fixture and timed path.

All measured algorithms use the *identical* two degree-192 public demonstrations and query input and must produce the **same 16-bit exact acceptance mask and the same unanimous-future-output certificate**. Recovered masks must also match the original frozen NOR-18 full-mask receipts; each public simulated future must agree with the reference RRC25 exact interpreter in standalone parity tests.

## Preregistered executable comparisons

1. **\`independent16\`:** Call the original \`compound25.verify_template\` sixteen times, using native \`execute\` and recalculating its base, U and V unary transformations for each candidate.
2. **\`cached16\`:** Call the existing \`nor17.candidate_outputs\` once per demonstration at degree 192, reusing the four unary transforms across all sixteen templates, then compare each candidate output with the observed public demonstration.
3. **\`prefix160\`:** Construct the two cached degree-160 source-prefix screens, intersect the survivors, and call the *same native* full exact \`verify_template\` on each surviving candidate.
4. **\`prefix176\`:** Repeat with a degree-176 screen and exactly the same downstream native full checks.

Every algorithm also independently computes all sixteen hypothetical degree-256 outputs from the known **public query input**. The benchmark reports **query simulation time and public verification time separately**, as well as combined execution time, so comparisons of complete certificates include shared query computation costs. It reads neither future query outputs nor private program identities. Query simulations for every mode are recomputed and metered within that mode, with no cross-mode cache credit.

For each of the 64 cases, run two warmups and **seven measured repetitions per mode**. Randomize the order of the four modes deterministically inside each repetition, so CPython allocator warming and CPU frequency drift do not always favor a particular algorithm. Before each sample, perform \`gc.collect()\`; temporarily disable garbage collection during the timed segment. Report per-case median query, verification and combined \`perf_counter_ns\` times; paired speedup \`median(independent16)/median(cached16)\` and a 95% **four-cohort block bootstrap** confidence interval with 4096 deterministic seeded draws. Give per-family medians and the fraction of source cases where cached execution is faster. CPU architecture, Python/compiler version and host information must accompany every source receipt.

Measure peak Python-traced temporary allocation **in an untimed separate run per case and algorithm** using \`tracemalloc\` starting before the algorithm and stopping afterward. Also launch isolated subprocesses per mode, reading their process maximum resident set size via \`resource.getrusage(RUSAGE_SELF).ru_maxrss\` on Linux; report pre-run baseline RSS, peak RSS, and peak-minus-baseline, with clear caveats that allocator reservations and process startup can make the RSS increments zero. These memory metrics are separate from timings, and neither is a hardware-independent proof.

## Integer costs and safety interpretation

Replay one exact reciprocal formal-series inversion for each degree-192 demonstration input and the degree-256 public query input. Verify the replay against the exact original \`graph11.inv\` result. Record the **actual number of Python big-integer multiplications and the sum of the products of the operands' positive bit lengths** in that inverse recurrence. Scale this observed per-source integer workload by the *exact* reciprocal invocation counts implied by each algorithm's public base, U and V calls (and cache reuse) to provide a per-method bigint operand-width ledger. Record maximum intermediate and output coefficient bit lengths and maximum Python integer storage size. This bit-length product sum is an **operand-size proxy**, distinct from native CPU instructions, Python multiplications per second and asymptotic multiplication bit complexity.

The prior NOR-18 coefficients-only prediction is that cached sixteen-template verification does fewer repeated reciprocal-series operations and may be faster in real CPU time. **Primary registered performance criterion:** cached16 has the same exact masks/certificates for every source, a paired median complete-public-certificate speedup of **at least 1.5×**, and is faster on **at least 48 of 64 cases**. Report those components independently. All other comparisons, including prefix160/prefix176, memory, process RSS and family-specific effects, are exploratory. This is measured performance on a pinned GitHub Actions CPU runner, not a claim about 5080/3050 GPUs, other machines or mathematical generalization.

## Reproduce

\`\`\`sh
python -m unittest research.nor18r_runtime.test_runtime -v
python research/nor18r_runtime/benchmark.py --check \
--make-fixture /tmp/nor18r_fixture.json
python research/nor18r_runtime/benchmark.py --check \
--fixture /tmp/nor18r_fixture.json \
--repetitions 7 --warmups 2 --out /tmp/nor18r_full.json
\`\`\`

The hosted workflow separately verifies the source manifest, original public-mask parity, all 64×4×7 timing samples, memory ledgers and test-source integrity. Full original benchmark evidence is frozen by SHA-256 after the first successful run. Unexpected errors, parity failures or insufficient measurements block merge.


## First executed CPU result (original source locked)

[Original green hosted CPU and memory benchmark](https://github.com/MoralityLabAI/Compactification-Theory/actions/runs/43797844269), artifact ID 14195445905, completed on 16 November 2026. Its public-only 64-source fixture and complete 7×4×64 timing records are **preserved byte-for-byte** in [results/nor18r_original_hosted.zip](results/nor18r_original_hosted.zip) and fingerprinted in [results/nor18r_first_frozen_receipt.json](results/nor18r_first_frozen_receipt.json).

The original JSON fingerprints are:

- Public-only NOR-18 source fixture: 1,306,733 bytes, SHA-256 \`5d75f2971d8b94daa9b65caae68e65921f2a90cd267481c7bb80a881e937d186\`.
- Complete first measured CPU benchmark: 580,813 bytes, SHA-256 \`59d48c8c9fe1bdf80ee2662d0c18f069f8414a92d48ad7980e3bb19b2a10ad98\`.
- Original NOR-18 288-case source record: SHA-256 \`9905aa23466b98ba2068e6daf9206d35c453b8b3b75bd27c3ab7ff8f0db4041b\`.

The [independent archived-receipt auditor](receipt_audit.py) regenerates exact acceptance masks and candidate query predictions from the fixture's public data using the original corpus interpreter, checks 1,792 original nanosecond timing samples, all 256 separately measured peak allocation records, per-case inverse-operand bit sizes, and the deterministic 4,096-draw cohort-block bootstrap. It imports no benchmarking implementation. The separate native-parity test verifies the four original public algorithms and future-label isolation, while the full hosted benchmark is reproducible without changing frozen source selection.

### Hosted platform and CPU measurements

Measured on GitHub Actions Linux \`7.0.0-1019-azure\`, x86-64, CPython 3.12.16 compiled with GCC 15.2.0, reporting four logical CPUs. Garbage collection was collected immediately before each timed run and disabled during the measured segment. Each case/mode was warmed twice, timed seven times, and mode order was deterministically shuffled. Source generation and JSON loading were excluded from timings.

| Public checker, including identical public query simulations | Median per-case complete CPU time | Median public-verification time | Median separately traced peak temporary allocation |
| --- | ---: | ---: | ---: |
| Native 16 independent checks | 23.913 ms | 21.291 ms | 74.1 KiB |
| **Four-unary cached sixteen-candidate batch** | **4.327 ms** | **2.266 ms** | 128.2 KiB |
| Degree-160 prefix cache + independent survivor checks | 12.331 ms | 9.706 ms | 112.8 KiB |
| Degree-176 prefix cache + independent survivor checks | 8.836 ms | 5.744 ms | 120.6 KiB |

The **median of the 64 paired complete-time speed ratios** was **4.32878×**, with cached full-batch execution faster in **64/64** cases. The preregistered speed criterion (median paired speedup at least 1.5× and cached faster on at least 48 of 64 public inputs) **passed**. The four-cohort block-bootstrap 95% interval was **4.280× to 4.396×**. This interval resamples the same four fixed generator cohorts and is conditional on this first hosted execution. It is not a cross-machine confidence interval or an independent-replication result.

Per-family median paired speedups were 4.396× for late_source (32 cases), 4.323× for signed (16) and 4.204× for rational (16). Every mode exactly reproduced every publicly accepted template and every logical output-unanimity certificate on all sixty-four benchmark sources.

### Exact integer operand workload and memory qualification

The independent RRC25 reciprocal algorithm executes a quadratic number of Python bigint products per inversion. The observed multiplication counts and operand-bitwidth products, including the once-per-mode public query simulation, were:

| Method | Observed R integer products across 64 cases | Sum of positive operand bitwidth products |
| --- | ---: | ---: |
| Native sixteen checks | 31,750,144 | 845,306,615 |
| Cached sixteen-candidate batch | **4,476,928** | **163,683,594** |
| Prefix160 plus native survivors | 18,724,608 | 227,918,645 |
| Prefix176 plus native survivors | 16,549,888 | 215,773,495 |

The second column is an **observed operand-size proxy**, computed from the exact integers passed into the original reciprocal recurrence. It measures multiplication count and operand bit widths, not the actual dynamic native integer multiplication instruction count or wall-clock cost of each operation. The call-multiplicity identity is kernel-proved in [MathCan NOR-18R PR #98](https://github.com/patrickdugan/MathCan/pull/98): eight native R inversions per public demonstration from U/V, plus sixteen more when the fixed base is R, versus one cached R inversion.

Caching uses **more temporary Python allocation** in these source-locked tests, with median independently measured \`tracemalloc\` peaks of 128.2 KiB versus 74.1 KiB for the native repeated checker. Isolated-worker maximum RSS was 29,364 KiB for every mode, with no measurable rise over that worker's fixture-loaded baseline. That process-level peak does not resolve the temporary Python allocation difference; it also excludes the cost of loading source files on a fresh machine.

NOR-18's arithmetic proxy predicted a cached-work benefit. NOR-18R establishes that the specifically tested CPython implementation also runs faster on this original held-out source subset, while revealing an allocation tradeoff. Generalization to a fresh source generator, other Python versions, different CPU microarchitectures, GPU implementations or production proof tasks remains to be tested.

### Independently reproduce the frozen evidence

\`\`\`sh
python research/nor18r_runtime/receipt_audit.py --check \
--archive research/nor18r_runtime/results/nor18r_original_hosted.zip
\`\`\`

The complete archived fixture deliberately excludes all withheld query-output labels and planted program identities. It is suitable for independent public-only verifier microbenchmarks without unsealing NOR-18's future truth.
Loading
Loading