warmup¶
Compile the numba kernels up front, so the first fit or predict in a fresh process
is not slow. See Deployment.
Pre-compile ChimeraBoost's numba kernels.
The hot loops are numba kernels, compiled on first use and cached on disk
(cache=True). A fresh machine or container still pays the full JIT cost
(~5-15 s) inside its first fit, and ~0.2-2 s inside the first predict
of a fresh process (kernel compile or cache load).
Long-lived processes never notice. Fleets of short-lived workers -- benchmark harnesses, serverless inference, ray/spark tasks -- pay it on every task, where it can dwarf the real fit/predict work.
warmup() runs a few tiny synthetic fits and predictions that touch every
kernel on the default fit and predict paths, so later real calls run at
steady-state speed. Call it at import or startup time, outside anything you
time or bill -- or run chimeraboost-warmup once after installing.
numba stamps each cache entry with its source file's modification time and
size, so upgrading ChimeraBoost invalidates the cache: the first run after
pip install -U pays the compile again.
warmup
¶
Compile (or load from the on-disk cache) all default-path kernels.
Covers binary classification with linear leaves, a categorical feature and
a validation set; multiclass; multi-quantile regression; regression with
ordered boosting and non-uniform sample weights (the weighted ordered-TS
kernel); and the gdiff cross-feature group-sum kernel. Together these touch
every fit- and predict-path numba kernel except the SHAP kernels
(shap=True).
Instead of calling this yourself, run chimeraboost-warmup once after
installing, or set the environment variable CHIMERABOOST_WARMUP=1 to
run it automatically when chimeraboost is imported (=background
uses a daemon thread instead).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
Print per-stage timings. |
False
|
background
|
bool
|
Run in a daemon thread and return it immediately, so compilation overlaps the caller's own startup (data loading, connections). A fit issued before the thread finishes simply blocks on numba's per-kernel compile locks, so it is never slower than compiling inline. |
False
|
shap
|
bool
|
Also compile the SHAP kernels. Off by default: it adds ~3.7 s to a
cold warmup and most callers never use |
False
|
Returns:
| Type | Description |
|---|---|
float or Thread
|
Wall-clock seconds spent warming up, or the started daemon thread
when |
Notes
A few kernels never fire inside a fit this small: they need more rows than a warmup fit has, or a weighted fit, or a degenerate column. Those are called directly below, with the dtypes the real call passes.
Source code in chimeraboost/warmup.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
main
¶
chimeraboost-warmup -- compile the kernels now, not on first fit.
Run once after pip install, and again after every upgrade, which
invalidates numba's cache. Also reachable as
python -m chimeraboost.warmup or python -m chimeraboost.