diff --git a/thunder/core/transform_common.py b/thunder/core/transform_common.py index e21ca4b28a..7b7a97469a 100644 --- a/thunder/core/transform_common.py +++ b/thunder/core/transform_common.py @@ -137,7 +137,7 @@ def dce(trace: Trace, needed_proxies: None | set[Variable] = None) -> Trace: # may mark some of the operation's outputs as unused some_unused = False for out in bsym.flat_proxy_outs: - if variableify(out) in needed_proxies and producer_map[out] == bsym: + if variableify(out) in needed_proxies and producer_map.get(out, None) == bsym: needed = True else: some_unused = True