Skip to content

Metal backend: support 4-bit linear#17117

Open
manuelcandales wants to merge 5 commits intogh/manuelcandales/153/headfrom
gh/manuelcandales/154/head
Open

Metal backend: support 4-bit linear#17117
manuelcandales wants to merge 5 commits intogh/manuelcandales/153/headfrom
gh/manuelcandales/154/head

Conversation

@manuelcandales
Copy link
Contributor

@manuelcandales manuelcandales commented Feb 2, 2026

This pull request adds support for 4-bit quantized linear in the Metal backend

Dtype support improvements:

  • Added support for the uint8 dtype (PyTorch dtype code 0) in the AOTInductor shims, including new function aoti_torch_dtype_uint8() and updates to dtype conversion utilities and supported dtype checks. (backends/aoti/common_shims.cpp, backends/aoti/common_shims.h, backends/aoti/utils.h, backends/apple/metal/runtime/shims/utils.cpp, backends/apple/metal/runtime/shims/utils.h) [1] [2] [3] [4] [5] [6]

Metal backend kernel and operator integration:

  • Registered the new torchao::_linear_fp_act_4bit_weight operator as a supported fallback kernel and added its C shim signature for the Metal backend. (backends/apple/metal/metal_backend.py, backends/apple/metal/runtime/shims/et_metal_ops.h) [1] [2]

Build and logging enhancements:

  • Updated Metal backend compile options to inject custom operator C shims and improved logging for shared library loading in the Metal backend. (backends/apple/metal/metal_backend.py, backends/apple/metal/runtime/metal_backend.cpp) [1] [2] [3]

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 2, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17117

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

❌ 4 New Failures, 1 Unrelated Failure

As of commit c5a3c1a with merge base ba6de95 (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@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 Feb 2, 2026
@manuelcandales manuelcandales requested review from larryliu0820 and mergennachin and removed request for cccclai and shoumikhin February 2, 2026 21:31
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Comment on lines +33 to +50
# Function to update and build torchao
update_and_build_torchao() {
echo "Building torchao..."
TORCHAO_DIR="$EXECUTORCH_ROOT/third-party/ao"
if [[ -d "$TORCHAO_DIR" ]]; then
cd "$TORCHAO_DIR"
echo "Pulling latest changes from ao repository..."
git checkout main
git pull origin main
USE_CPP=1 TORCHAO_BUILD_EXPERIMENTAL_MPS=1 pip install . --no-build-isolation
cd "$EXECUTORCH_ROOT"
echo "torchao build complete"
else
echo "Error: torchao directory not found at $TORCHAO_DIR"
exit 1
fi
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this. Just upgrade the pin

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants