fix: make the package importable on Windows - #124
Open
JoaoZaokk wants to merge 1 commit into
Open
Conversation
Two unrelated defects, both of which stop `import deepcompressor` (and so
`deepcompressor.app.diffusion.ptq`) before any work begins. Neither is
Windows-specific by design; both are places where a platform default was
assumed.
1. csrc/load.py builds with GCC flags.
MSVC ignores them with D9002 warnings, which alone would be cosmetic. But
CUDA >= 13 ships CCCL, and CCCL rejects MSVC's traditional preprocessor:
cccl/cuda/std/__cccl/preprocessor.h(23): fatal error C1189: #error:
MSVC/cl.exe with traditional preprocessor is used ... Please switch to
the standard conforming preprocessor by passing `/Zc:preprocessor`
The extension is JIT-built at import time from deepcompressor/data/__init__
-> dtype -> codebook -> csrc/load, so this is not an opt-in build step that
a user can skip: the package simply does not import.
Fixed by passing /Zc:preprocessor to cl.exe directly (for pybind.cpp) and
through nvcc via -Xcompiler (for quantize.cu), and substituting MSVC
equivalents for the GCC flags. `-fopenmp` is included in that substitution
deliberately -- being ignored means the C++ side is built without OpenMP,
which is quiet rather than harmless.
2. longbench/eval.py reads a UTF-8 file with the locale default.
task2prompt.json contains CJK text. Without an explicit encoding the read
uses cp1252 on Windows and raises at import:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position
1522: character maps to <undefined>
The write on line 123 already passes encoding="utf-8"; only this read was
missed. Note the blast radius: an LLM benchmark file that no diffusion
workflow will ever read prevents app.diffusion.ptq from importing, because
the diffusion PTQ entry point pulls in the LLM one.
Verified on Windows 11, Python 3.13, torch 2.13.0+cu130, CUDA 13.2, MSVC
14.44 (VS 2022 Build Tools), RTX 3090 (sm_86):
before fatal error C1189 during the JIT build, then UnicodeDecodeError
after extension compiles for sm_86, `from deepcompressor.app.diffusion
import ptq` succeeds, and `python -m deepcompressor.app.diffusion.ptq
--help` prints its usage
Linux behaviour is unchanged: both changes are inside a sys.platform guard or
add an argument that was already the implied default.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two unrelated defects, both of which stop
import deepcompressor— and thereforedeepcompressor.app.diffusion.ptq— before any work begins. Neither is Windows-specific by design; both are places where a platform default got assumed.1.
csrc/load.pybuilds with GCC flagsMSVC ignores them with
D9002warnings, which alone would be cosmetic. But CUDA ≥ 13 ships CCCL, and CCCL rejects MSVC's traditional preprocessor outright:This is not an opt-in build step a user can skip. The extension is JIT-built at import time along
deepcompressor/data/__init__.py→dtype.py→codebook.py→csrc/load.py, so the package does not import at all.Fixed by passing
/Zc:preprocessortocl.exedirectly (forpybind.cpp) and throughnvccvia-Xcompiler(forquantize.cu), with MSVC equivalents substituted for the GCC flags.-fopenmpis part of that substitution on purpose: being silently ignored means the C++ side builds without OpenMP, which is quiet rather than harmless.2.
longbench/eval.pyreads a UTF-8 file with the locale defaulttask2prompt.jsoncontains CJK text. Without an explicit encoding the read uses cp1252 on Windows and raises at import:The sibling write on line 123 already passes
encoding="utf-8"; only this read was missed.Worth noting the blast radius: an LLM benchmark file that no diffusion workflow will ever read prevents
app.diffusion.ptqfrom importing, because the diffusion PTQ entry point imports the LLM one.Verification
Windows 11, Python 3.13, torch 2.13.0+cu130, CUDA 13.2, MSVC 14.44 (VS 2022 Build Tools), RTX 3090 (sm_86):
fatal error C1189sm_86from deepcompressor.app.diffusion import ptqUnicodeDecodeErrorpython -m deepcompressor.app.diffusion.ptq --helpBeyond importing, the pipeline was exercised end to end on SANA 1.6B: calibration collected 128/128 samples, and PTQ ran into the smoothing stage before being stopped for time on this hardware. So these two changes are what stood between the package and a working run on Windows, not the only thing that would have to work afterwards.
Linux behaviour is unchanged — both changes sit inside a
sys.platformguard or add an argument that was already the implied default.🤖 Generated with Claude Code