Skip to content

Delete deprecated Int4CPULayout and related code#4149

Merged
jerryzh168 merged 25 commits into
mainfrom
gh/jerryzh168/65/head
Mar 24, 2026
Merged

Delete deprecated Int4CPULayout and related code#4149
jerryzh168 merged 25 commits into
mainfrom
gh/jerryzh168/65/head

Conversation

@pytorch-bot

pytorch-bot Bot commented Mar 23, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 9 Pending

As of commit 2fb716c with merge base bca91b0 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@jerryzh168 jerryzh168 added the module: not user facing Use this tag if you don't want this PR to show up in release notes label Mar 23, 2026
@jerryzh168

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Mar 24, 2026

Copy link
Copy Markdown

Claude finished @jerryzh168's task in 2m 1s —— View job


Review of PR #4149: Delete deprecated Int4CPULayout and related code

  • Gather context and read the diff
  • Review deleted Int4CPULayout implementation
  • Check all import/reference removals are complete
  • Verify no remaining references to deleted code
  • Post review feedback

Overall: Clean deprecation removal. All references to Int4CPULayout, Int4CPUAQTTensorImpl, and the associated dispatch functions have been properly removed across 8 files with no remaining dangling references in the codebase.

Changes Summary

File Change
torchao/dtypes/uintx/int4_cpu_layout.py Entire file deleted (330 lines) — the layout class, tensor impl, and linear dispatch functions
torchao/dtypes/uintx/__init__.py Removed Int4CPULayout import and __all__ entry
torchao/dtypes/__init__.py Removed Int4CPULayout import and __all__ entry
torchao/dtypes/affine_quantized_tensor.py Removed Int4CPULayout from the HQQ raw_output check
torchao/dtypes/affine_quantized_tensor_ops.py Removed CPU int4 linear dispatch registration
torchao/quantization/quant_api.py Removed Int4CPULayout from LAYOUT_TO_ZERO_POINT_DOMAIN and LAYOUT_TO_PRESERVE_ZEROS
test/prototype/test_parq.py Removed Int4CPULayout import and layout assignment
torchao/prototype/parq/quant/config_torchao.py Removed Int4CPULayout import and layout assignment

Potential Issue: Leftover config.version = 1 assignments

After this PR, both test/prototype/test_parq.py:346 and torchao/prototype/parq/quant/config_torchao.py:128 still set config.version = 1 when check_cpu_version(device) is true:

if check_cpu_version(device):
    config.version = 1  # <-- still here

However, _int4_weight_only_quantize_tensor at torchao/quantization/quant_api.py:755 has:

assert config.version == 2

This means on CPU with PyTorch >= 2.6, these code paths will hit an assertion error at runtime. This may be intentional (the Int4CPULayout was the only version 1 implementation for int4, so version 1 is now dead), but if so, the config.version = 1 assignments and the check_cpu_version branches should also be removed rather than left as dead code that will fail at runtime.

If this is expected to be cleaned up in a subsequent PR in this ghstack (e.g., one of #4150#4153), this is fine. Otherwise, consider removing these leftover version 1 assignments in this PR.

Everything else looks good

  • No remaining references to Int4CPULayout, Int4CPUAQTTensorImpl, or _linear_fp_act_uint4_weight_cpu anywhere in the codebase
  • The raw_output check in affine_quantized_tensor.py:288 correctly narrows to just (TensorCoreTiledLayout, PlainLayout)
  • The LAYOUT_TO_* dict cleanups in quant_api.py are correct
  • The dispatch deregistration in affine_quantized_tensor_ops.py is properly paired with the deletion of the implementation

@jerryzh168

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Mar 24, 2026

Copy link
Copy Markdown

Claude finished @jerryzh168's task in 1m 19s —— View job


Re-review of PR #4149: Delete deprecated Int4CPULayout and related code

  • Gather context and read the diff
  • Review all deleted and modified files
  • Check for remaining references to deleted code
  • Verify correctness of remaining code paths
  • Post review feedback

Overall: This PR is clean and ready to merge. All 8 files are correctly updated, and there are zero remaining references to Int4CPULayout, Int4CPUAQTTensorImpl, int4_cpu_layout, or _linear_fp_act_uint4_weight_cpu anywhere in the codebase.

Changes Summary

File Change
torchao/dtypes/uintx/int4_cpu_layout.py Entire file deleted (330 lines) — layout class, tensor impl, and CPU int4 linear dispatch
torchao/dtypes/uintx/__init__.py Removed Int4CPULayout import and __all__ entry
torchao/dtypes/__init__.py Removed Int4CPULayout import and __all__ entry
torchao/dtypes/affine_quantized_tensor.py Removed Int4CPULayout from HQQ raw_output check — now correctly checks (TensorCoreTiledLayout, PlainLayout) only
torchao/dtypes/affine_quantized_tensor_ops.py Removed CPU int4 linear dispatch registration
torchao/quantization/quant_api.py Removed Int4CPULayout from LAYOUT_TO_ZERO_POINT_DOMAIN and LAYOUT_TO_PRESERVE_ZEROS
test/prototype/test_parq.py Removed Int4CPULayout import, check_cpu_version import, and the version 1 / CPU layout branch
torchao/prototype/parq/quant/config_torchao.py Removed Int4CPULayout import, check_cpu_version import, and the version 1 / CPU layout branch; added license header

Previous issue resolved

The previous review flagged leftover config.version = 1 assignments in test_parq.py and config_torchao.py. This has been addressed — both the check_cpu_version imports and the config.version = 1 branches have been fully removed in the current revision.

CI Status

8 of 14 checks passed (Ruff, Build Docs, L4 tests, aarch64 regression tests, PR label check). 6 checks are still in progress or queued (H100 tests, regression tests, MPS tests). No failures.

No issues found. LGTM.


View job

@jerryzh168 jerryzh168 changed the base branch from gh/jerryzh168/65/base to main March 24, 2026 20:02
@jerryzh168 jerryzh168 merged commit 1b2682d into main Mar 24, 2026
33 of 36 checks passed
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: not user facing Use this tag if you don't want this PR to show up in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants