From b89dd05b54137f194c7a327396245fdaad9e2b9c Mon Sep 17 00:00:00 2001 From: Kimish Patel Date: Thu, 10 Jul 2025 11:33:07 -0700 Subject: [PATCH] When replacing literals with placeholders lists are always converted to tuples Summary: THis is needed because lists are not hashable, since they are mutable, and as a result we cannot have literals_to_ph in pattern rewrites used inside reference_representation_rewrite.py Test Plan: CI + next diff relies on this feature Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned] --- torchao/quantization/pt2e/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/torchao/quantization/pt2e/utils.py b/torchao/quantization/pt2e/utils.py index dc5f802fb8..114f6b0ab4 100644 --- a/torchao/quantization/pt2e/utils.py +++ b/torchao/quantization/pt2e/utils.py @@ -1031,6 +1031,8 @@ def replacement(x_i8, scale, zero_point, quant_min, quant_max): continue new_args = [] for arg in node.args: + if isinstance(arg, list): + arg = tuple(arg) # type: ignore[assignment] if ( _is_literal(arg) and arg not in exclude_literals