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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
work/
*.so
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"function_sha256": "b05f469b8a6fe9a725ac59ba0e6171e86a4906c8929883a54862cf9b2605c6e4",
"boundary": "after all ten probe correctness controls; before fixed timing arms",
"module_sha256": "ad34e00ad7d0a9f192f4e3e89b1b7cc3b45d27d10063fa2dc1937e101cf60c09"
}
11 changes: 11 additions & 0 deletions research/fraction-native-score-dispatch-feasibility/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Fraction arithmetic primitive profile and bounded contribution-table feasibility
============================================================================
Original Fraction/error arithmetic: Ali Romman, retaining Adam Gall/ywz65/PR2878, PR5826/5819, Mason Hale/PR5811 and all P104/native/compiler/precision notices. Full PR5848, PR5831 and nested source archives are unchanged. Apache-2.0.

New primitive profiling, exact local table, finite/key/capacity/failure checks and complete-cost screen: Chris R / Clear1nsight, substantial OpenAI Codex assistance; no subagents or independent human/kernel acceptance. Memoization is a standard technique. PR5848/5839 supply the qualifier/Linux baseline; PR5816/5818/5832/5761 retain tooling and test-repair credit with original authorship. The prior zero/unit negative artifact71f22c77b393e5cc14925c771894dc1a92c8443c supplies source-binding and finite-fixture lineage. No complete performance or kappa improvement is claimed.

Source-bound entry type gate: Chris R / Clear1nsight with substantial OpenAI Codex assistance; no independent human or proof-kernel acceptance. Parent table/finite bytes retained exactly from df9dc4c89b31494f1390d16b9ca2a15e5946e853 (PR5852). Publication agents handled only earlier branches, not this scientific test.

Native cache/context, source-bound slot/compact-key integration and complete cold-build qualifier: Chris R / Clear1nsight with substantial OpenAI Codex assistance and GPT-6-astra xhigh static review. The original Fraction miss arithmetic and independent exact integer engine are unchanged. C API/reference-counting/memoization are standard techniques. Preserve all inherited authors and Apache-2.0 notices. The C helper is new code; it does not port CPython arithmetic. Local measured timings are not a universal speedup or hosted performance validation. No kappa claim.

Scoped native score-dispatch probe: Chris R / Clear1nsight with substantial OpenAI Codex assistance; Astra static nomination/stop review only. Original Python Fraction._add is called, not ported. No new complete or kappa gain. Parent native/source authorship retained. Apache-2.0.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
for(int k=0;k<3;k++){
PyObject *score=PyList_GetItem(scores,k);
if(!score)goto fail;
Py_INCREF(score);
PyObject *next=PyNumber_InPlaceAdd(score,PyTuple_GET_ITEM(result,k+1));
Py_DECREF(score);
if(!next)goto fail;
if(PyList_SetItem(scores,k,next)<0)goto fail;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sha256": "ac5d282405e74f1f8cc4cddb768485709057d249dae370a16c063ab45327c2ea",
"parent_native_sha256": "78ed2e240ee40ce4989a4718e77e8b3967b092d2bf8c900124a26942c98a14cb",
"parent_loop_sha256": "b3dfa3aadae31d008309bc91fae06fab3aef86dd899dcbc34156cdff835d91e0",
"source_seam": "Exact retained parent three-score loop; only direct arm changes PyNumber_InPlaceAdd selection, with exact type guards and separate counts."
}
11 changes: 11 additions & 0 deletions research/fraction-native-score-dispatch-feasibility/PROOF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Scope of the finite probe and stopping rule

The prototype copies the literal three-score C loop from authenticated PR5864 source. The generic arm preserves each checked score retrieval, owned reference, PyNumber_InPlaceAdd, decref and stealing list store. The direct arm changes only call selection at these sites, requiring both operands to be exactly the supplied Fraction class before vectorcalling the existing bound Python kernel. Other operands retain generic augmented assignment. Direct errors propagate without retry, with already completed score stores preserved. Both loops retain owned score references and checked stores around callbacks; immutable tuple arguments own the increments throughout the call.

The checked wrapper binds the original existing Fraction addition code/closure/globals, constructor helpers and relevant MRO entries, with trace-entry freshness. Stable qualified runtime/operands are semantic premises. Raw packet type checks alone do not certify an arbitrary supplied function. The 33 prefix cases compare every complete score/type with ordinary Python addition, and ten controls test the native branch and error/fallback boundaries. These are finite probe checks; no full Cache/Event caller or all-input native proof is asserted.

The registered verifier authenticates the complete parent archive and literal source loop, binds the live measured probe function to its unchanged source, and truncates only at the unique boundary after all ten controls and before any timing. Thus fresh finite replay repeats every probe correctness assertion while the historical timing observations remain evidence, not a flaky test condition. The probe source, C source, binder, shapes and all original observations are retained.

The declared decision rule asks whether conservative illustrative gross saving can cover a nonnegative incremental full validation/build bill plus observed complete-parent variability. Its retained smaller-pair illustration is 0.187220978 wall / 0.187227513 CPU seconds, below the parent complete ranges 0.460568479 / 0.45. Even setting the unbuilt additional bill to zero gives negative margins. This justifies a scoped engineering stop before further integration. Synthetic scaling is not a true-gain upper bound, so this is not an impossibility theorem or a claim that a different benchmark cannot perform better.

All four timing samples, their source inventory, cold build bill, raw narrower PASS status, the 33-versus-32 prose correction and the direct arm's per-add counter cost remain. A source reviewer independently checked receipt arithmetic but ran no numerical experiment. No performance sample was rerolled or discarded, and no work was added to the frozen successful PR5864 implementation.
44 changes: 44 additions & 0 deletions research/fraction-native-score-dispatch-feasibility/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Scoped stop for a native Fraction score-dispatch probe

A fixed native B,C,C,B micro passes 33 prefix comparisons and ten functional/source-binding controls, and both paired micro comparisons improve. Its smaller paired difference illustrates only **0.187221 wall / 0.187228 CPU seconds** when scaled to the frozen 7,739,250 score-addition sites. This is below PR5864's observed complete candidate ranges of **0.460568 wall / 0.45 CPU seconds**, before any new full validation cost. Stop before full-control integration, actual audit or complete construction.

This is an engineering screen for this probe, not a bound on true native gain, a universal obstruction or a measured complete saving. [PR #5864](https://github.com/CrocSwap/integer-mult-bounds/pull/5864)'s validated 19.12% wall / 18.82% CPU improvement remains unchanged. Kappa research stays paused.

## Question and source boundary

Can calling the existing, authenticated Python Fraction._add directly from C pay its additional complete verification cost? The exact parent three-score loop is retained from PR5864 head `3f15c943e4ad6479f03e674c80fff1269a16ccfe`; the full official export is authenticated before finite replay. The direct arm adds exact operand-type guards, vectorcall to that same Python arithmetic routine and per-add dispatch counters. The generic arm retains PyNumber_InPlaceAdd and reports an aggregate count at exit. This counter asymmetry is paid in the measured probe and limits its interpretation.

The actual native Cache/Event integration is not built. No new rational arithmetic, independent backend, fixture or accepted caller is introduced. The probe demonstrates only its declared native score-loop controls, not all original qualification obligations. The retained prior binder checks executable shapes, closure/global/MRO state and identity-only freshness; it refuses unknown runtime bindings without invoking foreign descriptors.

## Fixed observations and stop

Sixteen fixed increment triples cover zeros, signs, cancellation, common/coprime denominators and 128-bit numerators. Each arm runs 32,768 groups / 98,304 additions with fresh scores, in B,C,C,B order. Prefix comparisons and controls run before timing. All samples are retained:

| Arm | Wall seconds | CPU seconds |
| --- | ---: | ---: |
| B1 | 0.083361725 | 0.082788980 |
| C1 | 0.067125316 | 0.067122706 |
| C2 | 0.067535516 | 0.067539532 |
| B2 | 0.069913598 | 0.069917697 |

The smaller paired difference is 0.002378082 wall / 0.002378165 CPU seconds. Illustrative scaling gives the 0.187-second figures above. Assuming an optimistically zero additional validation bill, its margin against the recorded complete-parent range is **−0.273348 wall / −0.262772 CPU seconds**. The prescribed conservative screen fails. No extra timing permutation, dropped sample, actual replay or larger construction follows. The raw micro status remains `MICRO_PASS_REQUIRES_FULL_INCREMENTAL_COST_BILL`: its narrower functional/timing predicates passed; the later complete-cost screening rule stopped expansion.

One scientific command cost 0.710 seconds wall, including cold C compilation, with no stderr and unchanged source bytes/modes. No automatic retry. The original 180-second command / 1 GiB sampled group RSS / 600-second initial / 1,500-second shared round limits remain. A first packaged finite replay rejected source authentication before native execution: compiling an isolated function changed its imported-module call opcodes. Complete-module source authentication and truncation preserve the compilation context; fresh normal/O finite replays pass, and the failed draft/receipt remain. No timing was repeated. The initial plan said 32 prefix comparisons; actual code includes the zero prefix and tests all 33 prefixes 0 through 32. This extra zero case and the counter asymmetry are documented without rerunning or inventing savings credit.

## Reproduction and coverage

```sh
python3 -B scripts/research_package.py --package research/fraction-native-score-dispatch-feasibility
```

Registered replay freshly compiles the probe and executes all 33 prefix comparisons and ten functional/binding controls, without repeating timings or asserting that a new host must reproduce the historical stop. It authenticates the complete parent archive, native source and literal score-loop boundary. Tested with Linux CPython 3.12.3 / GCC 13.3; existing `cc` and Python development headers are required. No install or silent native skip.

The ten controls cover complete prefix values/types and branch counts, nonexact/custom and Fraction-subtype generic augmented assignment, nonexact increments, direct exceptions without retry and exact partial-update order, callback list mutation, invalid kernel packets, live kernel / present-None-iadd drift and complete runtime restoration.

The original PR5864's 964 comparisons / 118 controls and complete qualification were not repeated in this rejected extension; their measured/published implementation is untouched. The planned 19 prior dispatch controls and new Cache/Event lifetime integration were not executed because the earlier screen did not justify that construction. Do not describe this probe as preserving a newly integrated complete caller. See [SCREEN.json](SCREEN.json), [PROOF.md](PROOF.md) and retained evidence.

## Open next questions

No further measured continuation is justified in this round. A separately proposed mechanism needs its own source/ownership/coverage/cost argument and a new fixed feasibility gate. Constructor-elision and descriptor-metadata ideas retain unpriced obligations; this stop does not exclude them or other future work. Keep the successfully measured PR5864 frozen while it is reviewed.

Chris R / Clear1nsight with substantial OpenAI Codex assistance; GPT-6-astra xhigh performed static nomination/stop review only and no compiler or numerical work. Original arithmetic remains Python Fraction and all credited Ali Romman/P104/native/tooling predecessors. Standard dispatch/C API techniques. Apache-2.0; no kappa, merge or selected-frontier change.
17 changes: 17 additions & 0 deletions research/fraction-native-score-dispatch-feasibility/RESULT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"prefix_cases": 33,
"controls": [
"all-33-prefix-values-types-and-branches",
"nonexact-custom-score-generic-iadd",
"Fraction-subtype-generic-iadd",
"nonexact-increment-generic",
"direct-error-no-retry-partial-update-order",
"callback-score-list-mutation-safe",
"nonfunction-kernel-packet-rejected",
"kernel-binding-drift",
"present-none-iadd-drift",
"runtime-restored-before-timing"
],
"control_count": 10,
"runtime_current": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"functions": {
"__add__": "896b59b7df8e862396d6d7a2702cb7d70b0272fcb925d6f2eb05185a7538ddb0",
"__radd__": "6c3aec85f1cd6d3625edbc271d34714cb5760d8f1bfa8f8946c238760ea394fd",
"_add": "cd655a8ed6164c9e64d6fbaff8c41407b55d583d0327c9a889f0d4bfb30d24b1",
"__mul__": "896b59b7df8e862396d6d7a2702cb7d70b0272fcb925d6f2eb05185a7538ddb0",
"_mul": "fddb7b00e5a1935b50177847fed06d5be9b0e98a88b7b03168e39b7058fcaef5",
"__abs__": "97fd3b7adf132814a9c1e7046ca724af66e814c365e0e6f0b315c577e3eb1ffe",
"__neg__": "7e3ea316de290d2c079d2b638791708174d983db9bdbbb673eda15e4f37477de",
"__new__": "d4c031bbaf8cab747dc194b04b157ba1d4c2235f9bbc0048d72801fffc4f4b85",
"_from_coprime_ints": "e8b9a62eb272ce89e2433eaa70feb9eb29193f4895a3e9d5eb11731f3c848baa",
"__sub__": "896b59b7df8e862396d6d7a2702cb7d70b0272fcb925d6f2eb05185a7538ddb0",
"_sub": "17df3425c308b7395d2f9b4d2941ba5c4fe7eb316e880c62a00903cc568bee34"
},
"reference_module_sha256": "cf33568f7b767f66896995a7a81cc662e8be226f2e58efb61d2028f64eb5d231",
"policy": "Known executable shapes, live closures/globals and full MRO bind the direct path; unsupported runtime uses unchanged generic +=. Source file hash recorded, not sufficient alone."
}
138 changes: 138 additions & 0 deletions research/fraction-native-score-dispatch-feasibility/SCREEN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"decision": "STOP_NATIVE_DIRECT_ADD_BEFORE_ACTUAL_OR_COMPLETE_CONSTRUCTION",
"micro": {
"additions_per_arm": 98304,
"build": {
"SOABI": "cpython-312-x86_64-linux-gnu",
"binary_sha256": "2539108f782328dcf75f477e6fa085235fa42a327743c97c1c16a4397c67ec95",
"cold_build_load_wall_seconds": 0.1481919409998227,
"compiler": "/usr/bin/cc",
"compiler_cpu_accounting": "outer GNU time user+system includes compiler children",
"compiler_version": "cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0",
"extension_suffix": ".cpython-312-x86_64-linux-gnu.so",
"flags": [
"-O2",
"-shared",
"-fPIC",
"-std=c11",
"-Wall",
"-Werror",
"-I/usr/include/python3.12"
],
"python": "3.12.3 (main, Aug 31 2026, 10:18:26) [GCC 13.3.0]",
"source_sha256": "ac5d282405e74f1f8cc4cddb768485709057d249dae370a16c063ab45327c2ea"
},
"control_count": 10,
"controls": [
"all-33-prefix-values-types-and-branches",
"nonexact-custom-score-generic-iadd",
"Fraction-subtype-generic-iadd",
"nonexact-increment-generic",
"direct-error-no-retry-partial-update-order",
"callback-score-list-mutation-safe",
"nonfunction-kernel-packet-rejected",
"kernel-binding-drift",
"present-none-iadd-drift",
"runtime-restored-before-timing"
],
"fixed_order": "BCCB",
"groups_per_arm": 32768,
"illustrative_gross_only": {
"cpu_seconds": 0.18722751338958643,
"wall_seconds": 0.18722097821499695
},
"no_actual_or_complete_construction": true,
"not_a_full_trace_projection_or_improvement": true,
"observations": [
{
"counts": [
0,
98304
],
"cpu_seconds": 0.08278898000000001,
"label": "B",
"terminal_scores": [
"2/3",
"-5/7",
"11/13"
],
"wall_seconds": 0.08336172500276007
},
{
"counts": [
98304,
0
],
"cpu_seconds": 0.06712270600000003,
"label": "C",
"terminal_scores": [
"2/3",
"-5/7",
"11/13"
],
"wall_seconds": 0.06712531601078808
},
{
"counts": [
98304,
0
],
"cpu_seconds": 0.06753953200000001,
"label": "C",
"terminal_scores": [
"2/3",
"-5/7",
"11/13"
],
"wall_seconds": 0.06753551599103957
},
{
"counts": [
0,
98304
],
"cpu_seconds": 0.069917697,
"label": "B",
"terminal_scores": [
"2/3",
"-5/7",
"11/13"
],
"wall_seconds": 0.06991359798121266
}
],
"paired_differences": {
"cpu_seconds": [
0.01566627399999998,
0.0023781649999999876
],
"wall_seconds": [
0.016236408991971985,
0.0023780819901730865
]
},
"runtime_current": true,
"status": "MICRO_PASS_REQUIRES_FULL_INCREMENTAL_COST_BILL"
},
"comparison_model": {
"gross": "Conservative smaller paired micro difference, illustratively scaled to source score count; not a bound on true actual saving.",
"additional_cost_assumed_seconds": 0,
"additional_cost_scope": "Optimistically zero to reject further expansion without building/measuring the full additional control union.",
"parent_complete_C_spread": {
"wall_seconds": 0.4605684790003579,
"cpu_seconds": 0.45000000000000284
},
"modeled_margin_before_any_new_cost": {
"wall_seconds": -0.27334750078536096,
"cpu_seconds": -0.2627724866104164
}
},
"why": "Even zero-cost illustrative saving fails the prespecified observed full-parent spread in wall and CPU. Both micro pairs improve but evidence does not justify further expansion. No timing reroll or sample omission.",
"not_a_universal_obstruction": true,
"not_a_complete_measurement": true,
"no_new_kappa": true,
"actual_audits": 0,
"complete_candidates": 0,
"scientific_command_count": 1,
"guarded_wall_seconds": 0.709715356992092
}
Loading