Skip to content

feat: MSVC auto-detection + C compiler check before torch.compile#210

Merged
nikopueringer merged 1 commit intonikopueringer:mainfrom
JamesNyeVRGuy:feat/msvc-auto-detect
Mar 31, 2026
Merged

feat: MSVC auto-detection + C compiler check before torch.compile#210
nikopueringer merged 1 commit intonikopueringer:mainfrom
JamesNyeVRGuy:feat/msvc-auto-detect

Conversation

@JamesNyeVRGuy
Copy link
Copy Markdown
Contributor

MSVC auto-detection + C compiler check before torch.compile

torch.compile needs a C compiler (cl.exe on Windows, gcc on Linux). On Windows, Visual Studio Build Tools installs cl.exe but doesn't add it to PATH — users get a cryptic compilation failure and fall back to eager mode (~30% slower) without knowing why.

  • Auto-detect MSVC in standard Visual Studio 2019/2022 install locations
  • Check for C compiler before attempting compile
  • Show actionable message with install link if missing
  • Skip reasons are logged clearly instead of generic "compilation failed"

What does this change?

Replaces the simple skip_compile boolean with a prerequisite check that:

  1. On Windows: searches for cl.exe in VS install paths and adds it to PATH automatically
  2. If no compiler found: logs a clear message with install link instead of attempting compile and failing cryptically
  3. On Linux: checks for gcc/cc before attempting compile

Only touches CorridorKeyModule/inference_engine.py. No new dependencies.

How was it tested?

  • Tested on Windows with VS Build Tools installed (cl.exe auto-detected, compile succeeds)
  • Tested on Windows without VS Build Tools (clear skip message logged, falls back to eager)
  • Tested on Linux with gcc (compile succeeds as before)
  • Tested on Linux Docker without gcc (clear skip message, falls back to eager)

Checklist

  • uv run pytest passes
  • uv run ruff check passes
  • uv run ruff format --check passes

torch.compile needs a C compiler (cl.exe on Windows, gcc on Linux).
On Windows, Visual Studio Build Tools installs cl.exe but doesn't add
it to PATH — users get a cryptic compilation failure and fall back to
eager mode (~30% slower) without knowing why.

- Auto-detect MSVC in standard Visual Studio install locations
- Check for C compiler before attempting compile
- Show actionable message with install link if missing
- Skip reasons are logged clearly instead of generic "compilation failed"
@nikopueringer nikopueringer merged commit 1e11ac4 into nikopueringer:main Mar 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants