Skip to content

Commit 12120b8

Browse files
Add power-of-two FFT323161 lead caching
1 parent 845c5fc commit 12120b8

29 files changed

Lines changed: 674 additions & 36 deletions

MANIFEST_NATIVE_PFA.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"root": "PrMers-v99.73-Aevum-PFA9-Force-Adaptive-exp11",
3-
"version": "4.20.67-alpha-v99.73-aevum-pfa9-force-adaptive-exp11",
4-
"feature": "force-adaptive explicit type-4 PFA9 requests with full-path diagnostic escape",
5-
"file_count": 422,
2+
"root": "PrMers-v99.74-Aevum-Pow2-Type4-LeadCache-exp12",
3+
"version": "4.20.68-alpha-v99.74-aevum-pow2-type4-lead-cache-exp12",
4+
"feature": "explicit power-of-two FFT323161 with deferred LEAD_WIDTH/carryFused register squaring",
5+
"file_count": 432,
66
"files": [
77
".github/workflows/build_linux.yml",
88
".github/workflows/build_mac_os.yml",
@@ -14,12 +14,15 @@
1414
"LICENSES/PrMers-MIT.txt",
1515
"LICENSES/README.md",
1616
"MANIFEST_NATIVE_PFA.json",
17+
"MODIFICATIONS.md",
1718
"Makefile",
1819
"NOTICE.md",
1920
"README.md",
2021
"README_AEVUM_REG.md",
2122
"README_NATIVE_AEVUM_PFA.md",
23+
"README_POW2_TYPE4_LEAD_CACHE.md",
2224
"README_TYPE4_PFA9.md",
25+
"RELEASE_EXP12.md",
2326
"build_and_test_native_pfa_ubuntu.sh",
2427
"chainpm1.sh",
2528
"chainpm1old.sh",
@@ -91,6 +94,7 @@
9194
"kernels/marin.cl",
9295
"kernels/prmers.cl",
9396
"prmers.ipynb",
97+
"scripts/bench_pow2_type4_ubuntu.sh",
9498
"scripts/benchmark_aevum_vs_marin.sh",
9599
"scripts/build_native_pfa.sh",
96100
"scripts/build_native_pfa_ubuntu.sh",
@@ -154,6 +158,7 @@
154158
"tests/aevum_apple_fused_tailsquare_test.py",
155159
"tests/aevum_fake_engine.cpp",
156160
"tests/aevum_pm1_small_factor_policy_test.py",
161+
"tests/aevum_pow2_type4_source_test.py",
157162
"tests/aevum_vtrace_prepared_cache_test.py",
158163
"tests/apple_strict_smoke_source_test.py",
159164
"tests/macos_default_marin_policy_test.py",
@@ -199,6 +204,7 @@
199204
"third_party/aevum/README_GPUOWL.md",
200205
"third_party/aevum/README_GPUOWL_LEGACY.txt",
201206
"third_party/aevum/README_NATIVE_PFA.md",
207+
"third_party/aevum/README_POW2_TYPE4_LEAD_CACHE.md",
202208
"third_party/aevum/README_TYPE4_PFA9.md",
203209
"third_party/aevum/SP/Gpu.cpp",
204210
"third_party/aevum/SP/Gpu.h",
@@ -226,6 +232,7 @@
226232
"third_party/aevum/scripts/check_macos_minos.sh",
227233
"third_party/aevum/scripts/install_ubuntu_dependencies.sh",
228234
"third_party/aevum/scripts/test_native_pfa_gpu.sh",
235+
"third_party/aevum/scripts/test_pow2_type4_lead_cache_ubuntu.sh",
229236
"third_party/aevum/scripts/test_type4_pfa9_ubuntu.sh",
230237
"third_party/aevum/src/AllocTrac.cpp",
231238
"third_party/aevum/src/AllocTrac.h",
@@ -391,6 +398,7 @@
391398
"third_party/aevum/tests/apple_readchecked_double_sync_test.py",
392399
"third_party/aevum/tests/check_macos_minos.sh",
393400
"third_party/aevum/tests/engine_api_load_test.cpp",
401+
"third_party/aevum/tests/engine_lead_cache_test.py",
394402
"third_party/aevum/tests/engine_small_factor_gpu_test.cpp",
395403
"third_party/aevum/tests/fft3161_exact_plan_test.py",
396404
"third_party/aevum/tests/gpu_init_order_test.py",
@@ -401,6 +409,8 @@
401409
"third_party/aevum/tests/opencl12_syntax_test.sh",
402410
"third_party/aevum/tests/opencl_monolithic_source_test.cpp",
403411
"third_party/aevum/tests/opencl_standard_test.cpp",
412+
"third_party/aevum/tests/pow2_type4_lead_cache_compare.cpp",
413+
"third_party/aevum/tests/pow2_type4_opencl_syntax.sh",
404414
"third_party/aevum/tests/run_aevum_apple_plane_isolation_v5.sh",
405415
"third_party/aevum/tests/run_aevum_apple_stage_trace_v4.sh",
406416
"third_party/aevum/tests/source_audit.sh",

MODIFICATIONS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## v99.74 power-of-two FFT323161 + PRPLL-style lead cache
2+
3+
- accepts explicit non-PFA FFT323161 plans, including `4:512:8:512:202`;
4+
- embeds Aevum v0.3.67;
5+
- preserves consecutive PRP squarings in `LEAD_WIDTH` state through the register adapter;
6+
- flushes the one pending final square before every externally visible register operation;
7+
- keeps PFA and Apple on their validated canonical paths;
8+
- adds exact cached-versus-canonical GPU comparison and benchmark scripts.
9+

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ test-gui-state:
118118
bash tests/test_web_gui_backend_state.sh
119119

120120
test-aevum-source:
121+
python3 tests/aevum_pow2_type4_source_test.py
121122
bash tests/source_aevum_engine_audit.sh
122123

123124
test-backend-compat: all

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,3 +1175,11 @@ PrMers is developed by cherubrock-seb, with feedback and contributions from user
11751175
- A forced Aevum request falls back to Marin only when no admissible FFT3161 plan exists, and the log states the reason explicitly.
11761176
- The one-register P-1 ultra-low-memory algorithm is the sole Marin-only path because it depends on Marin `fast3`; Auto selects Marin and forced Aevum exits cleanly before GPU allocation.
11771177
- PRP/LL checkpoints now include backend and mode metadata. Legacy untagged checkpoints are not loaded into Aevum, and LL-safe, LL-safe2 and LL-unsafe use distinct filenames.
1178+
1179+
### Power-of-two FFT323161 lead cache in v99.74
1180+
1181+
The exact plan `4:512:8:512:202` is now accepted by Aevum. Consecutive
1182+
`engine::square_mul(reg, 1)` calls use a one-square pending scheduler so the
1183+
GPU retains `LEAD_WIDTH` and upstream `carryFused` between iterations. See
1184+
`README_POW2_TYPE4_LEAD_CACHE.md` for validation and A/B commands.
1185+

README_POW2_TYPE4_LEAD_CACHE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# PrMers v99.74 — power-of-two FFT323161 + register lead cache
2+
3+
This release enables the exact upstream-style power-of-two plan:
4+
5+
```text
6+
4:512:8:512:202
7+
```
8+
9+
for `M175000039`. It is the same 4M-word FFT323161 family used by PRPLL:
10+
FP32 + GF31 + GF61, variant 202. Previous PrMers/Aevum builds rejected this
11+
non-PFA type-4 plan and therefore compared an 8M FFT3161 plan against PRPLL's
12+
4M FFT323161 plan.
13+
14+
The register adapter now also preserves upstream PRPLL's hot squaring chain.
15+
One logical `square_mul(reg,1)` is held pending; consecutive calls execute the
16+
previous square with `LEAD_WIDTH`, and a read/copy/checkpoint/sync emits the
17+
final square with a canonical boundary. This restores `carryFused` between
18+
ordinary PRP iterations without changing the public engine API.
19+
20+
Safety rules:
21+
22+
- enabled only for non-PFA, short-carry plans;
23+
- disabled on Apple, retaining the validated canonical path;
24+
- PFA3/PFA9 remain canonical because native-PFA fused carry is not implemented;
25+
- `AEVUM_REG_LEAD_CACHE=0` restores the previous per-iteration canonical path;
26+
- `AEVUM_TYPE4_MULTI_Q=0` disables type-4 plane overlap for A/B measurement.
27+
28+
Recommended RTX 3080 test:
29+
30+
```bash
31+
./prmers 175000039 -d 1 \
32+
-aevum-fft 4:512:8:512:202 \
33+
-proof 0 -f bench-pow2-type4
34+
```
35+
36+
Expected startup lines include:
37+
38+
```text
39+
FFT: 4M 4:512:8:512:202 (41.72 bpw)
40+
Aevum register lead cache enabled
41+
```
42+
43+
Use `AEVUM_REG_LEAD_CACHE=0` with the same command for the exact canonical
44+
baseline. The package test script also performs a word-exact GPU differential
45+
between the cached and canonical paths before benchmarking.

RELEASE_EXP12.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# exp12 publication commands
2+
3+
## Aevum standalone
4+
5+
```bash
6+
cd /Users/fricadev/dev/aevum-engine
7+
git switch main
8+
git pull --ff-only origin main
9+
git status --short
10+
11+
rsync -av --delete \
12+
--exclude='.git/' --exclude='.DS_Store' \
13+
--exclude='.aevum-kernel-cache/' \
14+
--exclude='build/' --exclude='build-engine/' --exclude='build-tests/' \
15+
--exclude='build-release/' --exclude='build-debug/' --exclude='build-cuda/' \
16+
--exclude='*.o' --exclude='*.d' --exclude='*.so' --exclude='*.dylib' \
17+
/Users/fricadev/Downloads/aevum-engine-v0.3.67-pow2-type4-lead-cache-exp12/ \
18+
/Users/fricadev/dev/aevum-engine/
19+
20+
git status --short
21+
git diff --check
22+
git diff --stat
23+
make test-host
24+
bash tests/native_pfa_opencl_syntax.sh
25+
python3 tests/engine_lead_cache_test.py
26+
27+
git add -A
28+
git diff --cached --check
29+
git diff --cached --stat
30+
git commit -m "Enable power-of-two FFT323161 lead caching"
31+
git push origin main
32+
33+
AEVUM_TAG='v0.3.67-pow2-type4-lead-cache-exp12'
34+
git tag -a "$AEVUM_TAG" -m "Aevum v0.3.67 power-of-two FFT323161 lead-cache release"
35+
git push origin "$AEVUM_TAG"
36+
```
37+
38+
## PrMers
39+
40+
```bash
41+
cd /Users/fricadev/prmerscopy/PrMers
42+
git switch main
43+
git pull --ff-only origin main
44+
git status --short
45+
46+
rsync -av --delete \
47+
--exclude='.git/' --exclude='.DS_Store' \
48+
--exclude='.aevum-kernel-cache/' --exclude='prmers' \
49+
--exclude='build/' --exclude='build-engine/' --exclude='build-tests/' \
50+
--exclude='build-release/' --exclude='package/' \
51+
--exclude='*.o' --exclude='*.d' --exclude='*.so' --exclude='*.dylib' \
52+
/Users/fricadev/Downloads/PrMers-v99.74-Aevum-Pow2-Type4-LeadCache-exp12/ \
53+
/Users/fricadev/prmerscopy/PrMers/
54+
55+
git status --short
56+
git diff --check
57+
git diff --stat
58+
python3 tests/native_pfa_cli_source_test.py
59+
python3 tests/aevum_pow2_type4_source_test.py
60+
make test-aevum-host
61+
make test-aevum-source
62+
make test-aevum-auto
63+
make test-aevum-default
64+
65+
git add -A
66+
git diff --cached --check
67+
git diff --cached --stat
68+
git commit -m "Add power-of-two FFT323161 lead caching"
69+
git push origin main
70+
71+
TAG='v4.20.68-alpha-v99.74-aevum-pow2-type4-lead-cache-exp12'
72+
git fetch --tags --force
73+
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
74+
echo "ERREUR: le tag existe deja" >&2
75+
exit 1
76+
fi
77+
git tag -a "$TAG" -m "PrMers v99.74 power-of-two FFT323161 lead-cache release"
78+
git push origin "$TAG"
79+
80+
gh run list --limit 10
81+
gh run watch
82+
```

include/core/Version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <string>
55

66
namespace core {
7-
const std::string PRMERS_VERSION = "4.20.67-alpha-v99.73-aevum-pfa9-force-adaptive-exp11";
7+
const std::string PRMERS_VERSION = "4.20.68-alpha-v99.74-aevum-pow2-type4-lead-cache-exp12";
88
} // namespace core
99

1010
#endif // VERSION_HPP

scripts/bench_pow2_type4_ubuntu.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
4+
cd "$ROOT"
5+
DEVICE="${1:-1}"
6+
DURATION="${2:-180}"
7+
EXPONENT="${3:-175000039}"
8+
9+
run_bench() {
10+
local name="$1"; shift
11+
local dir="$ROOT/bench-$name"
12+
rm -rf "$dir"; mkdir -p "$dir"
13+
printf '\n===== %s =====\n' "$name"
14+
set +e
15+
timeout -s INT "${DURATION}s" "$@" -f "$dir" 2>&1 | tee "$dir/run.log"
16+
local rc=${PIPESTATUS[0]}
17+
set -e
18+
if [[ $rc -ne 0 && $rc -ne 124 && $rc -ne 130 ]]; then return "$rc"; fi
19+
}
20+
21+
run_bench pow2-type4-lead \
22+
env AEVUM_REG_LEAD_CACHE=1 AEVUM_TYPE4_MULTI_Q=1 \
23+
./prmers "$EXPONENT" -d "$DEVICE" -aevum-fft 4:512:8:512:202 -proof 0
24+
25+
run_bench pow2-type4-canonical \
26+
env AEVUM_REG_LEAD_CACHE=0 AEVUM_TYPE4_MULTI_Q=1 \
27+
./prmers "$EXPONENT" -d "$DEVICE" -aevum-fft 4:512:8:512:202 -proof 0
28+
29+
run_bench pow2-type4-singleq \
30+
env AEVUM_REG_LEAD_CACHE=1 AEVUM_TYPE4_MULTI_Q=0 \
31+
./prmers "$EXPONENT" -d "$DEVICE" -aevum-fft 4:512:8:512:202 -proof 0
32+
33+
run_bench pfa9-type1 \
34+
./prmers "$EXPONENT" -d "$DEVICE" -aevum-fft pfa9:1:512:9:512:202 -proof 0
35+
36+
run_bench pow2-type1 \
37+
./prmers "$EXPONENT" -d "$DEVICE" -pfa-off -proof 0
38+
39+
run_bench marin \
40+
./prmers "$EXPONENT" -d "$DEVICE" -engine-marin -proof 0
41+
42+
printf '\n===== SUMMARY =====\n'
43+
for log in bench-*/run.log; do
44+
echo "--- $log"
45+
grep -E 'version=|register lead cache|multi-queue|FFT:|Progress:' "$log" | tail -12 || true
46+
done
47+
48+
PRPLL_BIN="${PRPLL_BIN:-$HOME/mgpu/gpuowl/build-release/prpll}"
49+
if [[ -x "$PRPLL_BIN" ]]; then
50+
echo
51+
echo "PRPLL reference command:"
52+
echo "$PRPLL_BIN -device $DEVICE -prp $EXPONENT -fft 4:512:8:512:202"
53+
fi

src/aevum/EngineAevum.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class engine_aevum final : public engine {
264264
handle_ = nullptr;
265265
throw std::runtime_error("Aevum plugin returned an invalid transform");
266266
}
267-
std::cout << "[Backend Aevum] engine::Reg adapter active, GF(M31^2) x GF(M61^2)"
267+
std::cout << "[Backend Aevum] engine::Reg adapter active, FFT3161/FFT323161"
268268
<< " | transform=" << transform_size_
269269
<< " | regs=" << register_count_
270270
<< " | plugin=" << api_.path
@@ -525,9 +525,6 @@ std::size_t transform_size_from_spec(const std::string& spec) {
525525
(fields[offset] == "1" || fields[offset] == "4");
526526
if (!supported_type)
527527
throw std::runtime_error("invalid Aevum FFT3161/FFT323161 spec");
528-
const bool explicit_pfa9 = spec.rfind("pfa9:", 0) == 0 || spec.rfind("pfa9fast:", 0) == 0 || spec.rfind("pfa9full:", 0) == 0;
529-
if (fields[offset] == "4" && !explicit_pfa9)
530-
throw std::runtime_error("Aevum FFT323161 requires explicit pfa9, pfa9fast, or pfa9full plan");
531528
const std::size_t width = parse_fft_dimension(fields[offset + 1]);
532529
const std::size_t middle = parse_fft_dimension(fields[offset + 2]);
533530
const std::size_t height = parse_fft_dimension(fields[offset + 3]);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
from pathlib import Path
3+
root = Path(__file__).resolve().parents[1]
4+
adapter = (root / "src/aevum/EngineAevum.cpp").read_text()
5+
engine = (root / "third_party/aevum/src/EngineApi.cpp").read_text()
6+
gpu = (root / "third_party/aevum/src/Gpu.cpp").read_text()
7+
fft = (root / "third_party/aevum/src/FFTConfig.cpp").read_text()
8+
version = (root / "include/core/Version.hpp").read_text()
9+
10+
assert 'fields[offset] == "1" || fields[offset] == "4"' in adapter
11+
assert 'requires explicit pfa9' not in adapter
12+
assert 'pending_reg_ = index;' in engine
13+
assert 'AEVUM_REG_LEAD_CACHE' in engine
14+
assert 'gpu_->regSquareStep(reg(index), pending_lead_width_, true);' in engine
15+
assert 'gpu_->regSquareStep(reg(index), lead_in, false);' in engine
16+
assert '!fft.isPfa() && !useLongCarry' in gpu
17+
assert 'fft.shape.fft_type == FFT323161;' in fft
18+
assert '4.20.68-alpha-v99.74-aevum-pow2-type4-lead-cache-exp12' in version
19+
print('PrMers Aevum power-of-two type-4 lead-cache source test passed')

0 commit comments

Comments
 (0)