Repository: pytorch
Issue: Torch Inductor Windows Path Escape Characters
Labels: module: windows,triaged,oncall: pt2,module: inductor

### 🐛 Describe the bug

---

## **### Bug Description**

When using `torch.compile` with the Inductor backend on a Windows system, Torch Inductor generates temporary Python files that include Windows-style file paths with unescaped backslashes (`\`). This results in malformed Unicode escape sequences (e.g., `\U`) within string literals, causing Python to raise a `SyntaxError` during the import of these generated files. Consequently, the compilation process fails, preventing the successful execution of the compiled model or function.

**Key Points:**
- **Path Handling Issue:** Temporary files generated by Torch Inductor contain Windows paths with single backslashes, which are incorrectly interpreted as escape characters in Python strings.
- **Resulting Error:** Malformed Unicode escape sequences lead to `SyntaxError`, disrupting the compilation process.
- **Impact:** Prevents the use of `torch.compile` with the Inductor backend on Windows, hindering performance optimizations and deployment workflows.

**Expected Behavior:**
Torch Inductor should correctly handle Windows-style file paths by properly escaping backslashes, using raw strings, or adopting forward slashes to ensure that generated Python code is syntactically valid and executable without errors.

---
### Malformed generated code
```python

# AOT ID: ['0_inference']
from ctypes import c_void_p, c_long
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align

from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


cpp_fused__to_copy_0 = async_compile.cpp_pybinding(['float*'], '''
#include "C:\Users\sigur\AppData\Local\Temp\torchinductor_sigur\sk\cskh5dx62fglpphcrl6723dnmowdabouerrzy3dmqcngbxwfa7bv.h"
extern "C" void kernel(float* out_ptr0)
{
    #pragma omp parallel num_threads(16)
    {
        int tid = omp_get_thread_num();
        {
            #pragma omp for
            for(long x0=static_cast<long>(0L); x0<static_cast<long>(160L); x0+=static_cast<long>(1L))
            {
                #pragma GCC ivdep
                for(long x1=static_cast<long>(0L); x1<static_cast<long>(475L); x1+=static_cast<long>(1L))
                {
                    auto tmp0 = (-1L)*x0;
                    auto tmp1 = c10::convert<float>(tmp0);
                    auto tmp2 = static_cast<float>(0.00625);
                    auto tmp3 = decltype(tmp1)(tmp1 * tmp2);
                    auto tmp4 = c10::convert<double>(tmp3);
                    auto tmp5 = (-17L) + x1;
                    auto tmp6 = c10::convert<double>(tmp5);
                    auto tmp7 = static_cast<double>(0.0022675736961451248);
                    auto tmp8 = decltype(tmp6)(tmp6 * tmp7);
                    auto tmp9 = decltype(tmp4)(tmp4 + tmp8);
                    auto tmp10 = static_cast<double>(158.4);
                    auto tmp11 = decltype(tmp9)(tmp9 * tmp10);
                    auto tmp12 = static_cast<double>(-6.0);
                    auto tmp13 = max_propagate_nan(tmp11, tmp12);
                    auto tmp14 = static_cast<double>(6.0);
                    auto tmp15 = min_propagate_nan(tmp13, tmp14);
                    auto tmp16 = static_cast<double>(3.141592653589793);
                    auto tmp17 = decltype(tmp15)(tmp15 * tmp16);
                    auto tmp18 = static_cast<double>(0.0);
                    auto tmp19 = tmp17 == tmp18;
                    auto tmp20 = std::sin(tmp17);
                    auto tmp21 = tmp20 / tmp17;
                    auto tmp22 = static_cast<double>(1.0);
                    auto tmp23 = tmp19 ? tmp22 : tmp21;
                    auto tmp24 = static_cast<double>(0.16666666666666666);
                    auto tmp25 = decltype(tmp17)(tmp17 * tmp24);
                    auto tmp26 = static_cast<double>(0.5);
                    auto tmp27 = decltype(tmp25)(tmp25 * tmp26);
                    auto tmp28 = std::cos(tmp27);
                    auto tmp29 = decltype(tmp28)(tmp28 * tmp28);
                    auto tmp30 = static_cast<double>(0.3591836734693878);
                    auto tmp31 = decltype(tmp29)(tmp29 * tmp30);
                    auto tmp32 = decltype(tmp23)(tmp23 * tmp31);
                    auto tmp33 = c10::convert<float>(tmp32);
                    out_ptr0[static_cast<long>(x1 + (475L*x0))] = tmp33;
                }
            }
        }
    }
}
''')


async_compile.wait(globals())
del async_compile

def call(args):
    buf1 = empty_strided_cpu((160, 1, 475), (475, 475, 1), torch.float32)
    cpp_fused__to_copy_0(buf1)
    return (buf1, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    fn = lambda: call([])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

```

### Code that leads to malformed generated code
```python
import os
import argparse
import torch
# import librosa
import time
from scipy.io.wavfile import write
import torch.amp
import torchaudio
from tqdm import tqdm

import utils
from models import SynthesizerTrn
from mel_processing import mel_spectrogram_torch
from speaker_encoder.voice_encoder import SpeakerEncoder
import logging
logging.getLogger('numba').setLevel(logging.WARNING)

# torch.backends.cudnn.benchmark = True
# torch.backends.cudnn.allow_tf32 = True

def load_models(args):
    hps = utils.get_hparams_from_file(args.hpfile)

    print("Loading model...")
    net_g = SynthesizerTrn(
        hps.data.filter_length // 2 + 1,
        hps.train.segment_size // hps.data.hop_length,
        **hps.model).cuda()
    _ = net_g.eval()


    print("Loading checkpoint...")
    _ = utils.load_checkpoint(args.ptfile, net_g, None)
    
    net_g = torch.compile(net_g)

    print("Loading WavLM for content...")
    cmodel = utils.get_cmodel(0).cuda()

    cmodel = torch.compile(cmodel)
    
    if hps.model.use_spk:
        print("Loading speaker encoder...")
        smodel = SpeakerEncoder('speaker_encoder/ckpt/pretrained_bak_5805000.pt').cuda()
        smodel = torch.compile(smodel)

    return hps, net_g, cmodel, smodel

@torch.compile
def process_wav(hps, net_g, cmodel, smodel, src, tgt):
    with torch.no_grad():
        wav_tgt, o_sr = torchaudio.load(tgt)
        if o_sr != hps.data.sampling_rate:
            wav_tgt = torchaudio.transforms.Resample(o_sr, hps.data.sampling_rate)(wav_tgt)
        wav_tgt = wav_tgt.squeeze(0).numpy()
        if hps.model.use_spk:
            g_tgt = smodel.embed_utterance(wav_tgt)
            g_tgt = torch.from_numpy(g_tgt).unsqueeze(0).cuda()
        else:
            wav_tgt = torch.from_numpy(wav_tgt).unsqueeze(0).cuda()
            mel_tgt = mel_spectrogram_torch(
                wav_tgt, 
                hps.data.filter_length,
                hps.data.n_mel_channels,
                hps.data.sampling_rate,
                hps.data.hop_length,
                hps.data.win_length,
                hps.data.mel_fmin,
                hps.data.mel_fmax
            )
        wav_src, o_sr = torchaudio.load(src)
        if o_sr != hps.data.sampling_rate:
            wav_src = torchaudio.transforms.Resample(o_sr, hps.data.sampling_rate)(wav_src)
        wav_src = wav_src.cuda()
        c = utils.get_content(cmodel, wav_src)
        
        if hps.model.use_spk:
            audio = net_g.infer(c, g=g_tgt)
        else:
            audio = net_g.infer(c, mel=mel_tgt)
        audio = audio[0][0].data.cpu().float().numpy()
    
    return audio



if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--hpfile", type=str, default="configs/freevc-24.json", help="path to json config file")
    parser.add_argument("--ptfile", type=str, default="checkpoints/freevc-24.pth", help="path to pth file")
    parser.add_argument("--tgt_path", type=str, default="voices/audio7.wav", help="path to target audio file")
    args = parser.parse_args()
    
    src = "voices/audio.wav"
    tgt = args.tgt_path

    os.makedirs("outputs", exist_ok=True)
    hps, net_g, cmodel, smodel = load_models(args)

    process_wav(hps, net_g, cmodel, smodel, src, tgt)

    start = time.time()
    for i in range(100):
        audio = process_wav(hps, net_g, cmodel, smodel, src, tgt)
    print("Mean time:", (time.time() - start) / 1_000)
    write(os.path.join("outputs", f"out.wav"), 24000, audio)

        
```

### Error logs

DEBUG:filelock:Attempting to acquire lock 2022744139744 on C:\Users\sigur\AppData\Local\Temp\torchinductor_sigur\locks\co2konkofj5rz6476x7nz6loyxdmxxkh3tc44gkjkzynhrr7w5o5.lock
DEBUG:filelock:Lock 2022744139744 acquired on C:\Users\sigur\AppData\Local\Temp\torchinductor_sigur\locks\co2konkofj5rz6476x7nz6loyxdmxxkh3tc44gkjkzynhrr7w5o5.lock
DEBUG:filelock:Attempting to release lock 2022744139744 on C:\Users\sigur\AppData\Local\Temp\torchinductor_sigur\locks\co2konkofj5rz6476x7nz6loyxdmxxkh3tc44gkjkzynhrr7w5o5.lock
DEBUG:filelock:Lock 2022744139744 released on C:\Users\sigur\AppData\Local\Temp\torchinductor_sigur\locks\co2konkofj5rz6476x7nz6loyxdmxxkh3tc44gkjkzynhrr7w5o5.lock
W0913 03:40:09.245000 68120 torch\_dynamo\repro\after_dynamo.py:110] [6/0] Compiled Fx GraphModule failed. Creating script to minify the error.
W0913 03:40:09.248000 68120 torch\_dynamo\debug_utils.py:277] [6/0] Writing minified repro to:
W0913 03:40:09.248000 68120 torch\_dynamo\debug_utils.py:277] [6/0] C:\Users\sigur\Desktop\shit\FreeVC\torch_compile_debug\run_2024_09_13_03_40_09_247190-pid_68116\minifier\minifier_launcher.py
Traceback (most recent call last):
  File "C:\Users\sigur\Desktop\shit\FreeVC\live.py", line 100, in <module>
    process_wav(hps, net_g, cmodel, smodel, src, tgt)
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\eval_frame.py", line 433, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\live.py", line 49, in process_wav
    @torch.compile
  File "C:\Users\sigur\Desktop\shit\FreeVC\live.py", line 52, in torch_dynamo_resume_in_process_wav_at_52
    wav_tgt, o_sr = torchaudio.load(tgt)
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torchaudio\transforms\_transforms.py", line 957, in __init__
    kernel, self.width = _get_sinc_resample_kernel(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\convert_frame.py", line 1116, in __call__
    return self._torchdynamo_orig_callable(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\convert_frame.py", line 948, in __call__
    result = self._inner_convert(
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\convert_frame.py", line 472, in __call__
    return _compile(
           ^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_utils_internal.py", line 84, in wrapper_function
    return StrobelightCompileTimeProfiler.profile_compile_time(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_strobelight\compile_time_profiler.py", line 129, in profile_compile_time      
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\convert_frame.py", line 817, in _compile
    guarded_code = compile_inner(code, one_graph, hooks, transform)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\convert_frame.py", line 636, in compile_inner
    out_code = transform_code_object(code, transform)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\bytecode_transformation.py", line 1185, in transform_code_object       
    transformations(instructions, code_options)
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\convert_frame.py", line 178, in _fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\convert_frame.py", line 582, in transform
    tracer.run()
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\symbolic_convert.py", line 2451, in run
    super().run()
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\symbolic_convert.py", line 893, in run
    while self.step():
          ^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\symbolic_convert.py", line 805, in step
    self.dispatch_table[inst.opcode](self, inst)
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\symbolic_convert.py", line 2642, in RETURN_VALUE
    self._return(inst)
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\symbolic_convert.py", line 2627, in _return
    self.output.compile_subgraph(
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\output_graph.py", line 1123, in compile_subgraph
    self.compile_and_call_fx_graph(tx, pass2.graph_output_vars(), root)
  File "C:\Users\sigur\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\output_graph.py", line 1318, in compile_and_call_fx_graph
    compiled_fn = self.call_user_compiler(gm)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\output_graph.py", line 1409, in call_user_compiler
    raise BackendCompilerFailed(self.compiler_fn, e).with_traceback(
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\output_graph.py", line 1390, in call_user_compiler
    compiled_fn = compiler_fn(gm, self.example_inputs())
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\repro\after_dynamo.py", line 107, in __call__
    compiled_gm = compiler_fn(copy.deepcopy(gm), example_inputs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\__init__.py", line 1951, in __call__
    return compile_fx(model_, inputs_, config_patches=self.config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\compile_fx.py", line 1505, in compile_fx
    return aot_autograd(
           ^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\backends\common.py", line 69, in __call__
    cg = aot_module_simplified(gm, example_inputs, **self.kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_functorch\aot_autograd.py", line 954, in aot_module_simplified
    compiled_fn, _ = create_aot_dispatcher_function(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_functorch\aot_autograd.py", line 687, in create_aot_dispatcher_function       
    compiled_fn, fw_metadata = compiler_fn(
                               ^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_functorch\_aot_autograd\jit_compile_runtime_wrappers.py", line 168, in aot_dispatch_base
    compiled_fw = compiler(fw_module, updated_flat_args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\compile_fx.py", line 1410, in fw_compiler_base
    return inner_compile(
           ^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\repro\after_aot.py", line 84, in debug_wrapper
    inner_compiled_fn = compiler_fn(gm, example_inputs)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\debug.py", line 304, in inner
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\compile_fx.py", line 527, in compile_fx_inner
    compiled_graph = fx_codegen_and_compile(
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\compile_fx.py", line 831, in fx_codegen_and_compile
    compiled_fn = graph.compile_to_fn()
                  ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\graph.py", line 1751, in compile_to_fn
    return self.compile_to_module().call
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_dynamo\utils.py", line 231, in time_wrapper
    r = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\graph.py", line 1701, in compile_to_module
    mod = PyCodeCache.load_by_key_path(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\codecache.py", line 3073, in load_by_key_path
    mod = _reload_python_module(key, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\sigur\Desktop\shit\FreeVC\.venv\Lib\site-packages\torch\_inductor\runtime\compile_tasks.py", line 39, in _reload_python_module
    raise RuntimeError(
torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
RuntimeError: Failed to import C:\Users\sigur\AppData\Local\Temp\torchinductor_sigur\2s\c2swhvevsvcfe3t7py66ebm444p2oq4p5iw2ywffmxngsqmqnok6.py
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 13-14: truncated \UXXXXXXXX escape (c2swhvevsvcfe3t7py66ebm444p2oq4p5iw2ywffmxngsqmqnok6.py, line 30)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information

Minifier script written to C:\Users\sigur\Desktop\shit\FreeVC\torch_compile_debug\run_2024_09_13_03_40_09_247190-pid_68116\minifier\minifier_launcher.py. Run this script to find the smallest traced graph which reproduces this error.


You can suppress this exception and fall back to eager by setting:
    import torch._dynamo
    torch._dynamo.config.suppress_errors = True

### Minified repro


from math import inf
import torch
from torch import tensor, device
import torch.fx as fx
import torch._dynamo
from torch._dynamo.testing import rand_strided
from torch._dynamo.debug_utils import run_fwd_maybe_bwd

import torch._dynamo.config
import torch._inductor.config
import torch._functorch.config
import torch.fx.experimental._config









from torch.nn import *
class Repro(torch.nn.Module):
    def __init__(self):
        super().__init__()



    def forward(self):
        arange = torch.arange(-17, 458, dtype = torch.float64, device = device(type='cpu'))
        getitem = arange[(None, None)];  arange = None
        idx = getitem / 441;  getitem = None
        arange_1 = torch.arange(0, -160, -1, dtype = None, device = device(type='cpu'))
        getitem_1 = arange_1[(slice(None, None, None), None, None)];  arange_1 = None
        truediv_1 = getitem_1 / 160;  getitem_1 = None
        t = truediv_1 + idx;  truediv_1 = idx = None
        t *= 158.4;  t_1 = t;  t = None
        t_2 = t_1.clamp_(-6, 6);  t_1 = None
        mul = t_2 * 3.141592653589793
        truediv_2 = mul / 6;  mul = None
        truediv_3 = truediv_2 / 2;  truediv_2 = None
        cos = torch.cos(truediv_3);  truediv_3 = None
        window = cos ** 2;  cos = None
        t_2 *= 3.141592653589793;  t_3 = t_2;  t_2 = None
        eq = t_3 == 0
        tensor = torch.tensor(1.0)
        to = tensor.to(t_3);  tensor = None
        sin = t_3.sin()
        truediv_4 = sin / t_3;  sin = t_3 = None
        kernels = torch.where(eq, to, truediv_4);  eq = to = truediv_4 = None
        mul_1 = window * 0.3591836734693878;  window = None
        kernels *= mul_1;  kernels_1 = kernels;  kernels = mul_1 = None
        kernels_2 = kernels_1.to(dtype = torch.float32);  kernels_1 = None
        return (kernels_2,)


mod = Repro()

def load_args(reader):
load_args._version = 0

if __name__ == '__main__':
    from torch._dynamo.repro.after_dynamo import run_repro
    run_repro(mod, load_args, accuracy=False, command='minify',
        save_dir='C:\\Users\\sigur\\Desktop\\shit\\FreeVC\\torch_compile_debug\\run_2024_09_13_03_40_09_247190-pid_68116\\minifier\\checkpoints', autocast=False, backend='inductor')


### Versions

Collecting environment information...
PyTorch version: 2.4.1+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 11 Home
GCC version: (x86_64-win32-seh-rev2, Built by MinGW-W64 project) 12.2.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-11-10.0.22631-SP0
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3080
Nvidia driver version: 560.94
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture=9
CurrentClockSpeed=3401
DeviceID=CPU0
Family=107
L2CacheSize=8192
L2CacheSpeed=
Manufacturer=AuthenticAMD
MaxClockSpeed=3401
Name=AMD Ryzen 9 5950X 16-Core Processor
ProcessorType=3
Revision=8450

Versions of relevant libraries:
[pip3] numpy==1.26.3
[pip3] torch==2.4.1+cu124
[pip3] torchaudio==2.4.1+cu124
[pip3] torchvision==0.19.1+cu124
[conda] Could not collect

cc @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex @ezyang @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire