Skip to content

implement packed quantize row / dequantize row API #3915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

SamGinzburg
Copy link
Contributor

Summary:
API for a packed version of quantize/dequantize row.

This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Differential Revision: D72121939

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D72121939

Copy link

netlify bot commented Apr 2, 2025

Deploy Preview for pytorch-fbgemm-docs ready!

Name Link
🔨 Latest commit 41cb838
🔍 Latest deploy log https://app.netlify.com/sites/pytorch-fbgemm-docs/deploys/67ed6a7adc49870008cf9a14
😎 Deploy Preview https://deploy-preview-3915--pytorch-fbgemm-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

SamGinzburg added a commit to SamGinzburg/FBGEMM that referenced this pull request Apr 2, 2025
Summary:
X-link: facebookresearch/FBGEMM#1004


API for a packed version of quantize/dequantize row.


This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939
SamGinzburg added a commit to SamGinzburg/FBGEMM that referenced this pull request Apr 2, 2025
Summary:
X-link: facebookresearch/FBGEMM#1004


API for a packed version of quantize/dequantize row.


This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D72121939

SamGinzburg added a commit to SamGinzburg/FBGEMM that referenced this pull request Apr 2, 2025
Summary:
X-link: facebookresearch/FBGEMM#1004

Pull Request resolved: pytorch#3915

API for a packed version of quantize/dequantize row.

This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D72121939

SamGinzburg added a commit to SamGinzburg/FBGEMM that referenced this pull request Apr 2, 2025
Summary:
X-link: facebookresearch/FBGEMM#1004

Pull Request resolved: pytorch#3915

API for a packed version of quantize/dequantize row.

This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939
SamGinzburg added a commit to SamGinzburg/FBGEMM that referenced this pull request Apr 2, 2025
Summary:
X-link: facebookresearch/FBGEMM#1004


API for a packed version of quantize/dequantize row.


This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939
SamGinzburg added a commit to SamGinzburg/FBGEMM that referenced this pull request Apr 2, 2025
Summary:
X-link: facebookresearch/FBGEMM#1004


API for a packed version of quantize/dequantize row.


This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D72121939

SamGinzburg added a commit to SamGinzburg/FBGEMM that referenced this pull request Apr 2, 2025
Summary:
X-link: facebookresearch/FBGEMM#1004

Pull Request resolved: pytorch#3915

API for a packed version of quantize/dequantize row.

This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939
Summary:
X-link: facebookresearch/FBGEMM#1004

Pull Request resolved: pytorch#3915

API for a packed version of quantize/dequantize row.

This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D72121939

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in def7bbe.

q10 pushed a commit to q10/FBGEMM that referenced this pull request Apr 10, 2025
Summary:
Pull Request resolved: facebookresearch/FBGEMM#1004

X-link: pytorch#3915

API for a packed version of quantize/dequantize row.

This version will return a single, contiguous tensor in memory instead of returning two tensors, and operates on the contiguous tensor.

Example usage:

```
            a = torch.randn(shape, dtype=torch.bfloat16, device="cuda")

            packed_values = quantize_fp8_packed_row_raw(
                a,
                use_triton=True,
            )

            # Undo scaling.
            a_bf16 = dequantize_fp8_packed_row(packed_values)

            torch.testing.assert_close(a_bf16, a, atol=2e-1, rtol=1e-1)
```

A third API: "quantize_fp8_packed_row" mimics the API of quantize_fp8_row (mainly for testing).

Reviewed By: jiawenliu64

Differential Revision: D72121939

fbshipit-source-id: c88f99977e21e64f6f6f7dbb3c7430c2c2b56d0e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants