mirror of
https://github.com/allaunthefox/SilverSight.git
synced 2026-08-17 20:30:34 +00:00
1. BMCTE_v2_PAPER.md — regime-stability theorem, λ(p) smoothness, entropy invariance 2. SYSTEM_SPEC.md — unified GPU kernel design, fused kernel, compiler IR 3. THEORY_CLOSURE.md — categorical framework, projection stability principle, BMCTE class All validated by bosonic_continuous experiment. Build: 2987 jobs, 0 errors
2.2 KiB
2.2 KiB
BMCTE v2 System Specification
Unified Execution Model (No Regime Switching)
Pipeline (single kernel)
U (N×N)
↓ [1] Mode Sampling
S = sample_modes(U) ~ μ_U
↓ [2] Gather
M = U[S, :] // p×p submatrix
↓ [3] Ryser Permanent
A = ryser_permanent(M)
↓ [4] Reduction
histogram += |A|²
↓
normalize
GPU Kernel Design
Kernel A — Sampling (O(Np))
- warp-per-photon
- register CDF tables for categorical draws
- coalesced read of U columns
Kernel B — Gather (memory-bound)
- construct M = U[S, :]
- shared cache for column reuse
- register-resident for p ≤ 8
Kernel C — Ryser Permanent (compute-bound)
- 2^p threads per block (bitmask enumeration)
- warp reduction for row sums
- Cost: O(p·2^p)
Kernel D — Reduction
- atomic histogram OR segmented reduction
- float64 accumulation
Fully Fused Kernel (Final Form)
__global__ void bmcte_kernel(
const complex128_t* U, int N, int p,
float64_t* histogram, long long samples) {
int k = blockIdx.x * blockDim.x + threadIdx.x;
if (k >= samples) return;
// 1. Sample modes
int S[8];
for (int j = 0; j < p; j++) {
S[j] = categorical_sample(U + j*N, N); // U[:,j]
}
// 2. Gather submatrix
complex128_t M[8][8]; // in registers
#pragma unroll
for (int i = 0; i < p; i++) {
#pragma unroll
for (int j = 0; j < p; j++) {
M[i][j] = U[S[i] * N + j];
}
}
// 3. Ryser permanent
double perm_real = ryser_real(M, p);
double perm_imag = ryser_imag(M, p);
double weight = (perm_real*perm_real + perm_imag*perm_imag);
// 4. Accumulate
atomicAdd(histogram + S[0], weight / factorial(p));
// ... for all selected modes
}
Compiler IR (BMCTE-IR v2)
SAMPLE(U) → S
GATHER(U, S) → M
RYSER_PERMANENT(M) → A
WEIGHT(A, p) → w
REDUCE(w, S) → histogram
NORMALIZE(histogram) → output
Optimization Rules
- Fuse sampling + gather (eliminate memory round trips)
- Register-resident M for p ≤ 8
- Inline Ryser loop into warp
- Batch K samples per kernel launch
- No runtime branching on p — single code path
Complexity Class
BMCTE: O(K·(Np + p·2^p))
No dependence on (N+p-1 choose p)