Skip to content

fix(pruning): validate multidimensional tensor in channel-structured pruning (#107) - #108

Open
rohith500 wants to merge 1 commit into
apple:mainfrom
rohith500:fix/pruning-channel-structured-1d
Open

rohith500 wants to merge 1 commit into
apple:mainfrom
rohith500:fix/pruning-channel-structured-1d

Conversation

@rohith500

@rohith500 rohith500 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #107.

Validates that ChannelStructured magnitude pruning is applied to tensors with at least 2 dimensions, raising a descriptive ValueError for 1D tensors instead of crashing with ATen RuntimeError: selected index k out of range. Also adds unit test coverage for 1D tensor validation across positive and negative channel axes.

@u-simha
u-simha self-requested a review September 17, 2026 23:37
@u-simha u-simha self-assigned this Sep 17, 2026
@rohith500
rohith500 force-pushed the fix/pruning-channel-structured-1d branch from bf9fe4b to 7f91afb Compare September 18, 2026 20:41
@rohith500 rohith500 changed the title fix(pruning): handle 1D tensors in channel-structured pruning (#107) fix(pruning): validate multidimensional tensor in channel-structured pruning (#107) Sep 18, 2026
@rohith500

Copy link
Copy Markdown
Contributor Author

Hi @u-simha,

Per your feedback and confirmation on #107, I've updated PR #108 to enforce multidimensional tensor validation:

  1. Validation Check: In _compute_channel_mask, added if weight.ndim < 2: raise ValueError(...) requiring $\ge 2$ dimensions and directing users to Unstructured pruning for 1D tensors.
  2. Early Dispatch: In compute_mask, ChannelStructured is dispatched to _compute_channel_mask so structural constraints are validated upfront even if schedule sparsity is 0.0.
  3. Automated Tests: Updated tests/pruning/test_magnitude_pruner.py with tests verifying ValueError is raised for 1D and 0-D tensors with ChannelStructured across multiple axes and sparsities, and confirming that Unstructured() properly prunes 1D parameters.
  4. Quality Gates: All 26 checks in make check pass cleanly, commit is cryptographically signed, and the Towncrier fragment is updated.

Ready for your review!

@rohith500
rohith500 force-pushed the fix/pruning-channel-structured-1d branch from 7f91afb to e7b90c3 Compare September 30, 2026 17:52
@rohith500
rohith500 force-pushed the fix/pruning-channel-structured-1d branch from e7b90c3 to 5d3eeef Compare October 4, 2026 14:08

This branch has not been deployed

No deployments
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.

[Bug]: ChannelStructured pruning crashes with RuntimeError on 1D tensors (PyTorch sum(dim=[]) scalar collapse)

2 participants