Add embedding op support for Float8Tensor with PerGroup quantization#4175
Merged
jerryzh168 merged 2 commits intomainfrom Mar 26, 2026
Merged
Add embedding op support for Float8Tensor with PerGroup quantization#4175jerryzh168 merged 2 commits intomainfrom
jerryzh168 merged 2 commits intomainfrom
Conversation
Summary: - Add granularity field to Float8WeightOnlyConfig supporting PerTensor, PerRow (default), and PerGroup - Previously hardcoded to PerRow(); now users can pass e.g. Float8WeightOnlyConfig(granularity=PerGroup(64)) for per-group float8 weight quantization - Update FP8Granularity type alias to include PerGroup Test Plan: - Added PerGroup(64) to existing test_fp8_linear_variants parametrization - Updated check_weight_scaling helpers to verify PerGroup scale shapes (N, K // group_size) - Existing weight-only tests now pass granularity to config instead of ignoring it - Run: python -m pytest test/quantization/quantize_/workflows/float8/test_float8_tensor.py -xvs -k "Float8WeightOnly" Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: - Register `aten.embedding.default` and `F.embedding` ops for Float8Tensor - Implementation dequantizes the weight then calls the original op - Two separate registrations with correct arg order for each dispatch path: `aten.embedding.default` uses (weight, indices) and `F.embedding` uses (indices, weight) - Works with all granularities (PerTensor, PerRow, PerGroup) Test Plan: - Added `test_fp8_embedding` parametrized with PerRow/PerGroup(64) and both dispatch paths (torch_function and aten) - Verifies quantize_ succeeds on nn.Embedding, output shape matches, and SQNR > 20 - Run: `python -m pytest test/quantization/quantize_/workflows/float8/test_float8_tensor.py -xvs -k "test_fp8_embedding"` [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4175
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 8a212ce with merge base 02105d4 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
jerryzh168
added a commit
that referenced
this pull request
Mar 25, 2026
Summary: - Register `aten.embedding.default` and `F.embedding` ops for Float8Tensor - Implementation dequantizes the weight then calls the original op - Two separate registrations with correct arg order for each dispatch path: `aten.embedding.default` uses (weight, indices) and `F.embedding` uses (indices, weight) - Works with all granularities (PerTensor, PerRow, PerGroup) Test Plan: - Added `test_fp8_embedding` parametrized with PerRow/PerGroup(64) and both dispatch paths (torch_function and aten) - Verifies quantize_ succeeds on nn.Embedding, output shape matches, and SQNR > 20 - Run: `python -m pytest test/quantization/quantize_/workflows/float8/test_float8_tensor.py -xvs -k "test_fp8_embedding"` ghstack-source-id: c57981c Pull Request resolved: #4175
howardzhang-cv
approved these changes
Mar 25, 2026
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.
Stack from ghstack (oldest at bottom):
Summary:
aten.embedding.defaultandF.embeddingops for Float8Tensoraten.embedding.defaultuses (weight, indices) andF.embeddinguses (indices, weight)Test Plan:
test_fp8_embeddingparametrized with PerRow/PerGroup(64) and both dispatch paths (torch_function and aten)python -m pytest test/quantization/quantize_/workflows/float8/test_float8_tensor.py -xvs -k "test_fp8_embedding"