Gradient Flow after detached

KSonPham: <p>Hi everyone,<br>
I’ve noticed an interesting behavior in my model. It utilizes the mmcv framework for both training and testing. The model features a backbone for creating BEV (Bird’s Eye View) features and two heads, pts_bbox_head and area_head, for predictions. These heads share the BEV features from the backbone. However, when I detach and clone the BEV features for forwarding via area_head, I observe that the features still get updated differently compared to completely removing the area_head. Could you explain why that’s the case? Thanks<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/3/73c6361ac7205ee154ed3c0b2d0632511c8d5d94.png" data-download-href="https://discuss.pytorch.org/uploads/default/73c6361ac7205ee154ed3c0b2d0632511c8d5d94" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/7/3/73c6361ac7205ee154ed3c0b2d0632511c8d5d94.png" alt="image" data-base62-sha1="gwbzE7bF3aPkJO6C8H5P5st4hmc" width="690" height="214" data-dominant-color="303B41"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1188×370 26 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<ul>
<li>
<p>With area_head:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/e/4/e46a95331c034f1816714b398ddc330b4db2ea27.png" data-download-href="https://discuss.pytorch.org/uploads/default/e46a95331c034f1816714b398ddc330b4db2ea27" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/e/4/e46a95331c034f1816714b398ddc330b4db2ea27.png" alt="image" data-base62-sha1="wAFdnQJKPMxn4YF1rtAvtZisK4n" width="690" height="393" data-dominant-color="2C373C"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">818×466 14.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
</li>
<li>
<p>Without area_head:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/a/1af2f616617dfa5445ede473a3abae8e1e7a2ffb.png" data-download-href="https://discuss.pytorch.org/uploads/default/1af2f616617dfa5445ede473a3abae8e1e7a2ffb" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/1/a/1af2f616617dfa5445ede473a3abae8e1e7a2ffb.png" alt="image" data-base62-sha1="3QoXii2BaZFiApBUF7G1mFyy2sX" width="690" height="372" data-dominant-color="313D42"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">792×427 15 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
</li>
</ul>

ptrblck: <p>Could you post a minimal and executable code snippet reproducing the issue?</p>