Skip to content

test(tinytorch): regression coverage for core tensor/layers/autograd/optimizer gaps - #1

Merged
Shashank-Tripathi-07 merged 1 commit into
devfrom
mcdc-01-core-tensor-autograd
Aug 15, 2026
Merged

test(tinytorch): regression coverage for core tensor/layers/autograd/optimizer gaps#1
Shashank-Tripathi-07 merged 1 commit into
devfrom
mcdc-01-core-tensor-autograd

Conversation

@Shashank-Tripathi-07

@Shashank-Tripathi-07 Shashank-Tripathi-07 commented Aug 14, 2026

Copy link
Copy Markdown
Owner

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 construction
  • 1D-by-2D matmul shape handling
  • scalar-form reshape(n) and invalid multi-dim/non-divisible reshape(-1, ...) cases
  • transpose() with only one of dim0/dim1 specified
  • Sequential(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 correctness
  • base Function.apply()'s NotImplementedError
  • backward() on a non-scalar tensor without a gradient argument
  • SGD's momentum checkpoint API: has_momentum(), get_momentum_state(), set_momentum_state()

Test plan

  • pytest tests/01_tensor tests/03_layers tests/06_autograd tests/07_optimizers -q passes locally, including all new cases
  • Verified each new test's target behavior directly against a clean origin/dev checkout before adding it

…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.
@github-actions

Copy link
Copy Markdown

🎉 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!

@github-actions

Copy link
Copy Markdown

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.

@Shashank-Tripathi-07
Shashank-Tripathi-07 deleted the mcdc-01-core-tensor-autograd branch August 19, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant