[PR #1338] [MERGED] fix(tests/10_tokenization): replace raw numpy array params with Tensor in DummyModel #7284

Closed
opened 2026-04-24 17:23:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1338
Author: @Shashank-Tripathi-07
Created: 4/16/2026
Status: Merged
Merged: 4/16/2026
Merged by: @profvjreddi

Base: devHead: fix/tokenization-dummy-model-numpy-params


📝 Commits (3)

  • 19c7e69 test(tinytorch): add finite-difference gradient correctness tests for Module 06
  • 2b7ff80 fix(tests/06_autograd): rewrite gradient correctness tests to pass CI
  • 96e672b fix(tests/10_tokenization): replace raw numpy array params with Tensor in DummyModel

📊 Changes

2 files changed (+397 additions, -1 deletions)

View changed files

tinytorch/tests/06_autograd/test_gradient_correctness.py (+392 -0)
📝 tinytorch/tests/10_tokenization/test_10_tokenization_progressive.py (+5 -1)

📄 Description

Summary

`DummyModel.parameters()` in `test_progressive_stability` was returning `[np.array([1.0])]`. Any `Trainer.init` that iterates `model.parameters()` and accesses `param.requires_grad` crashes with:

```
AttributeError: 'numpy.ndarray' object has no attribute 'requires_grad'
```

This is a latent bug in the test itself: every other test stub in this file already uses `Tensor(np.array(...), requires_grad=True)` for parameters. `DummyModel` was the one outlier.

Fix

Give `DummyModel` a proper `Tensor` parameter with `requires_grad=True`, consistent with the rest of the test file and with what `Trainer` actually expects.

Files

File Change
`tinytorch/tests/10_tokenization/test_10_tokenization_progressive.py` `DummyModel` now stores a `Tensor` param instead of a raw `np.array`

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1338 **Author:** [@Shashank-Tripathi-07](https://github.com/Shashank-Tripathi-07) **Created:** 4/16/2026 **Status:** ✅ Merged **Merged:** 4/16/2026 **Merged by:** [@profvjreddi](https://github.com/profvjreddi) **Base:** `dev` ← **Head:** `fix/tokenization-dummy-model-numpy-params` --- ### 📝 Commits (3) - [`19c7e69`](https://github.com/harvard-edge/cs249r_book/commit/19c7e69ea5ccc315d692c30f16adc831125e1c88) test(tinytorch): add finite-difference gradient correctness tests for Module 06 - [`2b7ff80`](https://github.com/harvard-edge/cs249r_book/commit/2b7ff801ee09a20571d7d048605bba6d9e4929d9) fix(tests/06_autograd): rewrite gradient correctness tests to pass CI - [`96e672b`](https://github.com/harvard-edge/cs249r_book/commit/96e672bc7fd9c72492d21f2d54c9214fcc6d6550) fix(tests/10_tokenization): replace raw numpy array params with Tensor in DummyModel ### 📊 Changes **2 files changed** (+397 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `tinytorch/tests/06_autograd/test_gradient_correctness.py` (+392 -0) 📝 `tinytorch/tests/10_tokenization/test_10_tokenization_progressive.py` (+5 -1) </details> ### 📄 Description ## Summary \`DummyModel.parameters()\` in \`test_progressive_stability\` was returning \`[np.array([1.0])]\`. Any \`Trainer.__init__\` that iterates \`model.parameters()\` and accesses \`param.requires_grad\` crashes with: \`\`\` AttributeError: 'numpy.ndarray' object has no attribute 'requires_grad' \`\`\` This is a latent bug in the test itself: every other test stub in this file already uses \`Tensor(np.array(...), requires_grad=True)\` for parameters. \`DummyModel\` was the one outlier. ## Fix Give \`DummyModel\` a proper \`Tensor\` parameter with \`requires_grad=True\`, consistent with the rest of the test file and with what \`Trainer\` actually expects. ## Files | File | Change | |------|--------| | \`tinytorch/tests/10_tokenization/test_10_tokenization_progressive.py\` | \`DummyModel\` now stores a \`Tensor\` param instead of a raw \`np.array\` | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-24 17:23:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#7284