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
tf.tuple() with a nested-tuple argument is silently returned unchanged under eager execution, but raises a shape ValueError under tf.function tracing (jit_compile=True and autoclustering) [Recent/StarCoder] #124879
tf.tuple doesn't appear to perform its documented grouping/control-dependency behavior here at all — it's an identity pass-through.
Under tf.function tracing — both explicit jit_compile=True and autoclustering (TF_XLA_FLAGS=--tf_xla_auto_jit=2) — the same call raises:
ValueError: Shapes must be equal rank, but are 0 and 1
From merging shape 0 with other shapes. for '{{node tuple/packed}} = Pack[N=2, ...
This happens because tracing attempts to convert the nested structure into a graph node, implicitly packing a scalar-shaped element against a (2,)-shaped element.
I haven't traced tf.tuple's internal implementation to say definitively whether eager's silent pass-through or graph mode's Pack-based conversion is the "correct" behavior for a nested (non-flat) input — flagging the inconsistency, not asserting which side is wrong.
Standalone code to reproduce the issue
import tensorflow as tf
print("tf:", tf.__version__)
def create_tuple(op):
z = tf.constant(0.0)
y1 = tf.constant(1.0)
y2 = tf.constant(2.0)
t1 = (y1, y2)
t2 = (op, t1)
t3 = (t2, z)
return t3
def compute(x):
y = create_tuple(x)
return tf.tuple(y)
x1 = tf.constant(1.0)
print("--- naive (eager) ---")
try:
print(compute(x1))
except Exception as e:
print("FAILED:", str(e)[:300])
print("--- xla (jit_compile=True) ---")
try:
print(tf.function(compute, jit_compile=True)(x1))
except Exception as e:
print("FAILED:", str(e)[:300])
print("--- autocluster (run with TF_XLA_FLAGS=--tf_xla_auto_jit=2) ---")
try:
print(tf.function(compute)(x1))
except Exception as e:
print("FAILED:", str(e)[:300])
Relevant log output
tf : 2.20.0-dev0+selfbuilt
--- naive (eager) ---
naive out: ((<tf.Tensor: shape=(), dtype=float32, numpy=1.0>, (<tf.Tensor: shape=(), dtype=float32, numpy=1.0>,<tf.Tensor: shape=(), dtype=float32, numpy=2.0>)), <tf.Tensor: shape=(), dtype=float32, numpy=0.0>)
--- xla (jit_compile=True) ---
FAILED: in user code:
File "repro.py", line 17, in compute *return tf.tuple(y)
ValueError: Shapes must be equal rank, but are 0 and 1
From merging shape 0 with other shapes. for'{{node tuple/packed}} = Pack[N=2, T--- autocluster (TF_XLA_FLAGS=--tf_xla_auto_jit=2) ---FAILED: in user code: File "repro.py", line 17, in compute * return tf.tuple(y) ValueError: Shapes must be equal rank, but are 0 and 1 From merging shape 0 with other shapes. for '{{node tuple/packed}} = Pack[N=2, T
Saw that this was assigned to someone else after I’d already put up this fix. Happy to close this if they’re actively working on it; otherwise, this is ready for review.
Activity
AnupamKumar-1 commentedon Aug 8, 2026
Saw that this was assigned to someone else after I’d already put up this fix. Happy to close this if they’re actively working on it; otherwise, this is ready for review.
google-ml-butler commentedon Aug 11, 2026
Are you satisfied with the resolution of your issue?
Yes
No