Skip to content

[LEADS-199] Add CPU-only PyTorch support to reduce package size#185

Merged
asamal4 merged 1 commit intolightspeed-core:mainfrom
bsatapat-jpg:dev
Mar 12, 2026
Merged

[LEADS-199] Add CPU-only PyTorch support to reduce package size#185
asamal4 merged 1 commit intolightspeed-core:mainfrom
bsatapat-jpg:dev

Conversation

@bsatapat-jpg
Copy link
Copy Markdown
Collaborator

@bsatapat-jpg bsatapat-jpg commented Mar 11, 2026

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Unit tests improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: Claude-4.5-opus-high
  • Generated by: Claude

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Documentation
    • Replaced pip-only install instructions with two UV-based installation variants: CPU (default) and GPU/CUDA.
    • Added explicit UV commands for syncing local embeddings and guidance on using CPU vs GPU lock files.
    • Clarified that the default lock is CPU-only and noted caveats where pip may install CUDA wheels on Linux.
    • Added guidance on local-embeddings dependency requirements for local model usage.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds UV-based CPU and GPU installation flows to README for local HuggingFace embedding models, replaces the pip-only example with uv commands and lock-file guidance, and introduces a local-embeddings optional dependency plus a [tool.uv] section in pyproject.toml mapping torch to a CPU wheel index.

Changes

Cohort / File(s) Summary
Documentation
README.md
Replaced pip-only installation example with two uv-based variants (CPU default and GPU/CUDA), added explicit uv sync commands and guidance for uv.lock vs uv-gpu.lock, and updated the Note about CPU vs GPU lock usage and pip CPU-wheel caveats.
Dependency Configuration
pyproject.toml
Added local-embeddings optional dependency (torch>=2.0.0, sentence-transformers>=5.1.0), introduced [[tool.uv.index]] name = "pytorch-cpu" with CPU wheel URL and explicit = true, and added [tool.uv.sources] mapping to point torch to that index.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly matches the main changeset objective: adding CPU-only PyTorch support via UV-based installation variants to optimize package size.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pyproject.toml`:
- Around line 134-140: The guidance line suggesting "uv lock --no-sources -o
uv-gpu.lock" is invalid because uv lock only writes uv.lock and does not support
-o for renaming; remove the incorrect multi-lockfile guidance and the reference
to uv-gpu.lock, leaving only the correct regenerate command ("uv lock") and a
short note that alternative-named lockfiles are not supported by uv lock (or
replace with correct steps if you want separate GPU lock generation via a
different workflow/tool). Ensure you update the comment block that mentions
"uv-gpu.lock" and the example command so it no longer instructs using
-o/--output-file with uv lock.
- Around line 48-50: The extra "local-embeddings-gpu" is ineffective because
torch is globally mapped to the CPU index via [tool.uv.sources], so
sentence-transformers' transitive torch will be resolved from pytorch-cpu; fix
by adding an extra-scoped source and constraints so the "local-embeddings-gpu"
extra uses the CUDA index for torch (e.g., add a source entry keyed for the
extra and add a conflict or explicit torch dependency under the
local-embeddings-gpu extra to pull torch from that CUDA source), updating the
mapping in [tool.uv.sources] so the extra name (local-embeddings-gpu) resolves
torch from the CUDA index instead of pytorch-cpu while leaving the default extra
to use the CPU index.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c5cd4676-9547-4dde-a690-1e0e4ec69618

📥 Commits

Reviewing files that changed from the base of the PR and between 34cbae4 and eb250e4.

⛔ Files ignored due to path filters (2)
  • uv-gpu.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • README.md
  • pyproject.toml

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 49-53: Update the README pip example to guarantee CPU-only PyTorch
wheels by modifying the pip install command shown ('pip install
'lightspeed-evaluation[local-embeddings]'') to include PyTorch's CPU wheel index
URL (--index-url https://download.pytorch.org/whl/cpu) or alternatively add an
explicit note next to that command clarifying that the plain command does not
guarantee CPU-only installs and to use the index URL for CPU-only installation;
also keep the existing mention of uv.lock vs uv-gpu.lock to guide users choosing
the smaller CPU-only environment.
- Around line 46-47: The README shows an invalid command using a positional
lockfile after --locked; update the instructions to explain that `uv sync` does
not accept a lockfile path and that `--locked` is a boolean that requires the
project lockfile to be named `uv.lock` adjacent to `pyproject.toml`, and provide
the correct steps: either rename or symlink `uv-gpu.lock` to `uv.lock` before
running `uv sync --locked`, or run `uv sync --frozen` to use the existing
lockfile without freshness checks; reference the `uv sync` command, `--locked`,
`--frozen`, `uv.lock`, and `uv-gpu.lock` in the updated text.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9373b58c-0e69-4d13-ab42-8be1dc5353c9

📥 Commits

Reviewing files that changed from the base of the PR and between eb250e4 and ffb30a9.

⛔ Files ignored due to path filters (2)
  • uv-gpu.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • README.md
  • pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml

Comment thread README.md Outdated
Comment thread README.md Outdated
VladimirKadlec
VladimirKadlec previously approved these changes Mar 11, 2026
Copy link
Copy Markdown
Member

@VladimirKadlec VladimirKadlec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you. Please rebase to the current main to pass the e2e tests.

@bsatapat-jpg
Copy link
Copy Markdown
Collaborator Author

LGTM, thank you. Please rebase to the current main to pass the e2e tests.

Thanks @VladimirKadlec for reviewing it.... I have rebased on the current main, and not it passed.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pyproject.toml`:
- Around line 38-40: The documented GPU install command "uv sync --extra
local-embeddings --locked uv-gpu.lock" is invalid because --locked is a boolean
and uv uses a fixed uv.lock; update the examples in pyproject.toml and README.md
to remove the filename after --locked and offer supported alternatives: show the
single-lock approach using a dependency group (e.g., "uv sync --group gpu" with
the gpu group declared in pyproject.toml) or the separate-lock via pip compile
and sync flow (explain generating a requirements-gpu.txt with "uv pip compile
... -o requirements-gpu.txt" then installing with "uv pip sync
requirements-gpu.txt"); replace every occurrence of the invalid command string
with one of these supported variants and ensure the docs mention that --locked
takes no file path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fd28ce25-9d43-4b25-818b-a54b6780e238

📥 Commits

Reviewing files that changed from the base of the PR and between e857770 and e2c7dc8.

⛔ Files ignored due to path filters (2)
  • uv-gpu.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • README.md
  • pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

Comment thread pyproject.toml Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 43-54: Update the README so the uv-related instructions explicitly
state that the `uv sync` commands require a checked-out repository containing
`pyproject.toml`, `uv.lock`, and `uv-gpu.lock` (i.e., a cloned repo), and that
running `pip install git+...` alone will not provide those files; mention that
users must clone the project before running `uv sync` or copying `uv-gpu.lock`
to `uv.lock`. Reference the `uv sync` command and the files `uv.lock`,
`uv-gpu.lock`, and `pyproject.toml` in the clarification so readers know exactly
which files are needed and the correct setup flow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8964382c-43c1-4aa7-b77d-773253a0e1c0

📥 Commits

Reviewing files that changed from the base of the PR and between e2c7dc8 and 6967881.

⛔ Files ignored due to path filters (2)
  • uv-gpu.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • README.md
  • pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml

Comment thread README.md Outdated
Copy link
Copy Markdown
Collaborator

@asamal4 asamal4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you !!

@asamal4 asamal4 merged commit d0fb10b into lightspeed-core:main Mar 12, 2026
16 checks passed
@bsatapat-jpg bsatapat-jpg deleted the dev branch March 12, 2026 08:36
emac-E pushed a commit to emac-E/lightspeed-evaluation that referenced this pull request Apr 10, 2026
[LEADS-199] Add CPU-only PyTorch support to reduce package size
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.

3 participants