Md. Asif Uddin
    Problem I.9.B05

    Same prediction, different backward graph

    gradient▲▲△

    Exact values where possible; six decimal places for non-exact numerical results.

    STATEMENT

    Compare full backpropagation with a one-step truncation that detaches the state after the second input.

    GIVEN

    Use I.9.B01’s linear scalar model: (u,w,b,v,c)=(1,1/2,0,2,0)(u,w,b,v,c)=(1,1/2,0,2,0), inputs (1,2,0)(1,2,0), initial state zero, and final target one. The full forward states are (1,5/2,5/4)(1,5/2,5/4). There is only a final output loss.

    FIND

    The prediction and loss in both computations, and their derivatives with respect to ww and uu. Explain the correct finite-difference check for each.

    STRATEGY

    After detaching h2h_2, replace its computation by the constant 5/25/2. Differentiate the remaining one-step function and compare it with I.9.B02.

    SOLUTION

    The full graph has h3=u(w2+2w)h_3=u(w^2+2w) at b=0b=0. At the stated parameters its gradients are ∂wL=9\partial_w\mathcal L=9 and ∂uL=15/4\partial_u\mathcal L=15/4.

    The detached graph instead evaluates

    h3=u⋅0+w⋅(5/2)+b,z3=vh3+c.\begin{aligned} h_3&=u\cdot0+w\cdot(5/2)+b,\\ z_3&=vh_3+c. \end{aligned}

    At the original parameters this gives the same h3=5/4h_3=5/4, z3=5/2z_3=5/2 and loss 9/89/8. Its last-state derivative is still δ3=3\delta_3=3, but there is no earlier parameter path:

    ∂wLtrunc=3(5/2)=15/2,∂uLtrunc=3⋅0=0.\begin{aligned} \partial_w\mathcal L_{\mathrm{trunc}}&=3(5/2)=15/2,\\ \partial_u\mathcal L_{\mathrm{trunc}}&=3\cdot0=0. \end{aligned}

    The derivative with respect to the boundary value itself would be wδ3=3/2w\delta_3=3/2. Detachment stops it from propagating into the calculation that produced that value.

    To finite-difference the full graph, perturb ww or uu and recompute every state. To finite-difference the truncated graph, first compute the boundary state at the original parameters, freeze it at 5/25/2, then perturb the parameters only in the final chunk.

    Recomputing the boundary during the truncated check reattaches the dependency you intended to remove. Its result would be the full gradient, not a failure of the truncated backward implementation.

    Answer

    Both predictions are 2.52.5 and both losses are 1.1251.125. Full (∂w,∂u)=(9,3.75)(\partial_w,\partial_u)=(9,3.75); truncated (∂w,∂u)=(7.5,0)(\partial_w,\partial_u)=(7.5,0).

    Check — sanity

    Resetting instead of detaching would set the boundary to zero. Because x3=b=c=0x_3=b=c=0, that would give prediction zero and loss 1/21/2, a different forward computation. Detach preserves the value; reset replaces it.

    Where this breaks

    This comparison uses one fixed parameter setting and one final loss. Chunk-wise updates may also change parameters between chunks; they are not identical to a single full-sequence update even if boundary derivatives happen to be small.

    Variation

    Keep the final two time steps after detaching h1h_1. The ww gradient happens to remain nine because the removed first-step contribution is zero, but the uu gradient drops from 3.753.75 to 33. Matching one parameter’s derivative does not establish that the whole backward graph matches.

    Draws on