Issues using Qtorch and Qtroch+

Hi everyone

I am currently trying to work with qtorch and qtorch-plus.

I have been using the following setup:

  • Windows 11
  • qtorch version 0.2.0
  • cuda version 11.8
  • torch version 2.1.0

The problem starts with including the libraries:

from qtorch import FixedPoint, FloatingPoint
from qtorch.quant import Quantizer, quantizer
from qtorch.optim import OptimLP
from qtorch_plus import Posit

It fails to build the quant_cpu.pyd. I searched with everything in order to check if the file is on the computer:

I tried to reinstall the two packages:

  • qtorch-plus
  • qtorch

I also tried to use only one package, but it does not change anything.

Any suggests how to proceed?

Full error msg:

  File "C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\qtorch\quant\__init__.py", line 1, in <module>
    from .quant_function import *
  File "C:\projects\qtorch_num_arithmetic\venv\Lib\site-packages\qtorch\quant\quant_function.py", line 10, in <module>
    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.

The stacktrace doesn’t show any errors so you might need to check which line of code is actually failing to build.

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.

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.

    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)

I checked the path and the file:

  • the file does exit in this path
  • the file is empty
...\\AppData\\Local\\torch_extensions\\torch_extensions\\quant_cpu\\lock

I wait for an hour but nothing happens so far.

Does someone of you face the same issue?

I just delete the lock file and it works.