Skip to content

Move BlockSparseWeightConfig to prototype and deprecate torchao.sparsity imports (#4230)#4232

Open
jerryzh168 wants to merge 5 commits intogh/jerryzh168/78/basefrom
gh/jerryzh168/78/head
Open

Move BlockSparseWeightConfig to prototype and deprecate torchao.sparsity imports (#4230)#4232
jerryzh168 wants to merge 5 commits intogh/jerryzh168/78/basefrom
gh/jerryzh168/78/head

Conversation

@jerryzh168
Copy link
Copy Markdown
Contributor

@jerryzh168 jerryzh168 commented Apr 3, 2026

Stack from ghstack (oldest at bottom):

BlockSparseWeightConfig, BlockSparseTensor, and related code have been
moved from torchao.sparsity to torchao.prototype.sparsity. Stub imports
remain in the old location and emit DeprecationWarnings to guide users
to the new paths. The block sparse test has also been moved to
test/prototype/test_blocksparse.py.

Deprecation Note:

Importing BlockSparseWeightConfig (or its alias block_sparse_weight)
from torchao.sparsity is deprecated. Please update your imports:

# Before (deprecated):
from torchao.sparsity import block_sparse_weight
from torchao.sparsity import BlockSparseWeightConfig
from torchao.sparsity.blocksparse import BlockSparseTensor

# After:
from torchao.prototype.sparsity import block_sparse_weight
from torchao.prototype.sparsity import BlockSparseWeightConfig
from torchao.prototype.sparsity.blocksparse import BlockSparseTensor

The old import paths will be removed in a future release.
See #4230 for more details.

BlockSparseWeightConfig is deprecated and will be removed in a future
release. A warning is now emitted on instantiation pointing users to
the tracking issue for more details.

Deprecation Note:

# 0.17:
BlockSparseWeightConfig(blocksize)

# 0.18 (deprecated):
BlockSparseWeightConfig(blocksize)

# 0.19 (removed):
See #4230 for more details.

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 3, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4232

Note: Links to docs will display an error until the docs builds have been completed.

❌ 6 New Failures, 2 Unrelated Failures

As of commit 3a29570 with merge base a302c10 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

jerryzh168 added a commit that referenced this pull request Apr 3, 2026
BlockSparseWeightConfig is deprecated and will be removed in a future
release. A warning is now emitted on instantiation pointing users to
the tracking issue for more details.

Deprecation Note:

# 0.17:
BlockSparseWeightConfig(blocksize)

# 0.18 (deprecated):
BlockSparseWeightConfig(blocksize)

# 0.19 (removed):
See #4230 for more details.

ghstack-source-id: 165273f
Pull Request resolved: #4232
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 3, 2026
@jerryzh168 jerryzh168 added the module: deprecation Use this tag if this PR deprecates a feature label Apr 3, 2026
BlockSparseWeightConfig is deprecated and will be removed in a future
release. A warning is now emitted on instantiation pointing users to
the tracking issue for more details.

Deprecation Note:
```
# 0.17:
BlockSparseWeightConfig(blocksize)

# 0.18 (deprecated):
BlockSparseWeightConfig(blocksize)

# 0.19 (removed):
See #4230 for more details.
```

[ghstack-poisoned]
@jerryzh168 jerryzh168 requested a review from vkuzo as a code owner April 17, 2026 02:48
jerryzh168 added a commit that referenced this pull request Apr 17, 2026
…ity imports (#4230)

BlockSparseWeightConfig, BlockSparseTensor, and related code have been
moved from torchao.sparsity to torchao.prototype.sparsity. Stub imports
remain in the old location and emit DeprecationWarnings to guide users
to the new paths. The block sparse test has also been moved to
test/prototype/test_blocksparse.py.

Deprecation Note:

Importing BlockSparseWeightConfig (or its alias block_sparse_weight)
from torchao.sparsity is deprecated. Please update your imports:

# Before (deprecated):
from torchao.sparsity import block_sparse_weight
from torchao.sparsity import BlockSparseWeightConfig
from torchao.sparsity.blocksparse import BlockSparseTensor

# After:
from torchao.prototype.sparsity import block_sparse_weight
from torchao.prototype.sparsity import BlockSparseWeightConfig
from torchao.prototype.sparsity.blocksparse import BlockSparseTensor

The old import paths will be removed in a future release.
See #4230 for more details.

ghstack-source-id: 6bc1af1
Pull Request resolved: #4232
@jerryzh168 jerryzh168 changed the title Add deprecation warning for BlockSparseWeightConfig (#4230) Move BlockSparseWeightConfig to prototype and deprecate torchao.sparsity imports (#4230) Apr 17, 2026
…rchao.sparsity imports (#4230)"

BlockSparseWeightConfig, BlockSparseTensor, and related code have been
moved from torchao.sparsity to torchao.prototype.sparsity. Stub imports
remain in the old location and emit DeprecationWarnings to guide users
to the new paths. The block sparse test has also been moved to
test/prototype/test_blocksparse.py.

Deprecation Note:

Importing BlockSparseWeightConfig (or its alias block_sparse_weight)
from torchao.sparsity is deprecated. Please update your imports:

# Before (deprecated):
from torchao.sparsity import block_sparse_weight
from torchao.sparsity import BlockSparseWeightConfig
from torchao.sparsity.blocksparse import BlockSparseTensor

# After:
from torchao.prototype.sparsity import block_sparse_weight
from torchao.prototype.sparsity import BlockSparseWeightConfig
from torchao.prototype.sparsity.blocksparse import BlockSparseTensor

The old import paths will be removed in a future release.
See #4230 for more details.

[ghstack-poisoned]
jerryzh168 added a commit that referenced this pull request Apr 17, 2026
…ity imports (#4230)

BlockSparseWeightConfig, BlockSparseTensor, and related code have been
moved from torchao.sparsity to torchao.prototype.sparsity. Stub imports
remain in the old location and emit DeprecationWarnings to guide users
to the new paths. The block sparse test has also been moved to
test/prototype/test_blocksparse.py.

Deprecation Note:

Importing BlockSparseWeightConfig (or its alias block_sparse_weight)
from torchao.sparsity is deprecated. Please update your imports:

# Before (deprecated):
from torchao.sparsity import block_sparse_weight
from torchao.sparsity import BlockSparseWeightConfig
from torchao.sparsity.blocksparse import BlockSparseTensor

# After:
from torchao.prototype.sparsity import block_sparse_weight
from torchao.prototype.sparsity import BlockSparseWeightConfig
from torchao.prototype.sparsity.blocksparse import BlockSparseTensor

The old import paths will be removed in a future release.
See #4230 for more details.

ghstack-source-id: 6bc1af1
Pull Request resolved: #4232
…rchao.sparsity imports (#4230)"


BlockSparseWeightConfig, BlockSparseTensor, and related code have been
moved from torchao.sparsity to torchao.prototype.sparsity. Stub imports
remain in the old location and emit DeprecationWarnings to guide users
to the new paths. The block sparse test has also been moved to
test/prototype/test_blocksparse.py.

Deprecation Note:
```
Importing BlockSparseWeightConfig (or its alias block_sparse_weight)
from torchao.sparsity is deprecated. Please update your imports:

# Before (deprecated):
from torchao.sparsity import block_sparse_weight
from torchao.sparsity import BlockSparseWeightConfig
from torchao.sparsity.blocksparse import BlockSparseTensor

# After:
from torchao.prototype.sparsity import block_sparse_weight
from torchao.prototype.sparsity import BlockSparseWeightConfig
from torchao.prototype.sparsity.blocksparse import BlockSparseTensor
```

The old import paths will be removed in a future release.
See #4230 for more details.

[ghstack-poisoned]
jerryzh168 added a commit that referenced this pull request Apr 17, 2026
…ity imports (#4230)

BlockSparseWeightConfig, BlockSparseTensor, and related code have been
moved from torchao.sparsity to torchao.prototype.sparsity. Stub imports
remain in the old location and emit DeprecationWarnings to guide users
to the new paths. The block sparse test has also been moved to
test/prototype/test_blocksparse.py.

Deprecation Note:

Importing BlockSparseWeightConfig (or its alias block_sparse_weight)
from torchao.sparsity is deprecated. Please update your imports:

# Before (deprecated):
from torchao.sparsity import block_sparse_weight
from torchao.sparsity import BlockSparseWeightConfig
from torchao.sparsity.blocksparse import BlockSparseTensor

# After:
from torchao.prototype.sparsity import block_sparse_weight
from torchao.prototype.sparsity import BlockSparseWeightConfig
from torchao.prototype.sparsity.blocksparse import BlockSparseTensor

The old import paths will be removed in a future release.
See #4230 for more details.

ghstack-source-id: e3cc825
Pull Request resolved: #4232
…rchao.sparsity imports (#4230)"


BlockSparseWeightConfig, BlockSparseTensor, and related code have been
moved from torchao.sparsity to torchao.prototype.sparsity. Stub imports
remain in the old location and emit DeprecationWarnings to guide users
to the new paths. The block sparse test has also been moved to
test/prototype/test_blocksparse.py.

Deprecation Note:
```
Importing BlockSparseWeightConfig (or its alias block_sparse_weight)
from torchao.sparsity is deprecated. Please update your imports:

# Before (deprecated):
from torchao.sparsity import block_sparse_weight
from torchao.sparsity import BlockSparseWeightConfig
from torchao.sparsity.blocksparse import BlockSparseTensor

# After:
from torchao.prototype.sparsity import block_sparse_weight
from torchao.prototype.sparsity import BlockSparseWeightConfig
from torchao.prototype.sparsity.blocksparse import BlockSparseTensor
```

The old import paths will be removed in a future release.
See #4230 for more details.

[ghstack-poisoned]
jerryzh168 added a commit that referenced this pull request Apr 17, 2026
…ity imports (#4230)

BlockSparseWeightConfig, BlockSparseTensor, and related code have been
moved from torchao.sparsity to torchao.prototype.sparsity. Stub imports
remain in the old location and emit DeprecationWarnings to guide users
to the new paths. The block sparse test has also been moved to
test/prototype/test_blocksparse.py.

Deprecation Note:

Importing BlockSparseWeightConfig (or its alias block_sparse_weight)
from torchao.sparsity is deprecated. Please update your imports:

# Before (deprecated):
from torchao.sparsity import block_sparse_weight
from torchao.sparsity import BlockSparseWeightConfig
from torchao.sparsity.blocksparse import BlockSparseTensor

# After:
from torchao.prototype.sparsity import block_sparse_weight
from torchao.prototype.sparsity import BlockSparseWeightConfig
from torchao.prototype.sparsity.blocksparse import BlockSparseTensor

The old import paths will be removed in a future release.
See #4230 for more details.

ghstack-source-id: 017f502
Pull Request resolved: #4232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: deprecation Use this tag if this PR deprecates a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant