fastmachinelearning / qonnx

QONNX: Arbitrary-Precision Quantized Neural Networks in ONNX
https://qonnx.readthedocs.io/
Apache License 2.0
124 stars 39 forks source link

Avoiding mp.Pool in case of using only 1 worker for easier pdb debugging #127

Closed lstasytis closed 2 months ago

lstasytis commented 3 months ago

Problem: When debugging QONNX model transformations which can make use of applyNodeLocal using pdb, the use of multiprocessing.Pool stops the debugger from being able to stop at the exact stack frame which is created by the process forked using the multiprocessing library if the error happened there.

The stack frame can still be accessed by breakpointing right before the actual error occurs, however this would require prior knowledge of where the code breaks, which can be highly undesirable.

Solution: Intuitively, the user would expect that if they simply set their num_workers to 1, that multiprocessing will not be called and pdb will work as expected. Thus, I propose to simply check for this case and run the applyNodeLocal() function 'as is' without mp.Pool if the worker count is set to 1.

maltanar commented 2 months ago

@lstasytis can you please run pre-commit run --all to run the linter and push an update to the PR? I added some instructions here:

https://github.com/fastmachinelearning/qonnx?tab=readme-ov-file#linting