Commit d8d6630
authored
fix: guard save_for_backward on grad_bias not bias in fused linear CE forward (#1157)
## Summary
Fixes a bug in `LigerFusedLinearCrossEntropyFunction.forward` where
`ctx.save_for_backward` checks `bias is not None` instead of `grad_bias
is not None` before calling `.detach()`.
When `input_requires_grad=False`, `fused_linear_cross_entropy_forward`
sets `grad_bias = None` regardless of whether `bias` is provided. The
stale check then calls `None.detach()` and raises `AttributeError`.
Fixes #1156
## Details
One-line fix in `src/liger_kernel/ops/fused_linear_cross_entropy.py`:
Before: `grad_bias.detach() if bias is not None else None,`
After: `grad_bias.detach() if grad_bias is not None else None,`
## Testing Done
- Hardware Type: CPU (logic-only fix, no GPU kernel change)
- [x] run `make test` to ensure correctness
- [x] run `make checkstyle` to ensure code style
- [ ] run `make test-convergence` to ensure convergence1 parent 167741f commit d8d6630
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| |||
0 commit comments