Repository navigation
Commit 4ccb054
def_comp + thread effective_order across jit boundaries
Two coupled fixes that together make effective_order honor the contract
uniformly across user code, including jnp.* operators and explicit jit
subroutines.
(1) def_comp was discarding effective_order. The wrapper used
partial(jet, comp), which passed effective_order=None to the inner
jet call regardless of what the trace was told. comp_rule now
accepts _jet_effective_order and forwards it; def_comp also calls
_register_eff_order_rule(prim) so the dispatcher actually feeds
the kwarg.
(2) The deeper bug: _pjit_jet_rule discarded effective_order at every
jit boundary. Any function using jnp.* primitives (which wrap each
op in implicit jit) computed the full series despite the hint.
Fix: when effective_order is non-None, append it as an extra
runtime input to the inner pjit. _jet_jaxpr now has a
propagate_effective_order flag that selects between the existing
no-propagation path and a new path that uses jet_fun_with_eff +
traceable_with_eff to pull eff out of the last input and feed it
into the inner JetTrace. The jaxpr cache now distinguishes the two
paths so a function jet'd with and without effective_order builds
two cached jaxprs (instead of polluting one).
Both jet_fun_with_eff and traceable_with_eff are linear-util
transformations mirroring jet_fun and traceable respectively, with the
only difference being that they thread the eff scalar through the
trace. The inner JetTrace's effective_order then becomes a tracer on
the inner pjit's eff input — lax.cond inside _jet_scan handles
tracer-valued conditions natively.
Tests: tests/test_effective_order.py adds 8 cross-jit propagation
cases — 7 with implicit jit (jnp.exp, jnp.sin, x**0.5, x*x, x**3, …
each composed with jnp.exp so the high-order Taylor coefficients are
non-zero and truncation is observable) plus one with an explicit
jax.jit subroutine. Each asserts both prefix correctness AND that the
tail is genuinely truncated (zero), distinguishing actual
short-circuiting from natural-zero coefficients. Total suite: 646
passed, 5 skipped.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 704298b commit 4ccb054
3 files changed
Lines changed: 152 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
235 | 242 | | |
236 | 243 | | |
237 | 244 | | |
| |||
257 | 264 | | |
258 | 265 | | |
259 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
260 | 271 | | |
261 | 272 | | |
262 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
264 | 292 | | |
265 | 293 | | |
266 | 294 | | |
| |||
580 | 608 | | |
581 | 609 | | |
582 | 610 | | |
583 | | - | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
584 | 616 | | |
585 | 617 | | |
586 | 618 | | |
| |||
1250 | 1282 | | |
1251 | 1283 | | |
1252 | 1284 | | |
1253 | | - | |
| 1285 | + | |
| 1286 | + | |
1254 | 1287 | | |
1255 | 1288 | | |
1256 | 1289 | | |
| |||
1262 | 1295 | | |
1263 | 1296 | | |
1264 | 1297 | | |
1265 | | - | |
1266 | | - | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
1267 | 1313 | | |
1268 | 1314 | | |
1269 | 1315 | | |
1270 | 1316 | | |
1271 | 1317 | | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
1272 | 1321 | | |
1273 | 1322 | | |
1274 | 1323 | | |
1275 | 1324 | | |
1276 | 1325 | | |
1277 | 1326 | | |
1278 | 1327 | | |
1279 | | - | |
| 1328 | + | |
1280 | 1329 | | |
1281 | 1330 | | |
1282 | 1331 | | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
1283 | 1341 | | |
1284 | | - | |
| 1342 | + | |
1285 | 1343 | | |
1286 | 1344 | | |
1287 | | - | |
| 1345 | + | |
| 1346 | + | |
1288 | 1347 | | |
1289 | 1348 | | |
1290 | 1349 | | |
| 1350 | + | |
1291 | 1351 | | |
1292 | 1352 | | |
1293 | 1353 | | |
| |||
1297 | 1357 | | |
1298 | 1358 | | |
1299 | 1359 | | |
1300 | | - | |
| 1360 | + | |
| 1361 | + | |
1301 | 1362 | | |
1302 | 1363 | | |
1303 | 1364 | | |
1304 | 1365 | | |
1305 | | - | |
| 1366 | + | |
1306 | 1367 | | |
1307 | | - | |
| 1368 | + | |
1308 | 1369 | | |
1309 | | - | |
| 1370 | + | |
1310 | 1371 | | |
1311 | 1372 | | |
1312 | 1373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 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 | + | |
0 commit comments