Conversation
rohith500
force-pushed
the
fix/pruning-channel-structured-1d
branch
from
September 18, 2026 20:41
bf9fe4b to
7f91afb
Compare
Contributor
Author
|
Hi @u-simha, Per your feedback and confirmation on #107, I've updated PR #108 to enforce multidimensional tensor validation:
Ready for your review! |
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 of Changes
Closes #107.
Per maintainer alignment with @u-simha in Issue #107, this PR validates that
ChannelStructuredmagnitude pruning is applied to tensors with at least 2 dimensions, raising an informativeValueErrorfor 1D or 0D tensors instead of crashing with ATenRuntimeError: selected index k out of range._compute_channel_mask:src/coreai_opt/pruning/spec/prune.py:torch.nn.utils.prune._validate_structured_pruning), ensuring that the concept of "channels" is well-defined.Unstructuredpruning for 1D parameters (e.g.biasor normalization weights).compute_mask:ChannelStructureddirectly to_compute_channel_maskso scheme-specific structural constraints are checked even if the schedule's initial sparsity is0.0._compute_channel_maskcontinues to handlesparsity == 0.0(num_prune == 0) andsparsity >= 1.0directly.Automated Tests Added
In
tests/pruning/test_magnitude_pruner.py:test_channel_structured_1d_tensor_raises:ChannelStructuredto a 1D tensor via_MagnitudePruneImpl.compute_maskraisesValueErrormatching"Channel-structured pruning requires a tensor with at least 2 dimensions"acrossaxis=0,axis=-1, and multiple sparsity levels (including0.0).test_channel_structured_0d_scalar_raises:ChannelStructuredto a 0-D scalar raisesValueError.test_channel_structured_1d_parameter_model_raises:MagnitudePruner.prepare) when a 1D parameter (biasofnn.Linear) is configured withChannelStructured, verifying it raisesValueError.test_unstructured_1d_tensor_supported:Unstructuredpruning properly supports 1D parameters (bias), confirming the suggested alternative in the error message.Verification
pytest tests/pruning/test_magnitude_pruner.py: 46 passed, 1 xfailed in 0.31s.pytest tests/pruning/: 85 passed, 1 xfailed in 3m 03s.make check: All checks passed (26/26):ruff,darkerruff-lint,checkmake,pymarkdown 0.9.40): Passed__all__, import aliasing): PassedChecklist
fix(pruning): validate multidimensional tensor in channel-structured pruning (#107))SHA256:0wr/nMrZodwxsOOHBGpcwRXPk8c3rePKishJLzmhj98)changelog.d/107.fixed)make checkwithout warnings or diff pollution