Raise math.exp2/log2 to stablehlo.exp2/log2 and support those ops #3708
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 268 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.335
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3708"
general
weight: 0.35
ftynse
StableHLO 1.23 (in the XLA main now pins) added
stablehlo.exp2andstablehlo.log2, and XLA haskExp2/kLog2with elemental emitters for them. Until nowmath.exp2andmath.log2(which the libdevice raising produces for__nv_exp2,__nv_log2,__nv_fast_log2f, and whichexp10is lowered through) were rescaled onto the natural forms:exp2(x) -> exp(x ln 2)andlog2(x) -> log(x) (1/ln 2), an extra multiply and a rounding error per element.This raises them to the dedicated ops and gives those ops the same treatment the other unary transcendentals have:
arith-raise:math.log2 -> stablehlo.log2andmath.exp2 -> stablehlo.exp2(andmhlo.log2/mhlo.exp2on the mhlo path) throughRaiseUnary; theRaiseLog2/RaiseExp2rescaling patterns are gone.log10still rescales since stablehlo has no base-10 log.exp2_const_prop,log2_const_prop(via the reference interpreter'sexp2Op/log2Op), added toenzyme-hlo-optand to the C-API pipeline next to the other unary const props.cse_exp2,cse_log2.unary_pad_push_exp2, matchingunary_pad_push_exp.log2_simplify:log2(exp2 x) -> x,log2(exp x) -> x log2 e,log2(sqrt x) -> log2(x) / 2,log2(rsqrt x) -> -log2(x) / 2;log_simplifygainslog(exp2 x) -> x ln 2.d/dx 2^x = 2^x ln 2,d/dx log2 x = 1 / (x ln 2).Utils.cpptreatexp2likeexp.LICM and the other structural patterns (reshape/transpose/broadcast pushing, while hoisting) key off the
Elementwise/pure traits and need no per-op registration.Tests:
raising/arith_raise_log_exp_base.mlirupdated; newdiffrules/stablehlo/exp2.mlir,diffrules/stablehlo/log2.mlir(forward, reverse and interpreter checks),exp2_log2_const_prop.mlir,log2simplify.mlir,cse_exp2_log2.mlir.Reactant.jl does not yet expose
Ops.exp2/Ops.log2(itslog2goes throughlog(x)/log(2)); that is a follow-up once a JLL carries this.🤖 Generated with Claude Code
https://claude.ai/code/session_01K1GPCnUaQKiMLASni1N1eu