test(tinytorch): regression coverage for core tensor/layers/autograd/optimizer gaps - #1
Merged
Merged
Conversation
…rad/optimizer gaps An MC/DC-focused audit found several code paths in these four foundational modules that behave correctly but had zero test coverage: empty tensor construction, non-square matmul shapes, scalar-form reshape, partial transpose args, multi-positional-arg Sequential, Dropout's validation and training-gate logic, sum(axis=...) backward gradients, the base Function class's NotImplementedError, backward() on a non-scalar without a gradient arg, and the SGD momentum checkpoint API (has_momentum/get_momentum_state/ set_momentum_state). These are pure regression tests, no source or package files were touched. Each new test was verified against a clean origin/dev checkout before being added, confirming the behavior it locks in is correct today, so a future refactor can no longer break these paths silently.
|
🎉 Thanks for contributing to StaffML! We appreciate you sharing your knowledge. A maintainer will review the math and logic shortly. P.S. If you haven't already, please drop a ⭐ on the repository! |
This was referenced Aug 14, 2026
|
Thanks @Shashank-Tripathi-07! 🎉 @Shashank-Tripathi-07 was already credited in tinytorch for: code, test. The contributor tables are now handled directly by this workflow; no follow-up command is needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds regression tests for core tensor/layers/autograd/optimizer gaps found by an MC/DC audit. Independent of the other companion PRs in this series (#2, #3, #4, #5), each covers a different module group and can be reviewed/merged in any order.
Covered gaps:
Tensor([])empty-list constructionreshape(n)and invalid multi-dim/non-divisiblereshape(-1, ...)casestranspose()with only one of dim0/dim1 specifiedSequential(layer1, layer2)multi-positional-arg construction (previously only tested via a locally shadowed mock class, not the real class)Dropout's bounds validation and training-gate logic (previously zero coverage in the standalone pytest suite)sum(axis=...)backward gradient correctnessFunction.apply()'sNotImplementedErrorbackward()on a non-scalar tensor without a gradient argumenthas_momentum(),get_momentum_state(),set_momentum_state()Test plan
pytest tests/01_tensor tests/03_layers tests/06_autograd tests/07_optimizers -qpasses locally, including all new cases