albanD:

A leaf is a Tensor with no gradient history.


Ah! I see. That makes so much sense.
I didn’t even realize I had it’s requires_grad flag set to false X’D
I confirmed what you said and its true, it was fixed after changing that flag:
print('-- what is a leaf?')
y_clone = y.clone()
print(f'y.is_leaf = {y_clone.is_leaf}')
x = torch.tensor([2.0],requires_grad=True)
lx = (x - 3)**2
print(f'x.is_leaf = {x.is_leaf}')
print(f'lx.is_leaf = {lx.is_leaf}')

result:
-- is y_clone an leaf
y.is_leaf = True
x.is_leaf = True
lx.is_leaf = False


Thanks! Again your a savior