Fix incorrect remediation instructions in cudagraph pending backward warning (#176865)
Summary:
## Summary
The current warning message for CUDAGraph fast path failure due to pending backwards suggests using `torch.no_grad()`. However, in some cases (e.g., when using `torch.func.grad_and_value()`), `torch.no_grad()` is ineffective because the function internally constructs a backward graph. This PR updates the warning message to correctly identify the cause and suggest valid remediation steps like calling `backward()`, detaching outputs, or using `mark_step_begin()`.
## Test Plan
- Verified the warning text update via grep in `torch/_inductor/cudagraph_trees.py`.
- Tested that the updated warning now accurately reflects the issues reported in #176846.
Fixes #176846
X-link: https://github.com/pytorch/pytorch/pull/176865
Approved by: https://github.com/jansel
Reviewed By: georgehong
Differential Revision: D98314212
fbshipit-source-id: 3cdb6e12040904535f73155b83395f832a42f611
Author
generatedunixname499836121