Skip to content

Commit bdc7bfe

Browse files
CopilotIvanYashchuk
andcommitted
Simplify _div_prim_grad: use / for gradient computations, prims.div only for forward
Co-authored-by: IvanYashchuk <19621411+IvanYashchuk@users.noreply.github.com>
1 parent e1d32f4 commit bdc7bfe

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

thunder/core/transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,8 @@ def _div_prim_grad(a: Number | TensorProxy, b: Number | TensorProxy, /) -> Numbe
11391139
fwd = prims.div(a, b)
11401140

11411141
g = get_grad(fwd)
1142-
a_grad = prims.div(g, b)
1143-
b_grad = -g * prims.div(prims.div(a, b), b)
1142+
a_grad = g / b
1143+
b_grad = -g * ((a / b) / b)
11441144
put_grads((a, b), (a_grad, b_grad))
11451145

11461146
return fwd

0 commit comments

Comments
 (0)