From 9853a8432b8a17e0ce8c65f186ed116b6004c44f Mon Sep 17 00:00:00 2001 From: ssjia Date: Mon, 9 Mar 2026 09:14:10 -0700 Subject: [PATCH 1/3] [ET-VK][ez] Fix duplicate placeholder target in create_constant_placeholder When multiple pattern replacements (e.g., quantized conv and quantized linear) share the same weight parameter, each independently calls create_constant_placeholder to create a _sums placeholder with the same name. torch.fx.Graph.create_node deduplicates node.name but not node.target, so the second call produces a placeholder with a unique name but a duplicate target. Since recompile() uses node.target for function parameter names, this causes a SyntaxError: duplicate argument in function definition. Fix by checking the state_dict/constants dicts (O(1) lookup) before creating the node. If the name already exists, find and return the existing placeholder node. Differential Revision: [D95807071](https://our.internmc.facebook.com/intern/diff/D95807071/) [ghstack-poisoned] --- backends/transforms/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backends/transforms/utils.py b/backends/transforms/utils.py index ef19a937b0b..cb3e8c9469a 100644 --- a/backends/transforms/utils.py +++ b/backends/transforms/utils.py @@ -111,6 +111,15 @@ def create_constant_placeholder( target = name + # If a placeholder with this target already exists, return it to avoid + # duplicate parameter names in the generated function signature which would + # cause a SyntaxError on recompile. This can happen when multiple pattern + # replacements independently create placeholders for a shared weight. + if name in exp_program.state_dict or name in exp_program.constants: + for n in graph.nodes: + if n.op == "placeholder" and n.target == name: + return n + # Add data to state_dict/ constants match kind: case InputKind.PARAMETER: From b9c8d41eb13dd125382c2f88bd1c0cdaa425edbc Mon Sep 17 00:00:00 2001 From: ssjia Date: Mon, 9 Mar 2026 10:15:48 -0700 Subject: [PATCH 2/3] Update on "[ET-VK][ez] Fix duplicate placeholder target in create_constant_placeholder" When multiple pattern replacements (e.g., quantized conv and quantized linear) share the same weight parameter, each independently calls create_constant_placeholder to create a _sums placeholder with the same name. torch.fx.Graph.create_node deduplicates node.name but not node.target, so the second call produces a placeholder with a unique name but a duplicate target. Since recompile() uses node.target for function parameter names, this causes a SyntaxError: duplicate argument in function definition. Fix by checking the state_dict/constants dicts (O(1) lookup) before creating the node. If the name already exists, find and return the existing placeholder node. Differential Revision: [D95807071](https://our.internmc.facebook.com/intern/diff/D95807071/) [ghstack-poisoned] From aeff39cb911cea5e0da273694b8edeb1bb0eb5cb Mon Sep 17 00:00:00 2001 From: ssjia Date: Mon, 9 Mar 2026 12:11:28 -0700 Subject: [PATCH 3/3] Update on "[ET-VK][ez] Fix duplicate placeholder target in create_constant_placeholder" When multiple pattern replacements (e.g., quantized conv and quantized linear) share the same weight parameter, each independently calls create_constant_placeholder to create a _sums placeholder with the same name. torch.fx.Graph.create_node deduplicates node.name but not node.target, so the second call produces a placeholder with a unique name but a duplicate target. Since recompile() uses node.target for function parameter names, this causes a SyntaxError: duplicate argument in function definition. Fix by checking the state_dict/constants dicts (O(1) lookup) before creating the node. If the name already exists, find and return the existing placeholder node. Differential Revision: [D95807071](https://our.internmc.facebook.com/intern/diff/D95807071/) [ghstack-poisoned]