Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/models/llama/source_transformation/quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ def filter_fn(m, fqn):
),
filter_fn=filter_fn,
)

model = unwrap_tensor_subclass(model)

# TODO: deal with checkpoint / computation dtype decoupling.

if verbose:
Expand Down
8 changes: 2 additions & 6 deletions extension/llm/export/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
from torch.nn.attention import SDPBackend
from torchao.quantization.pt2e.quantize_pt2e import convert_pt2e, prepare_pt2e
from torchao.quantization.pt2e.quantizer import ComposableQuantizer, Quantizer
from torchao.utils import unwrap_tensor_subclass

FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)
Expand Down Expand Up @@ -203,11 +202,6 @@ def _get_edge_config(self) -> EdgeCompileConfig:
return edge_config

def _export(self, module: Optional[torch.nn.Module] = None) -> ExportedProgram:
if module is not None:
unwrap_tensor_subclass(module)
else:
unwrap_tensor_subclass(self.model)

dynamic_shape = self._get_dynamic_shape()
# 1. torch.nn.attention.sdpa_kernel([SDPBackend.MATH]) is for bypassing the dynamo error when tracing
# 2. torch.no_grad() is for getting rid of the dropout (not sure why training ops will show up)
Expand All @@ -226,6 +220,8 @@ def _export(self, module: Optional[torch.nn.Module] = None) -> ExportedProgram:
dynamic_shapes=dynamic_shape,
strict=True,
)
# Functionalize the graph, and decompose subclasses from torchao quantize.
exported_module = exported_module.run_decompositions({})
return exported_module

def export(self) -> "LLMEdgeManager":
Expand Down
Loading