scalar_pullback does first(blocks(dt))[2][1] = Δval (plain assignment) instead of accumulating, unlike every other rule in this extension (increment!!/in-place +=). If the tensor fed to scalar(t) is also used elsewhere in the same reverse pass, one pullback's contribution silently clobbers the other's — wrong gradient, no error.
ext/TensorKitMooncakeExt/tensoroperations.jl:196-204. Fix: first(blocks(dt))[2][1] += Δval.
scalar_pullbackdoesfirst(blocks(dt))[2][1] = Δval(plain assignment) instead of accumulating, unlike every other rule in this extension (increment!!/in-place+=). If the tensor fed toscalar(t)is also used elsewhere in the same reverse pass, one pullback's contribution silently clobbers the other's — wrong gradient, no error.ext/TensorKitMooncakeExt/tensoroperations.jl:196-204. Fix:first(blocks(dt))[2][1] += Δval.