pytorch - 💡(How to fix) Fix PyTorch 2.12 compile error: Boolean literal getting used as LHS expression

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

PyTorch 2.12.0 compile generates ill-formed code which uses boolean literal as LHS expression:

def forward(self, L_c_ : torch.Tensor, L_a_ : torch.Tensor, L_b_ : torch.Tensor):
    ...
    True &= ne;  iand = True;  ne = iand = None  # SYNTAX ERROR
    ...

This bug only occurs in PyTorch 2.12.0. Tested with 2.10, 2.11, and 2.12, and it was only observed in 2.12.

Error Message

Traceback (most recent call last): File ".../compile_bug.py", line 27, in <module> out = mul(a, b, c=0.5) File ".../lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1047, in compile_wrapper result = fn(*args, **kwargs) File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2474, in call result = self._torchdynamo_orig_backend( File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2192, in call result = self._inner_convert( File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 736, in call result = _compile( File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2025, in _compile raise InternalTorchDynamoError( File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1961, in _compile guarded_code, tracer_output = compile_inner(code, one_graph, hooks) File ".../lib/python3.10/site-packages/torch/_utils_internal.py", line 96, in wrapper_function return function(*args, **kwargs) File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1571, in compile_inner result = _compile_inner(code, one_graph, hooks) File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 16 30, in _compile_inner dynamo_output = compile_frame( File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 14 78, in compile_frame bytecode, tracer_output = transform_code_object(code, transform) File ".../lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1626, in transform_code_object tracer_output = transformations(instructions, code_options) File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1450, in transform tracer_output = trace_frame( File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 343, in _fn return fn(*args, **kwargs) File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 911, in trace_frame run_tracer() File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 892, in run_tracer tracer.run() File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1813, in run while self.step(): File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1480, in step self.dispatch_table[inst.opcode](self, inst) File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5143, in RETURN_VALUE self._return(inst) File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5125, in _return all_stack_locals_metadata = self.output.compile_subgraph( File ".../lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2113, in compile_subgraph self.compile_and_call_fx_graph(tx, pass2.graph_output_vars(), root) File ".../lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2628, in compile_and_call_fx_graph fx.GraphModule(root, self.graph), File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 578, in init self.graph = graph File ".../lib/python3.10/site-packages/torch/nn/modules/module.py", line 2074, in setattr super().setattr(name, value) File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 634, in graph self.recompile() File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 933, in recompile cls.forward = _forward_from_src(self._code, python_code.globals, co_fields) File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 255, in fx_forward_from_src_skip_result result = original_forward_from_src(src, globals, co_fields) File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 110, in _forward_from_src return _method_from_src( File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 120, in _method_from_src _exec_with_source(src, globals_copy, co_fields) File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 106, in _exec_with_source exec(compile(src, key, "exec"), globals) torch._dynamo.exc.InternalTorchDynamoError: SyntaxError: 'True' is an illegal expression for augmented assignment (<eval_with_key>.2, line 10)

Root Cause

PyTorch 2.12.0 compile generates ill-formed code which uses boolean literal as LHS expression:

def forward(self, L_c_ : torch.Tensor, L_a_ : torch.Tensor, L_b_ : torch.Tensor):
    ...
    True &= ne;  iand = True;  ne = iand = None  # SYNTAX ERROR
    ...

This bug only occurs in PyTorch 2.12.0. Tested with 2.10, 2.11, and 2.12, and it was only observed in 2.12.

Fix Action

Fix / Workaround

Traceback (most recent call last):
  File ".../compile_bug.py", line 27, in <module>
    out = mul(a, b, c=0.5)
  File ".../lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1047, in compile_wrapper
    result = fn(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2474, in __call__
    result = self._torchdynamo_orig_backend(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2192, in __call__
    result = self._inner_convert(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 736, in __call__
    result = _compile(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2025, in _compile
    raise InternalTorchDynamoError(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1961, in _compile
    guarded_code, tracer_output = compile_inner(code, one_graph, hooks)
  File ".../lib/python3.10/site-packages/torch/_utils_internal.py", line 96, in wrapper_function
    return function(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1571, in compile_inner
    result = _compile_inner(code, one_graph, hooks)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 16
30, in _compile_inner
    dynamo_output = compile_frame(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 14
78, in compile_frame
    bytecode, tracer_output = transform_code_object(code, transform)
  File ".../lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1626, in transform_code_object
    tracer_output = transformations(instructions, code_options)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1450, in transform
    tracer_output = trace_frame(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 343, in _fn
    return fn(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 911, in trace_frame
    run_tracer()
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 892, in run_tracer
    tracer.run()
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1813, in run
    while self.step():
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1480, in step
    self.dispatch_table[inst.opcode](self, inst)
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5143, in RETURN_VALUE
    self._return(inst)
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5125, in _return
    all_stack_locals_metadata = self.output.compile_subgraph(
  File ".../lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2113, in compile_subgraph
    self.compile_and_call_fx_graph(tx, pass2.graph_output_vars(), root)
  File ".../lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2628, in compile_and_call_fx_graph
    fx.GraphModule(root, self.graph),
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 578, in __init__
    self.graph = graph
  File ".../lib/python3.10/site-packages/torch/nn/modules/module.py", line 2074, in __setattr__
    super().__setattr__(name, value)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 634, in graph
    self.recompile()
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 933, in recompile
    cls.forward = _forward_from_src(self._code, python_code.globals, co_fields)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 255, in fx_forward_from_src_skip_result
    result = original_forward_from_src(src, globals, co_fields)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 110, in _forward_from_src
    return _method_from_src(
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 120, in _method_from_src
    _exec_with_source(src, globals_copy, co_fields)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 106, in _exec_with_source
    exec(compile(src, key, "exec"), globals)
torch._dynamo.exc.InternalTorchDynamoError: SyntaxError: 'True' is an illegal expression for augmented assignment (<eval_with_key>.2, line 10)

CPU: Architecture: aarch64 CPU op-mode(s): 64-bit Byte Order: Little Endian CPU(s): 12 On-line CPU(s) list: 0-11 Vendor ID: Qualcomm Model: 1 Thread(s) per core: 1 Core(s) per socket: 12 Socket(s): 1 Stepping: 0x2 BogoMIPS: 38.40 Flags: fp asimd aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 asimdfhm uscat ilrcpc flagm ssbs sb dcpodp flagm2 frint i8mm bf16 rng afp rpres L1d cache: 1.1 MiB (12 instances) L1i cache: 2.3 MiB (12 instances) L2 cache: 144 MiB (12 instances) Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; __user pointer sanitization Vulnerability Spectre v2: Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Code Example

def forward(self, L_c_ : torch.Tensor, L_a_ : torch.Tensor, L_b_ : torch.Tensor):
    ...
    True &= ne;  iand = True;  ne = iand = None  # SYNTAX ERROR
    ...

---

import torch


@torch.compile
def mul(
    a: torch.Tensor,
    b: torch.Tensor,
    c: float | int | None,
) -> torch.Tensor:
    """
    a * b     ...if c == 0
    a * b + c ...otherwise
    """
    has_bias = c is not None
    has_bias &= c != 0.0

    if has_bias:
        return a * b + c

    return a * b


def main():
    a = torch.randn(10)
    b = torch.randn(10)

    """
    First call: success

    >>> # Generated code:
    >>> def forward(self, L_a_ : torch.Tensor, L_b_ : torch.Tensor):
    >>>     l_a_ = L_a_
    >>>     l_b_ = L_b_
    >>>     mul = l_a_ * l_b_;  l_a_ = l_b_ = None
    >>>     return (mul,)
    """
    _ = mul(a, b, c=0.0)


    """
    Second call: fails with syntax error

    >>> # Generated code:
    >>> def forward(self, L_c_ : torch.Tensor, L_a_ : torch.Tensor, L_b_ : torch.Tensor):
    >>>     l_c_ = L_c_
    >>>     l_a_ = L_a_
    >>>     l_b_ = L_b_
    >>>     item = l_c_.item();  l_c_ = None
    >>>     ne = item != 0.0
    >>>     True &= ne;  iand = True;  ne = iand = None  # SYNTAX ERROR
    >>>     mul = l_a_ * l_b_;  l_a_ = l_b_ = None
    >>>     add = mul + item;  mul = item = None
    >>>     return (add,)
    """
    _ = mul(a, b, c=0.5)


if __name__ == "__main__":
    main()

---

Traceback (most recent call last):
  File ".../compile_bug.py", line 27, in <module>
    out = mul(a, b, c=0.5)
  File ".../lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1047, in compile_wrapper
    result = fn(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2474, in __call__
    result = self._torchdynamo_orig_backend(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2192, in __call__
    result = self._inner_convert(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 736, in __call__
    result = _compile(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2025, in _compile
    raise InternalTorchDynamoError(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1961, in _compile
    guarded_code, tracer_output = compile_inner(code, one_graph, hooks)
  File ".../lib/python3.10/site-packages/torch/_utils_internal.py", line 96, in wrapper_function
    return function(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1571, in compile_inner
    result = _compile_inner(code, one_graph, hooks)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 16
30, in _compile_inner
    dynamo_output = compile_frame(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 14
78, in compile_frame
    bytecode, tracer_output = transform_code_object(code, transform)
  File ".../lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1626, in transform_code_object
    tracer_output = transformations(instructions, code_options)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1450, in transform
    tracer_output = trace_frame(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 343, in _fn
    return fn(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 911, in trace_frame
    run_tracer()
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 892, in run_tracer
    tracer.run()
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1813, in run
    while self.step():
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1480, in step
    self.dispatch_table[inst.opcode](self, inst)
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5143, in RETURN_VALUE
    self._return(inst)
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5125, in _return
    all_stack_locals_metadata = self.output.compile_subgraph(
  File ".../lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2113, in compile_subgraph
    self.compile_and_call_fx_graph(tx, pass2.graph_output_vars(), root)
  File ".../lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2628, in compile_and_call_fx_graph
    fx.GraphModule(root, self.graph),
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 578, in __init__
    self.graph = graph
  File ".../lib/python3.10/site-packages/torch/nn/modules/module.py", line 2074, in __setattr__
    super().__setattr__(name, value)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 634, in graph
    self.recompile()
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 933, in recompile
    cls.forward = _forward_from_src(self._code, python_code.globals, co_fields)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 255, in fx_forward_from_src_skip_result
    result = original_forward_from_src(src, globals, co_fields)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 110, in _forward_from_src
    return _method_from_src(
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 120, in _method_from_src
    _exec_with_source(src, globals_copy, co_fields)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 106, in _exec_with_source
    exec(compile(src, key, "exec"), globals)
torch._dynamo.exc.InternalTorchDynamoError: SyntaxError: 'True' is an illegal expression for augmented assignment (<eval_with_key>.2, line 10)
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

Description

PyTorch 2.12.0 compile generates ill-formed code which uses boolean literal as LHS expression:

def forward(self, L_c_ : torch.Tensor, L_a_ : torch.Tensor, L_b_ : torch.Tensor):
    ...
    True &= ne;  iand = True;  ne = iand = None  # SYNTAX ERROR
    ...

This bug only occurs in PyTorch 2.12.0. Tested with 2.10, 2.11, and 2.12, and it was only observed in 2.12.

Reproducible Example

This error only occurs if the first and second calls are invoked in sequence (order doesn't matter). In other words:

  • This script -> compile error
  • Flip the order of 1st and 2nd call -> compile error
  • Omit 1st or 2nd call -> no error
import torch


@torch.compile
def mul(
    a: torch.Tensor,
    b: torch.Tensor,
    c: float | int | None,
) -> torch.Tensor:
    """
    a * b     ...if c == 0
    a * b + c ...otherwise
    """
    has_bias = c is not None
    has_bias &= c != 0.0

    if has_bias:
        return a * b + c

    return a * b


def main():
    a = torch.randn(10)
    b = torch.randn(10)

    """
    First call: success

    >>> # Generated code:
    >>> def forward(self, L_a_ : torch.Tensor, L_b_ : torch.Tensor):
    >>>     l_a_ = L_a_
    >>>     l_b_ = L_b_
    >>>     mul = l_a_ * l_b_;  l_a_ = l_b_ = None
    >>>     return (mul,)
    """
    _ = mul(a, b, c=0.0)


    """
    Second call: fails with syntax error

    >>> # Generated code:
    >>> def forward(self, L_c_ : torch.Tensor, L_a_ : torch.Tensor, L_b_ : torch.Tensor):
    >>>     l_c_ = L_c_
    >>>     l_a_ = L_a_
    >>>     l_b_ = L_b_
    >>>     item = l_c_.item();  l_c_ = None
    >>>     ne = item != 0.0
    >>>     True &= ne;  iand = True;  ne = iand = None  # SYNTAX ERROR
    >>>     mul = l_a_ * l_b_;  l_a_ = l_b_ = None
    >>>     add = mul + item;  mul = item = None
    >>>     return (add,)
    """
    _ = mul(a, b, c=0.5)


if __name__ == "__main__":
    main()

Error logs

Traceback (most recent call last):
  File ".../compile_bug.py", line 27, in <module>
    out = mul(a, b, c=0.5)
  File ".../lib/python3.10/site-packages/torch/_dynamo/eval_frame.py", line 1047, in compile_wrapper
    result = fn(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2474, in __call__
    result = self._torchdynamo_orig_backend(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2192, in __call__
    result = self._inner_convert(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 736, in __call__
    result = _compile(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 2025, in _compile
    raise InternalTorchDynamoError(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1961, in _compile
    guarded_code, tracer_output = compile_inner(code, one_graph, hooks)
  File ".../lib/python3.10/site-packages/torch/_utils_internal.py", line 96, in wrapper_function
    return function(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1571, in compile_inner
    result = _compile_inner(code, one_graph, hooks)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 16
30, in _compile_inner
    dynamo_output = compile_frame(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 14
78, in compile_frame
    bytecode, tracer_output = transform_code_object(code, transform)
  File ".../lib/python3.10/site-packages/torch/_dynamo/bytecode_transformation.py", line 1626, in transform_code_object
    tracer_output = transformations(instructions, code_options)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 1450, in transform
    tracer_output = trace_frame(
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 343, in _fn
    return fn(*args, **kwargs)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 911, in trace_frame
    run_tracer()
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 892, in run_tracer
    tracer.run()
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1813, in run
    while self.step():
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 1480, in step
    self.dispatch_table[inst.opcode](self, inst)
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5143, in RETURN_VALUE
    self._return(inst)
  File ".../lib/python3.10/site-packages/torch/_dynamo/symbolic_convert.py", line 5125, in _return
    all_stack_locals_metadata = self.output.compile_subgraph(
  File ".../lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2113, in compile_subgraph
    self.compile_and_call_fx_graph(tx, pass2.graph_output_vars(), root)
  File ".../lib/python3.10/site-packages/torch/_dynamo/output_graph.py", line 2628, in compile_and_call_fx_graph
    fx.GraphModule(root, self.graph),
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 578, in __init__
    self.graph = graph
  File ".../lib/python3.10/site-packages/torch/nn/modules/module.py", line 2074, in __setattr__
    super().__setattr__(name, value)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 634, in graph
    self.recompile()
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 933, in recompile
    cls.forward = _forward_from_src(self._code, python_code.globals, co_fields)
  File ".../lib/python3.10/site-packages/torch/_dynamo/convert_frame.py", line 255, in fx_forward_from_src_skip_result
    result = original_forward_from_src(src, globals, co_fields)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 110, in _forward_from_src
    return _method_from_src(
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 120, in _method_from_src
    _exec_with_source(src, globals_copy, co_fields)
  File ".../lib/python3.10/site-packages/torch/fx/graph_module.py", line 106, in _exec_with_source
    exec(compile(src, key, "exec"), globals)
torch._dynamo.exc.InternalTorchDynamoError: SyntaxError: 'True' is an illegal expression for augmented assignment (<eval_with_key>.2, line 10)

Versions

Collecting environment information... PyTorch version: 2.12.0+cpu Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.5 LTS (aarch64) GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0 Clang version: 14.0.0-1ubuntu1.1 CMake version: version 3.22.1 Libc version: glibc-2.35

Python version: 3.10.16 (main, Mar 18 2025, 12:09:19) [GCC 11.4.0] (64-bit runtime) Python platform: Linux-5.15.153.1-microsoft-standard-WSL2-aarch64-with-glibc2.35 Is CUDA available: False CUDA runtime version: No CUDA CUDA_MODULE_LOADING set to: N/A GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA Is XPU available: False HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True Caching allocator config: N/A

CPU: Architecture: aarch64 CPU op-mode(s): 64-bit Byte Order: Little Endian CPU(s): 12 On-line CPU(s) list: 0-11 Vendor ID: Qualcomm Model: 1 Thread(s) per core: 1 Core(s) per socket: 12 Socket(s): 1 Stepping: 0x2 BogoMIPS: 38.40 Flags: fp asimd aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 asimdfhm uscat ilrcpc flagm ssbs sb dcpodp flagm2 frint i8mm bf16 rng afp rpres L1d cache: 1.1 MiB (12 instances) L1i cache: 2.3 MiB (12 instances) L2 cache: 144 MiB (12 instances) Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; __user pointer sanitization Vulnerability Spectre v2: Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] executorch==1.2.0 [pip3] mypy-boto3-s3==1.36.21 [pip3] numpy==2.2.6 [pip3] numpydoc==1.9.0 [pip3] nvidia-cublas==13.1.0.3 [pip3] nvidia-cuda-cupti==13.0.85 [pip3] nvidia-cuda-nvrtc==13.0.88 [pip3] nvidia-cuda-runtime==13.0.96 [pip3] nvidia-cudnn-cu13==9.19.0.56 [pip3] nvidia-cufft==12.0.0.61 [pip3] nvidia-curand==10.4.0.35 [pip3] nvidia-cusolver==12.0.4.66 [pip3] nvidia-cusparse==12.6.3.3 [pip3] nvidia-cusparselt-cu13==0.8.0 [pip3] nvidia-nccl-cu13==2.28.9 [pip3] nvidia-nvjitlink==13.0.88 [pip3] nvidia-nvtx==13.0.85 [pip3] onnx==1.21.0 [pip3] onnx-ir==0.2.1 [pip3] onnxruntime==1.22.1 [pip3] onnxruntime_extensions==0.15.2 [pip3] onnxscript==0.7.0 [pip3] onnxsim==0.4.36 [pip3] pytorch-ignite==0.5.4 [pip3] pytorch_tokenizers==1.2.0 [pip3] torch==2.12.0+cpu [pip3] torchao==0.17.0 [pip3] torchaudio==2.9.1 [pip3] torchvision==0.27.0+cpu [pip3] triton==3.6.0 [conda] Could not collect

cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @amjames @jataylo @azahed98

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix PyTorch 2.12 compile error: Boolean literal getting used as LHS expression