mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 06:07:17 -05:00
[GH-ISSUE #1893] [Bug] Jupyternotebook: Tensor.__init__() Does Not Accept requires_grad Used by Autograd Tests #35283
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Chufeng-Jiang on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/harvard-edge/cs249r_book/issues/1893
Area
TinyTorch
Location
Module 06 and forward in the jupyternotebook
Description
The autograd broadcasting tests construct tensors using the following syntax:
x = Tensor(data, requires_grad=True)
However, the currently exported Tensor class only defines:
Tensor(data)
As a result, the tests in the Jupyternotebook fail before reaching the broadcasting-gradient implementation.
However, it doesn't affect the unit test when call "tito module complete 06", everything passed successfully.
Expected Behavior
I think all related - codes in the notebook cell needs to revised to, making the requires_grad separately :
The same change may need to be applied to the other occurrences of Tensor(..., requires_grad=True) in the cell.
I would be happy to submit a pull request with the modifications in the cell. However, before doing so, I wanted to confirm whether this is the intended fix or whether the Tensor constructor is instead supposed to be updated to support the requires_grad argument.
Environment (TinyTorch bugs only)
No response
@profvjreddi commented on GitHub (Jul 2, 2026):
Thanks @Chufeng-Jiang, and good catch. Your proposed fix is the right one. The
Tensorconstructor is intentionally minimal in module 01;enable_autograd()later monkey-patches__init__to acceptrequires_grad. Sincetest_unit_broadcast_gradients()runs beforeenable_autograd()(like its siblingtest_unit_function_classes(), which already sets the attribute manually with a note), the test should setrequires_gradas an attribute rather than pass it to the constructor. We do not want to change the constructor. I've applied that fix on our end so it lands cleanly across the module. Thanks for the clear report and repro.@all-contributors please add @Chufeng-Jiang for 🪲 Bug in TinyTorch
@github-actions[bot] commented on GitHub (Jul 2, 2026):
I've added @Chufeng-Jiang as a contributor to tinytorch! 🎉
Recognized for: bug, code
Project(s): tinytorch (explicitly mentioned in comment)
Based on: @all-contributors please add @Chufeng-Jiang for 🪲 Bug in TinyTorch
The contributor list has been updated in:
tinytorch/.all-contributorsrc,tinytorch/README.mdREADME.mdWe love recognizing our contributors! ❤️