Skip to content
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

feat: Implement FP8 functionality #2763

Open
wants to merge 124 commits into
base: release/2.3
Choose a base branch
from
Open

feat: Implement FP8 functionality #2763

wants to merge 124 commits into from

Conversation

peri044
Copy link
Collaborator

@peri044 peri044 commented Apr 18, 2024

Description

This PR adds FP8 & BF16 datatype support. It also implements converter for FP8 quantized ops.

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

chore: updates to trt api

chore: trt 10 fixes

chore: more fixes
author Dheeraj Peri <peri.dheeraj@gmail.com> 1711393059 -0700
committer Dheeraj Peri <peri.dheeraj@gmail.com> 1711393072 -0700

chore: minor updates

chore: Fix save failures

chore: minor fixes

chore: remove duplicate bert test case

chore: remove comments

chore: add load api

chore: minor updates

chore: minor updates

chore: minor updates

chore: more updates
@zewenli98
Copy link
Collaborator

@peri044 I remember we've already removed cudnn dependency on the release/2.3, but it still stays here:

__cudnn_version__,

This causes an error when I import torch-trt:

>>> import torch_tensorrt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/scratch.zewenl_sw/docker_workspace/TRT10/TensorRT/py/torch_tensorrt/__init__.py", line 7, in <module>
    from torch_tensorrt._version import (  # noqa: F401
ImportError: cannot import name '__cudnn_version__' from 'torch_tensorrt._version' (/home/scratch.zewenl_sw/docker_workspace/TRT10/TensorRT/py/torch_tensorrt/_version.py)

Can you take a look?

@peri044
Copy link
Collaborator Author

peri044 commented May 17, 2024

@peri044 I remember we've already removed cudnn dependency on the release/2.3, but it still stays here:

__cudnn_version__,

This causes an error when I import torch-trt:

>>> import torch_tensorrt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/scratch.zewenl_sw/docker_workspace/TRT10/TensorRT/py/torch_tensorrt/__init__.py", line 7, in <module>
    from torch_tensorrt._version import (  # noqa: F401
ImportError: cannot import name '__cudnn_version__' from 'torch_tensorrt._version' (/home/scratch.zewenl_sw/docker_workspace/TRT10/TensorRT/py/torch_tensorrt/_version.py)

Can you take a look?

fixed it now

@zewenli98
Copy link
Collaborator

Cool thanks! And did you implement the unit test for torch.ops.trt.quantize_fp8.default?

@github-actions github-actions bot added the documentation Improvements or additions to documentation label May 21, 2024
@zewenli98
Copy link
Collaborator

@peri044 Thanks for the comments. I have refactored based on your suggestions.

examples/dynamo/vgg16_fp8_ptq.py Outdated Show resolved Hide resolved
examples/dynamo/vgg16_fp8_ptq.py Outdated Show resolved Hide resolved
examples/dynamo/vgg16_fp8_ptq.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@gs-olive gs-olive left a comment

Choose a reason for hiding this comment

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

Overall looks good! Added a few comments

py/torch_tensorrt/dynamo/conversion/impl/quantize.py Outdated Show resolved Hide resolved
py/torch_tensorrt/dynamo/conversion/impl/quantize.py Outdated Show resolved Hide resolved
node
for node in gm.graph.nodes
if (
node.op == "placeholder"
and isinstance(node.type, type)
and issubclass(node.type, torch.SymInt)
and not node.users
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do SymInt inputs always have 0 users?

Copy link
Collaborator Author

@peri044 peri044 May 23, 2024

Choose a reason for hiding this comment

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

Nope they have users. But there's one no-user sym_int node added by torch.compile workflow when we do torch._dynamo.mark_dynamic and this pass is removing that specific node.

# bf16 = auto()

f8 = auto()
bf16 = auto()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure this is aligned with main, otherwise the enum values would change version to version

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will be added when we merge this #2845 right ?

@@ -27,7 +27,7 @@
REQUIRE_FULL_COMPILATION = False
DRYRUN = False
HARDWARE_COMPATIBLE = False
SUPPORTED_KERNEL_PRECISIONS = {dtype.f32, dtype.f16, dtype.i8}
SUPPORTED_KERNEL_PRECISIONS = {dtype.f32, dtype.f16, dtype.i8, dtype.f8}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing bf16 here, can you just use a cherrypick of main?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will be added when we merge this #2845 right ?

py/torch_tensorrt/dynamo/conversion/aten_ops_converters.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: lowering Issues re: The lowering / preprocessing passes component: tests Issues re: Tests component: torch_compile documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants