You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XLA fails to validate an out-of-range dynamic num_bits in QuantizeAndDequantizeV3 (num_bits ≤ 0): eager and plain graph raise InvalidArgumentError, but jit_compile=True silently produces a nonsensical result #127914
tf.raw_ops.QuantizeAndDequantizeV3 takes a dynamicnum_bits input. Eager execution and plain tf.function (graph) both validate it and raise InvalidArgumentError when num_bits ≤ 0. Under jit_compile=True (XLA), the same call silently returns a result instead of raising.
This is not merely "backends disagree on invalid input": the eager V3 kernel reads the dynamic num_bits and explicitly requires num_bits_val > 0 (else InvalidArgumentError), whereas the XLA V3
lowering reads ctx->Input(3) and directly computes 2^num_bits with no range check — so the XLA
path is missing the input constraint the eager path enforces. TF already treats validation gaps for this
op as bugs (e.g. #99456 / #87421: hard crash / Check failed: d >= 0 instead of InvalidArgumentError).
Hi @tinywisdom, Thank you for reporting this issue!
You've clearly demonstrated that the XLA compilation for tf.raw_ops.QuantizeAndDequantizeV3 lacks the necessary input validation for num_bits > 0. This causes it to produce silent incorrect results when num_bits is out of range, whereas graph and eager execution correctly raises an InvalidArgumentError.
We’ll investigate the issue on our end and provide an update.
Activity
Kayyuri commentedon Sep 23, 2026
Hi @tinywisdom, Thank you for reporting this issue!
You've clearly demonstrated that the XLA compilation for
tf.raw_ops.QuantizeAndDequantizeV3lacks the necessary input validation fornum_bits > 0. This causes it to produce silent incorrect results when num_bits is out of range, whereas graph and eager execution correctly raises anInvalidArgumentError.We’ll investigate the issue on our end and provide an update.
Validate constant num_bits in XLA QuantizeAndDequantizeV3
Validate constant num_bits in XLA QuantizeAndDequantizeV3
Validate constant num_bits in XLA QuantizeAndDequantizeV3
Kayyuri commentedon Oct 14, 2026
Hi @tinywisdom,
A fix for this issue has been proposed in this PR. Once it is merged, this issue will be resolved.
Big thanks to @adi-IL for raising the PR to address this issue. We truly appreciate your initiative and the effort in contributing the fix.
google-ml-butler commentedon Oct 15, 2026
Are you satisfied with the resolution of your issue?
Yes
No