Skip to content

Conversation

@fmueller
Copy link
Owner

Motivation

  • Make PyTorch an optional dependency so translation features are opt-in and the base install avoids heavy GPU builds.
  • Provide a pinned, CPU-only PyTorch extra for Linux x86_64 to allow users to avoid CUDA downloads when they only need CPU inference.
  • Surface a clear runtime error when PyTorch is missing that explains how to install the translation extras.

Description

  • Move torch out of core dependencies into optional extras translation and translation-cpu in pyproject.toml with pinned CPU wheel URLs for targeted Linux/Python combos and a fallback spec for other platforms.
  • Add a _require_torch helper in src/scribae/translate/mt.py that checks for torch via importlib.util.find_spec and raises a user-facing RuntimeError with installation guidance if missing, and use the returned module for device detection.
  • Update translation pipeline code to lazily require torch once a translation pipeline is needed and avoid importing it at CLI startup.
  • Document the new install flow in README.md and update the Quick start to show uv sync --locked --dev --extra translation and --extra translation-cpu usage.

Testing

  • Ran uv run ruff check --fix, which failed due to inability to download the pinned CPU torch wheel from download.pytorch.org during environment sync.
  • Ran uv run mypy, which failed for the same reason related to dependency fetch errors for the pinned torch wheel.
  • Ran uv run pytest, which also failed because the environment sync attempted to fetch the pinned CPU torch wheel and the download failed.

Codex Task

- Specified that `uv sync --locked --all-extras --dev` includes PyTorch with CUDA.
- Added instructions for a lightweight CPU-only PyTorch installation option (~200MB vs ~2GB).
- Updated `_require_torch` to use a try/except block for more robust import error handling.
- Replaced `importlib.util.find_spec` with direct `import torch`, raising an error with more context if the import fails.
@fmueller fmueller merged commit 4492632 into main Dec 29, 2025
3 checks passed
@fmueller fmueller deleted the codex/find-cuda-usage-in-scribae branch December 29, 2025 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants