avengeryt22 commited on
Commit
539cbe4
·
verified ·
1 Parent(s): 2c55082

add reproduction card

Browse files
Files changed (1) hide show
  1. README.md +166 -0
README.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0 0 2em"><a href="https://hf.co/chat?mode=ml-intern"><img src="https://hf.co/datasets/huggingface/badges/resolve/main/built-with-ml-intern-lg.svg" alt="Built with ML Intern" style="margin:0"></a><a href="https://hf.co/chat?mode=ml-intern&prompt=Reproduce%20the%2016-D%20oracle%20benchmark%20from%20arXiv%3A2602.10378%20with%20the%20pinned%20Flash-SD-KDE%20code" style="display:inline-flex;align-items:center;gap:5px;padding:4px 12px;border:1.5px solid #eee;border-radius:16px;background:#f9fbfc;color:#c2410c;font-weight:600;font-size:14px;text-decoration:none">Check the 16-D arm ›</a><a href="https://hf.co/chat?mode=ml-intern&prompt=Re-run%20the%20fused%20vs%20non-fused%201D%20timing%20from%20avengeryt22%2Fflash-sd-kde-repro%20on%20an%20A6000-class%20GPU" style="display:inline-flex;align-items:center;gap:5px;padding:4px 12px;border:1.5px solid #eee;border-radius:16px;background:#f9fbfc;color:#c2410c;font-weight:600;font-size:14px;text-decoration:none">Re-time on other hardware ›</a></div>
2
+
3
+ # Flash-SD-KDE §5 claim: signed fused/non-fused equivalence and scoped error/cost
4
+
5
+ Reproduction / falsification attempt for the claim in **Section 5** of
6
+ [Flash-SD-KDE: Accelerating SD-KDE with Tensor Cores](https://arxiv.org/abs/2602.10378)
7
+ (Epstein, Dwaraknath, Winnicki; arXiv:2602.10378v1), tested against the authors'
8
+ code at commit `acaf8712f8c146c837e1d1dcccb56ce6322962bc`.
9
+
10
+ **Claim under test.** Fusing the Laplace-corrected Gaussian kernel improves
11
+ implementation throughput without changing its signed estimator, whose
12
+ statistical behaviour remains distinct from empirical SD-KDE.
13
+
14
+ **Verdict: verified, with three scope conditions** (no universal speedup, no
15
+ nonnegative-density claim, no A6000 digit match — see *What this does not
16
+ establish*).
17
+
18
+ | Part | Test | Result |
19
+ |---|---|---|
20
+ | Kernel is `K_h(r)(1.5 − 0.5 r²/h²)` and equals `K_h − (h²/2)ΔK_h` | float64 identity + finite-difference Laplacian, independently coded | max abs error **4.4e-16**; FD check 4.4e-7 |
21
+ | Signed, negative tails retained | mass / moments / sign root | ∫K_LC = **1.0000000000000002**, ∫r²K_LC = **−1e-17**, ∫r⁴K_LC = **−3.0000 h⁴**, sign flips at **r/h = 1.7320508 = √3** |
22
+ | Fusion does not change the estimator | fused vs non-fused raw signed densities | **1.1e-16** (float64), **6.0e-8…8.9e-8** max abs / **1.6e-7…2.8e-7** rel (float32 and GPU Triton); **0** sign disagreements in 18 runs |
23
+ | Fusion improves throughput | authors' Triton kernels, their timing protocol, A10G | **1.93× → 6.20×** (n = 128 → 4096); fused **0.19–0.20 ms** flat, non-fused **0.387 → 1.199 ms** |
24
+ | Statistics distinct from empirical SD-KDE | MISE / MIAE / integrated negative mass | empirical SD-KDE worse on both metrics at every n; negative mass **1.69e-3 vs exactly 0** at n = 4096 |
25
+
26
+ ## 1. Kernel mathematics, checked independently
27
+
28
+ All three paths are separately coded in `code/independent_1d.py`: (A) the
29
+ definition `p − (h²/2)Δp` with the analytic 1D Laplacian, (B) the fused factor
30
+ form used by the kernel, (C) the non-fused two-pass form.
31
+
32
+ | check (h = 0.37, float64) | value |
33
+ |---|---|
34
+ | `maxabs(K_h(1.5−0.5s²) − [K_h − (h²/2)K_h''])` | 4.44e-16 (4.12e-16 relative) |
35
+ | central-difference Laplacian vs analytic `K_h''` | 4.41e-07 |
36
+ | FD-Laplacian corrected kernel vs closed form | 3.02e-08 |
37
+ | ∫ K_LC dr over ±40h | 1.0000000000000002 |
38
+ | ∫ r² K_LC dr / h² | −1.04e-17 |
39
+ | ∫ r⁴ K_LC dr / h⁴ | −3.0000 |
40
+ | sign-change radius r/h | 1.7320508075688772 (√3) |
41
+
42
+ `K_LC·h` at r/h = 1.5, √3, 2.0, 3.0: **+0.04857, +7.8e-06, −0.02700, −0.01330**.
43
+ The kernel integrates to one and has zero second moment but a **negative**
44
+ fourth moment — a fourth-order kernel that is not a probability density.
45
+
46
+ ## 2. Signed error and negative mass (declared config)
47
+
48
+ Released settings: weights (.3,.4,.3), means (−2,0,2), σ (.4,.7,.3), n_train
49
+ 128…4096, 2048 grid points on [−6,6], Silverman bandwidth per n, seed 0, one
50
+ 4096-draw per replicate with prefix subsets. **MISE/MIAE are the mean of the
51
+ three per-replicate ISE/IAE** (trapezoid, signed density, no clipping).
52
+
53
+ | n | KDE MISE | **fused LC MISE** | non-fused MISE | emp SD-KDE MISE | KDE MIAE | **fused LC MIAE** | emp MIAE | LC neg. mass |
54
+ |---:|---:|---:|---:|---:|---:|---:|---:|---:|
55
+ | 128 | 3.4435e-2 | **1.8034e-2** | 1.8034e-2 | 3.0365e-2 | 4.0125e-1 | **2.8664e-1** | 3.6990e-1 | 1.021e-2 |
56
+ | 256 | 2.7163e-2 | **1.1633e-2** | 1.1633e-2 | 2.1592e-2 | 3.5296e-1 | **2.1593e-1** | 3.0521e-1 | 8.478e-3 |
57
+ | 512 | 2.1044e-2 | **7.1874e-3** | 7.1874e-3 | 1.4884e-2 | 3.0239e-1 | **1.6925e-1** | 2.4657e-1 | 5.699e-3 |
58
+ | 1024 | 1.4812e-2 | **3.8112e-3** | 3.8112e-3 | 8.7519e-3 | 2.4841e-1 | **1.1892e-1** | 1.8130e-1 | 4.389e-3 |
59
+ | 2048 | 1.0311e-2 | **1.7946e-3** | 1.7946e-3 | 4.9426e-3 | 2.0356e-1 | **8.0977e-2** | 1.3261e-1 | 2.642e-3 |
60
+ | 4096 | 7.2109e-3 | **1.1142e-3** | 1.1142e-3 | 2.8013e-3 | 1.6325e-1 | **6.5009e-2** | 9.7414e-2 | 1.687e-3 |
61
+
62
+ At n = 4096 the corrected estimator has mass 1.0000, ∫|p̂| = 1.00337, minimum
63
+ −0.00419; empirical SD-KDE has ∫|p̂| = 1.0, minimum 0.0 and negative mass
64
+ **exactly 0**. The two estimators are different objects: the Laplace estimator
65
+ is linear in the empirical measure and signed, the empirical SD-KDE is not
66
+ linear and nonnegative.
67
+
68
+ **Definition check.** Computing ISE of the replicate-averaged density instead of
69
+ averaging per-replicate ISE gives 0.710× the reported MISE (10 replicates) and
70
+ 0.799× (declared 3) — a 20–29% error, which is why the averaging order is stated
71
+ explicitly above.
72
+
73
+ ## 3. Fused vs non-fused: identical estimator, different cost
74
+
75
+ Output agreement (raw signed densities, per (n, replicate)):
76
+
77
+ | path | max abs diff | max rel diff |
78
+ |---|---|---|
79
+ | float64, fused vs non-fused | 1.11e-16 | 3.06e-16 |
80
+ | float32, fused vs non-fused | 5.96e-8 … 8.94e-8 | 1.6e-7 … 2.8e-7 |
81
+ | A10G Triton, fused vs non-fused | 5.96e-8 … 8.94e-8 | — |
82
+ | A10G fused vs independent float64 definition | — | 1.4e-7 … 2.3e-7 |
83
+
84
+ Zero sign disagreements between fused and non-fused in all 18 (n, replicate)
85
+ runs; both return `(2048,)` float32 tensors in every run. Induced change in
86
+ MISE between the two paths is < 1e-9 absolute (e.g. 3.811235e-3 vs 3.811236e-3
87
+ at n = 1024). The GPU statistics also match the CPU float32 statistics to six
88
+ digits (MISE at n = 4096: 1.114168e-3 both), so the Triton path is not silently
89
+ changing the estimator.
90
+
91
+ Runtime, authors' protocol (one warmup + one discarded pass, then 3 CUDA-event
92
+ repeats, mean of 3 data replicates; `splitk_stream`, `fast_tf32`, autotune on):
93
+
94
+ | n | KDE ms | **fused ms** | non-fused ms | non-fused / fused |
95
+ |---:|---:|---:|---:|---:|
96
+ | 128 | 0.2025 | **0.2002** | 0.3870 | 1.93× |
97
+ | 256 | 0.1905 | **0.1926** | 0.3911 | 2.03× |
98
+ | 512 | 0.1958 | **0.1964** | 0.4030 | 2.05× |
99
+ | 1024 | 0.1939 | **0.1947** | 0.4716 | 2.42× |
100
+ | 2048 | 0.1943 | **0.1950** | 0.7218 | 3.70× |
101
+ | 4096 | 0.2037 | **0.1932** | 1.1986 | 6.20× |
102
+
103
+ Timing boundaries are identical for the two paths: same inputs, same output
104
+ shape/dtype, host transfer (`.cpu()`) outside the timed region, same warmup and
105
+ repeat count. The fused kernel is flat at ~0.19 ms — launch-bound over this
106
+ range — while the non-fused path pays a second pass that scales with n, so the
107
+ ratio is a function of n, not a constant.
108
+
109
+ ## What this does not establish
110
+
111
+ - **No fixed speedup.** 1.93×–6.20× is specific to n, to this A10G, and to the
112
+ 1D launch-bound regime. The paper tabulates no 1D speedup; Figure 4 shows a
113
+ ~2–8× band, which this reproduces in shape but cannot match digit-for-digit.
114
+ - **No speedup on CPU.** In NumPy float64 at n = 4096 the fused form is
115
+ *slower* (0.1137 s vs 0.1013 s). The throughput claim is about the fused GPU
116
+ kernel, not about the algebra.
117
+ - **No nonnegative probability density.** The estimator integrates to 1 but has
118
+ negative mass (1.69e-3 at n = 4096) and negative values; it is not a density.
119
+ - **No A6000 number.** The A10G (80 SMs reported by torch) is a different
120
+ Ampere part from the paper's RTX A6000 (84 SMs); absolute times and ratios
121
+ will move with hardware.
122
+ - **"Distinct" is an estimator-class statement, not a significance test.** The
123
+ ordering (LC < empirical SD-KDE in both MISE and MIAE) holds at all six n and
124
+ across 10 replicates, but the declared config has 3 replicates, which is too
125
+ few for a formal test. In 1D the Laplace estimator also wins MIAE, whereas the
126
+ paper's 16-D text reports Flash-SD-KDE as best on MIAE; that is a
127
+ dimension-dependent ordering, not a contradiction of the claim.
128
+
129
+ ## Deviations from the released setup
130
+
131
+ 1. GPU is an **A10G** (24 GB, 80 SMs as reported by torch), not the paper's RTX A6000.
132
+ 2. A **float64 "gold" pass** was added; the released code is float32 throughout.
133
+ 3. **10 replicates** were run; the first 3 draws are exactly the declared config
134
+ (RNG stream is replicate-outer), the other 7 are a labelled extension.
135
+ Primary tables above use the declared 3.
136
+ 4. The authors' **`gitbud` run-directory/Slack plumbing was bypassed**; their
137
+ `_time_call`/`_time_repeated` and call sequence were copied verbatim.
138
+ 5. Grid is float64 in the gold pass and float32 in the as-released pass.
139
+ 6. `densities_curves.npz` is not archived here; the script regenerates it.
140
+
141
+ ## Files
142
+
143
+ - `code/independent_1d.py` — independent float64/float32 implementation, kernel
144
+ checks, signed ISE/IAE/negative mass, fused/non-fused equivalence (CPU).
145
+ - `code/gpu_a10g.py` — authors' pinned Triton kernels: output identity vs the
146
+ float64 definition, runtime with their protocol.
147
+ - `results/independent_1d.json` — all per-replicate metrics and checks.
148
+ - `results/gpu_a10g.json` — GPU metrics, equivalence and timings.
149
+ - `results/gpu_run.log` — raw stdout of the A10G run.
150
+
151
+ Reproduce: `pip install torch triton numpy` (resolved here to torch 2.15.0+cu132,
152
+ triton 3.9.0, numpy 2.5.5), then `python code/independent_1d.py` (~22 s CPU) and
153
+ `python code/gpu_a10g.py` (needs CUDA; clones the pinned commit itself).
154
+ Compute used: one A10G-small sandbox, ~14 min, ≈ $0.23.
155
+
156
+ ## Citation
157
+
158
+ ```bibtex
159
+ @article{epstein2026flashsdkde,
160
+ title = {Flash-SD-KDE: Accelerating SD-KDE with Tensor Cores},
161
+ author = {Epstein, Elliot L. and Dwaraknath, Rajat Vadiraj and Winnicki, John},
162
+ journal= {arXiv preprint arXiv:2602.10378},
163
+ year = {2026},
164
+ url = {https://arxiv.org/abs/2602.10378}
165
+ }
166
+ ```