Commit 5bbc327
authored
Improve Matern kernels runtime performance (#405)
* Update Python API infos
* Log info level on mopta08
* Linting
* Improve matern52 performances
57% performance improvement — benchmark went from 237 ms → 102 ms.
Two optimizations applied to correlation_models.rs:
rval_from_distances: Replaced two-pass computation (separate a and b arrays with inner mapv().product() allocations) with a single-pass scalar loop — no intermediate array allocations.
_jac_helper → _jac_from_r: Replaced the O(n·d²·h²) nested "product-excluding-one-factor" loop + einsum with a closed-form O(n·d·h) formula. Since the Matern 5/2 polynomial is always positive, the excluded-product can be computed via division: total_product / single_factor.
* Add bench matern32
* Improve matern32 performances (same as matern52)
* Add bench for squred_exp and abs_exp
* Minor improvments in squared_exp and abs_exp
The changes for SE and AE show marginal improvement (criterion reports "change within noise threshold" and "no change in performance detected" for AE). This is expected — these kernels were already simpler than the Matern ones. The main optimization (powf(2.) → v * v and shared theta_w computation) eliminates unnecessary allocations and expensive transcendental calls, but since the exponential kernels lack the O(n·d²·h²) product-excluding-one-factor structure that made Matern so costly, the absolute gains are modest.
Summary of optimizations applied:
SquaredExponential: Replaced all powf(F::cast(2.)) with v * v (avoids log+exp internally); shared neg_theta_w_sq computation in jac and rval_with_jac instead of recomputing theta_w² + separate negation
AbsoluteExponential: Shared neg_theta_w in rval_with_jac, computing r and jr from the same intermediate; avoided redundant rval_from_distances call in rval_with_jac
* Format1 parent 28b0e07 commit 5bbc327
File tree
3 files changed
+218
-207
lines changed- crates
- ego/benches
- gp/src
- python/egobox
3 files changed
+218
-207
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
31 | 73 | | |
32 | 74 | | |
33 | 75 | | |
| |||
38 | 80 | | |
39 | 81 | | |
40 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
41 | 104 | | |
42 | 105 | | |
43 | 106 | | |
| |||
0 commit comments