Issues using Qtorch and Qtroch+

makkkiiii: <p>Hi everyone</p>
<p>I am currently trying to work with qtorch and qtorch-plus.</p>
<p>I have been using the following setup:</p>
<ul>
<li>Windows 11</li>
<li>qtorch version 0.2.0</li>
<li>cuda version 11.8</li>
<li>torch version 2.1.0</li>
</ul>
<p>The problem starts with including the libraries:</p>
<pre><code class="lang-auto">from qtorch import FixedPoint, FloatingPoint
from qtorch.quant import Quantizer, quantizer
from qtorch.optim import OptimLP
from qtorch_plus import Posit
</code></pre>
<p>It fails to build the quant_cpu.pyd. I searched with everything in order to check if the file is on the computer:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/f/f/ffdeb69d73081afd5c106d386b1643470e420bb0.png" data-download-href="https://discuss.pytorch.org/uploads/default/ffdeb69d73081afd5c106d386b1643470e420bb0" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/f/f/ffdeb69d73081afd5c106d386b1643470e420bb0.png" alt="image" data-base62-sha1="AvwUNt2mkuanVJH6PnTF9usSe1G" width="690" height="175" data-dominant-color="EFF0F1"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">945×240 16.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I tried to reinstall the two packages:</p>
<ul>
<li>qtorch-plus</li>
<li>qtorch</li>
</ul>
<p>I also tried to use only one package, but it does not change anything.</p>
<p>Any suggests how to proceed?</p>
<p>Full error msg:</p>
<pre><code class="lang-auto">  File "C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\qtorch\quant\__init__.py", line 1, in &lt;module&gt;
    from .quant_function import *
  File "C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\qtorch\quant\quant_function.py", line 10, in &lt;module&gt;
    quant_cpu = load(
                ^^^^^
  File "C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\torch\utils\cpp_extension.py", line 1283, in load
    return _jit_compile(
           ^^^^^^^^^^^^^
  File "C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\torch\utils\cpp_extension.py", line 1508, in _jit_compile
    _write_ninja_file_and_build_library(
  File "C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\torch\utils\cpp_extension.py", line 1623, in _write_ninja_file_and_build_library
    _run_ninja_build(
  File "C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\torch\utils\cpp_extension.py", line 1910, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'quant_cpu': [1/1] "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86/link.exe" quant_cpu.o bit_helper.o sim_helper.o /nologo /DLL c10.lib torch_cpu.lib torch.lib /LIBPATH:C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\torch\lib torch_python.lib /LIBPATH:C:\projects\qtorch_num_arithmetic\venv\Scripts\libs /out:quant_cpu.pyd
FAILED: quant_cpu.pyd 
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x86/link.exe" quant_cpu.o bit_helper.o sim_helper.o /nologo /DLL c10.lib torch_cpu.lib torch.lib /LIBPATH:C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\torch\lib torch_python.lib /LIBPATH:C:\projects\qtorch_num_arithmetic\venv\Scripts\libs /out:quant_cpu.pyd

ninja: build stopped: subcommand failed.
</code></pre>

ptrblck: <p>The stacktrace doesn’t show any errors so you might need to check which line of code is actually failing to build.</p>

makkkiiii: <p>It was failing because of the windows environment path definition. I had defined two version of ninja. After deleting one of the paths it seems to work.</p>
<p>I am currently facing another issue. It compiled everything or at least the errors do not show up and the .o files were build, but it waits now in FileBaton class routine.</p>
<pre><code class="lang-auto">    def wait(self):
        '''
        Periodically sleeps for a certain amount until the baton is released.

        The amount of time slept depends on the ``wait_seconds`` parameter
        passed to the constructor.
        '''
        while os.path.exists(self.lock_file_path):
            time.sleep(self.wait_seconds)
</code></pre>
<p>I checked the path and the file:</p>
<ul>
<li>the file does exit in this path</li>
<li>the file is empty</li>
</ul>
<pre><code class="lang-auto">...\\AppData\\Local\\torch_extensions\\torch_extensions\\quant_cpu\\lock
</code></pre>
<p>I wait for an hour but nothing happens so far.</p>
<p>Does someone of you face the same issue?</p>

hy_c: <p>I just delete the lock file and it works.</p>