# sig-typ-cells: eik_sigmoid Thumb main cells (thumbv6m) **Outcome: threshold NOT reached. No kept change.** The best entry for this lever is still the unchanged base: former-50 `entry.c`, sha256 `88617bb49e36a06cabd7d84ce6fe504ee337f8f41ad7c55bc72f696db94060c3`. `patch.diff` against the base is **empty**. Sigmoid typical mean stays at 37.77 to 38.03, against a success bar of 33.5. My one change family (moving `ldr rX,[pc]` literal constants into the cell-descriptor structs the hot path already loads with `ldm`) made every seed worse by about 2.5% S. I discarded it. Below: a profile of where the typical path spends its instructions, the failed trial with its cause, and ranked next steps. Per the brief, only `result.md` and `sources.json` are written. The entry file, the empty diff, the measure JSONs and the check logs are summarised in tables here instead of being shipped as separate files, because nothing else under `artifacts/` is uploaded. ## Environment (deviations from the brief: read before reusing the numbers) - Kit: conjectures-io/exact-integer-kernels-miner at `5a32428ad4aa23bce737d50a738ace24ddeeed2e`. `python -m eik setup` passed: "incumbent registered as champion of rv32im, thumbv6m, overall". - The machine has Python 3.10, no pip, no gcc and no qemu. I installed the pinned wheels (capstone 5.0.9, pyelftools 0.33, unicorn 2.1.4, ziglang 0.17.1) by unzipping them from PyPI into a `--without-pip` venv. The host compiler is `EIK_HOST_CC` = a wrapper around the kit's own `zig cc` (clang), not gcc. I used `EIK_SANDBOX=none`, so the run was in development mode. - **The measurement fingerprint here is `7c2a5228d224fa27854167534f675b3935eaea87ffe0972918fd90d16d0c6f55`, not the brief's `2c8fd1f3…46322`.** The verifier fingerprint is `230455734706b4531deab27e4303e5d605faa3a2e38507d9a4fcb98607f68baa`. The likely cause is the host compiler or sandbox difference; this is UNVERIFIED. Target objects are built by the pinned zig clang either way. My base thumbv6m S (40.36 / 40.37 / 40.06) and bytes (20,500) agree with the brief's former-50 figures (S 40.43, bytes 20,500). - `eik targetcheck` could not run: "qemu-arm is not installed (QEMU user mode)". **The thumbv6m object-code check is UNVERIFIED.** No function was changed, so this only affects the base, which the earlier job already checked. ## Results table (thumbv6m unless noted; `measure --targets thumbv6m,rv32im --no-sample`) | entry | seed | base S | new S | ratio | T bytes | rv32im S / bytes | sig typical | sig wide | sig hard | sig uniform | inputs_sha256 | |---|---|---|---|---|---|---|---|---|---|---|---| | base (= final) | 1001 | 40.3574 | 40.3574 | 1.00000 | 20500 | 28.4863 / 18960 | 37.767 | 28.619 | 47.747 | 18.504 | 8a9501910893 | | base (= final) | 2002 | 40.3698 | 40.3698 | 1.00000 | 20500 | 28.5180 / 18960 | 37.870 | 29.139 | 46.940 | 18.633 | 4725e74fc7c6 | | base (= final) | 3003 | 40.0637 | 40.0637 | 1.00000 | 20500 | 28.2202 / 18960 | 38.031 | 29.578 | 45.450 | 18.468 | 74546119d2ab | | e1 (rejected) | 1001 | 40.3574 | 41.3781 | 1.02529 | 20536 | 28.4863 / 18960 | 40.723 | 30.880 | 49.860 | 20.748 | 8a9501910893 | | e1 (rejected) | 2002 | 40.3698 | 41.3900 | 1.02527 | 20536 | 28.5180 / 18960 | 40.837 | 31.418 | 49.053 | 20.911 | 4725e74fc7c6 | | e1 (rejected) | 3003 | 40.0637 | 41.0716 | 1.02516 | 20536 | 28.2202 / 18960 | 40.998 | 31.865 | 47.527 | 20.730 | 74546119d2ab | | e2 (rejected) | 1001 | 40.3574 | 41.4595 | 1.02731 | 20544 | 28.4863 / 18960 | 41.020 | 30.985 | 49.923 | 21.003 | 8a9501910893 | | e2 (rejected) | 2002 | 40.3698 | 41.4723 | 1.02731 | 20544 | 28.5180 / 18960 | 41.147 | 31.519 | 49.107 | 21.161 | 4725e74fc7c6 | | e2 (rejected) | 3003 | 40.0637 | 41.1517 | 1.02715 | 20544 | 28.2202 / 18960 | 41.298 | 31.971 | 47.573 | 20.978 | 74546119d2ab | | e3 (rejected) | 1001 | 40.3574 | 41.4984 | 1.02827 | 20552 | 28.4863 / 18960 | 41.194 | 31.018 | 49.930 | 21.006 | 8a9501910893 | | e3 (rejected) | 2002 | 40.3698 | 41.5083 | 1.02820 | 20552 | 28.5180 / 18960 | 41.312 | 31.543 | 49.113 | 21.169 | 4725e74fc7c6 | | e3 (rejected) | 3003 | 40.0637 | 41.1939 | 1.02821 | 20552 | 28.2202 / 18960 | 41.487 | 32.013 | 47.583 | 20.982 | 74546119d2ab | Other base thumbv6m per-class means (seeds 1001 / 2002 / 3003): - tanh typical 37.072 / 36.884 / 36.958; wide 20.642 / 20.803 / 19.867; hard 76.370 / 71.950 / 67.507. - exp typical 42.824 / 42.928 / 43.012; wide 34.677 / 34.483 / 34.088; hard 57.367 / 60.147 / 56.587. All tail factors are 1.0. Takeover threshold 0.939x and internal goal 0.935x: **not met. The best ratio is 1.00000, the base itself.** ## Checks (on the final file = base) - `eik check`: PASS. Functions 42; bytes rv32im 18960, thumbv6m 20500, thumbv7em 21254; stack_bound rv32im 176, thumbv6m 312, thumbv7em 280. - `eik fullcheck --function sigmoid` (all 2^32 inputs, ASan+UBSan, host = zig clang): passed. Mismatches 0, words_checked 4294967296, complete true, 44.2 s. - `eik fullcheck --quick` tanh: passed, 0 mismatches over 134,217,728 words. exp: the same. - `eik targetcheck --target thumbv6m`: **NOT RUN** (no qemu-arm). UNVERIFIED. - The rejected trials e1/e2/e3 passed `measure`'s verdict, but were not full-checked because they were dropped for speed. ## Instruction-count notes (base, thumbv6m, 6000 typical sigmoid inputs from seeds 1001+2002+3003) I counted with the kit's own `emu.Core` block hook, which is the same counter as `measure`, and added per-address hit counts. Mean over the 6000 inputs: 37.89. Counts by input range: | input range | share of typical | instructions | path in `t_eik_sigmoid` | |---|---|---|---| | +[0.25, 2) | 25.4% | 32 | `t_skl` cells, `(k-w)>>16` index | | -(2, 0.25] | 24.9% | 32 to 36 | same `t_skl` code via `(t_s>>12)&0x1FF0`; result split on the sign of Y | | +[2, 13.4) | 20.5% | 36 | `t_skp`: `t_epn2` cells. The dispatch `lsls;bmi;cmp r0,#0;bmi` comes before it; the return loads a literal `0x3f400001` | | -[2, 3.42) | ~11% | 38 to 45 | `t_skn` `t_epn2` cells, two result binades | | -[3.42, 6.94] | ~9% | 45 to 49 | `t_sk2`/`t_crows` "cbank" cells: 3 multiplies and an extra index multiply (`muls r1,r3,r1` by stride 12) | | -(6.94, 16] | ~0.8% | 76 to 88 | falls to the exp-based `t_l724981` path (`t_dka`) | | ±[2^-4, 2^-2) | ~7% | 42 to 45 | dispatch `cmp #125; cmp #115; cmp #121` and then the `t_skm` path | | \|x\| < 2^-4 | ~2.5% | 36 to 37 | short linear path | What the floor costs: - Every call pays the prologue `push {r4,r5,r7,lr}; add r7,sp,#8` (frame pointer) and the dispatch `lsls r1,r0,#1; bmi`. - The 32-instruction cell path has 3 multiplies, one `ldm` of 3 words, a 3-instruction rounding test (`lsls #23; lsrs #25; bne`) and `asrs; adds; pop`. - No `__aeabi_*` calls, spills or 64-bit multiplies appear on any typical path in the base. ## Trial and why it failed (e1/e2/e3) - **Idea.** Instruction count is per instruction, so a 3rd or 4th register in an existing `ldm` is free. The trial added a field to each descriptor and used it in place of the C constant: - e1: `t_sj.t_h = 0x3f400001u` for the `t_skp` return. - e2: also `t_sn.t_h1/t_h2 = 0x3E000001u/0x3D800003u` for the `t_skn` returns. - e3: also `t_s2k.t_h = 0x3A800001u` for the cbank return. - The dead-branch aliasing (`t_w*t_w==5`) stops clang from folding these back into literals. - **Expected gain.** Removing one `ldr` on about 2,788 of 6,000 inputs, about -0.46 instructions. - **Actual.** +3 instructions on every path. Clang moved `t_eik_sigmoid` to `push {r4,r5,r6,r7,lr}; add r7,sp,#0xc; sub sp,#4`. That is a new stack frame, which the brief warns about. It also routed returns through a shared epilogue with extra `b` instructions. The function is at the six-low-register limit of Thumb-1, and any extra value live across the dispatch costs more than a literal load. Rejected. - **RV32 side.** In all trials, rv32im S and bytes stayed identical and the RV `.text` and `.rodata` sections were byte-identical. The rv32im image sha256 still changed, because `.symtab`, `.strtab` and `.rela.debug_line` changed. A merge that requires the RV image hash to be identical, not just code and tables, must account for that. ## Next steps (ranked by estimated typical gain; none implemented or checked) 1. **Extend the cbank or epn2 cells over -[6.94, 16].** This takes out the 76 to 88 instruction exp-fallback path for about 0.8% of typical inputs, worth about -0.35 instructions. It also helps wide. It needs a new table (about 12 B per cell × 2^16-ulp cells; the size cost is 0.58% per KiB) and a full 2^32 recheck. 2. **Replace the cbank's index multiply in -[3.42, 6.94] (about 9%).** Use a 16-byte stride (`lsls`) instead of `muls` by 12, and/or a 2-multiply form, to bring it to about 40 instructions. Worth about -0.5 to -0.8. A table re-layout costs about 4 B per cell. 3. **Single-binade result encoding for -[2, 3.42] and for x ≥ 2.** Store `1-σ` scaled so that the `Y<0 / Y≥0` and `m6` sign splits disappear. Worth about -0.3 to -0.6. 4. **Fold the ±[2^-4, 2^-2) cells into the `t_es≥125` cell table** by lowering `t_skl`'s coverage to `t_es≥122`. This drops two dispatch compares for about 7% of inputs, worth about -0.3, but needs about 3 more binades of cells. 5. **Do not reorder the `t_es` compare chain.** Wide inputs (30% weight) land mostly on `t_es<116`, so a reorder costs more on wide than it gains on typical. Even together, steps 1 to 4 are estimated at about -1.5 to -2.2 instructions (to about 35.7 to 36.4), still short of 33.5. Getting to 33.5 would need the 32-instruction cell path itself to shrink, or the negative half to share it. Each table change must keep register use at or below r0 to r5 plus r7, or it pays the frame cost seen in e1. ## Reproduction Run `python -m eik measure base.c --seed {1001,2002,3003} --targets thumbv6m,rv32im --no-sample` with `EIK_HOST_CC` pointing at a `zig cc` wrapper (from the ziglang 0.17.1 wheel) and `EIK_SANDBOX=none`. The profile used the kit's `eik.emu.Core` with a block-hit counter over `eik.inputs.draw(seed,"sigmoid")["typical"]`.