Tiny-torch 03-layers have Tensor(, requires_grad=True). but 01-Tensor not #479

Closed
opened 2026-03-22 15:42:25 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @wz1114841863 on GitHub (Jan 13, 2026).

layers.ipynb specifies requires_grad=True when initializing the Tensor, but this initialization parameter is not specified when constructing the Tensor class in tensor.ipynb. Therefore, an error occurs during execution. Is this behavior as expected?

Image
Originally created by @wz1114841863 on GitHub (Jan 13, 2026). layers.ipynb specifies requires_grad=True when initializing the Tensor, but this initialization parameter is not specified when constructing the Tensor class in tensor.ipynb. Therefore, an error occurs during execution. Is this behavior as expected? <img width="959" height="729" alt="Image" src="https://github.com/user-attachments/assets/392e705c-a70d-43dd-ae88-66b1d65aaa17" />
Author
Owner

@wz1114841863 commented on GitHub (Jan 13, 2026):

I manually modified the Tensor definition in tinytorch/core/tensor.py to ensure the tests in 03-layers run correctly in Jupyter. However, when submitting with tito module complete 03, I encountered the following error. I did not modify any code in Jupyter—only read and understood it—so I'm unsure what caused this issue, especially since all unit tests passed.
Image

@wz1114841863 commented on GitHub (Jan 13, 2026): I manually modified the Tensor definition in `tinytorch/core/tensor.py` to ensure the tests in `03-layers` run correctly in Jupyter. However, when submitting with `tito module complete 03`, I encountered the following error. I did not modify any code in Jupyter—only read and understood it—so I'm unsure what caused this issue, especially since all unit tests passed. <img width="867" height="1039" alt="Image" src="https://github.com/user-attachments/assets/ae6e432c-c718-401c-822c-e993db0d6364" />
Author
Owner

@profvjreddi commented on GitHub (Jan 13, 2026):

This is the same issue we just fixed in PR #1101.

Module 03 was incorrectly passing requires_grad=True to the Tensor constructor, but requires_grad isn't introduced until Module 06 via monkey-patching. I removed the premature requires_grad=True from the Linear layer so students can complete Module 03 without needing autograd.

I just fixed in https://github.com/harvard-edge/cs249r_book/commit/a36340690. I can't believe this slipped through my tests 😮‍💨

If you pull the latest dev branch, this should work now. Thanks for reporting!

@profvjreddi commented on GitHub (Jan 13, 2026): This is the same issue we just fixed in PR #1101. Module 03 was incorrectly passing requires_grad=True to the Tensor constructor, but requires_grad isn't introduced until Module 06 via monkey-patching. I removed the premature requires_grad=True from the Linear layer so students can complete Module 03 without needing autograd. I just fixed in https://github.com/harvard-edge/cs249r_book/commit/a36340690. I can't believe this slipped through my tests 😮‍💨 If you pull the latest `dev` branch, this should work now. Thanks for reporting!
Author
Owner

@profvjreddi commented on GitHub (Jan 23, 2026):

v0.1.4 is now released with this fix! See #1112 for update instructions.

@profvjreddi commented on GitHub (Jan 23, 2026): v0.1.4 is now released with this fix! See #1112 for update instructions.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#479