Repository navigation
Closed
Closed
Copy link
Labels
2.21.0tensorflow 2.21.0comp:xlaXLAstaleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authortype:bugBug
Description
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
No
Source
source
TensorFlow version
tf 2.21.0
Custom code
Yes
OS platform and distribution
Linux, 22.04.1-Ubuntu
Mobile device
No response
Python version
3.10.12
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
A graph mixing tf.experimental.numpy.hstack / broadcasting ops compiles and runs in eager but fails XLA compilation with Incompatible shapes: [4] vs. [8]. The eager/XLA shape inference disagree.
Standalone code to reproduce the issue
import tensorflow as tf
tf.random.set_seed(1699)
t4400 = tf.complex(tf.random.normal([8], dtype=tf.float32), tf.random.normal([8], dtype=tf.float32))
def model_1699(t4400):
t4403 = tf.experimental.numpy.hstack((5, 5, 5, 5))
t4401 = tf.experimental.numpy.logical_xor(t4400, t4400)
t4410 = tf.experimental.numpy.allclose(t4403, t4401, atol=-2.92515058314041)
return t4410
_args = (t4400,)
# --- minimal driver: eager then XLA jit_compile ---
eager_out = model_1699(*_args)
xla_out = tf.function(model_1699, jit_compile=True)(*_args)
print('OK', eager_out.shape, xla_out.shape)Relevant log output
Traceback (most recent call last):
File "/home/bug_reports/_repros/repro_690dce2f.py", line 15, in <module>
xla_out = tf.function(model_1699, jit_compile=True)(*_args)
File "/home/.venv/lib/python3.10/site-packages/tensorflow/python/util/traceback_utils.py", line 167, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/.venv/lib/python3.10/site-packages/tensorflow/python/eager/execute.py", line 53, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [4] vs. [8]
[[{{node Equal_1}}]]
tf2xla conversion failed while converting __inference_model_1699_169[_XlaMustCompile=true,config_proto=13561319589895757934,executor_type=11160318154034397263]. Run with TF_DUMP_GRAPH_PREFIX=/path/to/dump/dir and --vmodule=xla_compiler=2 to obtain a dump of the compiled functions. [Op:__inference_model_1699_169]Metadata
Metadata
Assignees
Labels
2.21.0tensorflow 2.21.0comp:xlaXLAstaleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authortype:bugBug
Activity
furk4neg3 commentedon Jul 4, 2026
I can take a look at this issue.
From my initial investigation, the failure seems to happen because
tf.experimental.numpy.allcloseeventually builds an equality comparison for inputs with statically known non-broadcastable shapes. In eager/non-XLA execution, Tensor equality handles this case by returning a scalarFalse, but underjit_compile=Truethe incompatibleEqualop reaches XLA and fails during compilation.I’m planning to try a narrow fix in
tf.experimental.numpy.allclose: when both input shapes are statically known and non-broadcastable, avoid constructing the incompatible equality op and return scalarFalsefor the existing non-inexact comparison path. I’ll also add a focused XLA regression test for the reported case.I’ll keep the change scoped to
allcloseand avoid changing general Tensor equality or XLA lowering behavior unless maintainers think that would be the better direction.furk4neg3 commentedon Jul 4, 2026
I opened a PR with a narrow fix for this: #122605
The change keeps the fix scoped to
tf.experimental.numpy.allcloseby avoiding construction of the incompatible equality op when the input shapes are statically known to be non-broadcastable in the non-inexact comparison path. I also added an XLA regression test for the reported case.Venkat6871 commentedon Sep 30, 2026
Hi @jasminetrail,
Apologies for the delay. This issue has been fixed on
masterand the fix is included inv2.22.0-rc0andtf-nightly.In TensorFlow 2.21.0,
tf.experimental.numpy.isclosecould behave differently between eager execution andtf.function(jit_compile=True)for non-broadcastable shapes[4]and[8]: eager execution returnedFalse, while XLA raised anInvalidArgumentError.The fix from PR #122605 (landed in commit 35fd349) and the follow-up PR #123867 (commit 09a3302) updated
tf.experimental.numpy.iscloseand added regression coverage for this case.I also verified the original reproducer with
v2.22.0-rc0andtf-nightly, where the incompatible shapes now consistently raise a shape-mismatch error. I’ve included the verification results in this gist for your reference.Could you please verify this on your side as well and let us know if you still see the issue?
Thank you!
github-actions commentedon Oct 8, 2026
This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you.
github-actions commentedon Oct 16, 2026
This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further.
google-ml-butler commentedon Oct 16, 2026
Are you satisfied with the resolution of your issue?
Yes
No