Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add use_gpu for PureSVD #229

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

chezou
Copy link
Contributor

@chezou chezou commented Dec 11, 2024

Description

Introduce use_gpu for PureSVD.

My microbenchmark code shows 8 times faster than CPU with Movielens 1M dataset on GeForce 3060Ti compared with Ryzen 5 5600X.

>>> import timeit
>>> with open("scripts/benchmark.py", "r") as f:
...     code = f.read()
...
>>> print(code)
import pandas as pd

from rectools import Columns
from rectools.dataset import Dataset
from rectools.models.pure_svd import PureSVDModel

ratings = pd.read_csv(
    "ml-1m/ratings.dat",
    sep="::",
    engine="python",  # Because of 2-chars separators
    header=None,
    names=[Columns.User, Columns.Item, Columns.Weight, Columns.Datetime],
)

# Create dataset
dataset = Dataset.construct(ratings)

model = PureSVDModel(factors=100, use_gpu={})
>>> timeit.timeit("model.fit(dataset)", setup=code.format(False), number=10)
42.881751499007805
>>> timeit.timeit("model.fit(dataset)", setup=code.format(True), number=10)
5.059483032004209

Environment information:

➜  RecTools git:(svd-gpu) ✗ poetry run python -c  "import cupy; cupy.show_config(_full=True)"
OS                           : Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.39
Python Version               : 3.12.3
CuPy Version                 : 13.3.0
CuPy Platform                : NVIDIA CUDA
NumPy Version                : 1.26.4
SciPy Version                : 1.12.0
Cython Build Version         : 0.29.36
Cython Runtime Version       : None
CUDA Root                    : /usr/local/cuda
nvcc PATH                    : /usr/local/cuda/bin/nvcc
CUDA Build Version           : 12060
CUDA Driver Version          : 12060
CUDA Runtime Version         : 12060 (linked to CuPy) / 12060 (locally installed)
CUDA Extra Include Dirs      : []
cuBLAS Version               : 120604
cuFFT Version                : 11300
cuRAND Version               : 10307
cuSOLVER Version             : (11, 7, 1)
cuSPARSE Version             : 12504
NVRTC Version                : (12, 6)
Thrust Version               : 200600
CUB Build Version            : 200600
Jitify Build Version         : <unknown>
cuDNN Build Version          : None
cuDNN Version                : None
NCCL Build Version           : None
NCCL Runtime Version         : None
cuTENSOR Version             : None
cuSPARSELt Build Version     : None
Device 0 Name                : NVIDIA GeForce RTX 3060 Ti
Device 0 Compute Capability  : 86
Device 0 PCI Bus ID          : 0000:09:00.0

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Optimization

How Has This Been Tested?

Before submitting a PR, please check yourself against the following list. It would save us quite a lot of time.

  • Have you read the contribution guide?
  • Have you updated the relevant docstrings? We're using Numpy format, please double-check yourself
  • Does your change require any new tests?
  • Have you updated the changelog file?

@chezou chezou force-pushed the svd-gpu branch 6 times, most recently from 6788d67 to 6430038 Compare December 11, 2024 06:36
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (9b3992e) to head (d19a277).
Report is 91 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##              main      #229     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files           45        60     +15     
  Lines         2242      4016   +1774     
===========================================
+ Hits          2242      4016   +1774     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@feldlime feldlime left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, it looks super cool!

CHANGELOG.md Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
rectools/models/pure_svd.py Outdated Show resolved Hide resolved
rectools/models/pure_svd.py Show resolved Hide resolved
@chezou
Copy link
Contributor Author

chezou commented Jan 16, 2025

Python 3.9 CI fails because of codecov issue. Test is passed.

error - 2025-01-16 17:47:40,999 -- Report creating failed: {"message":"Token required because branch is protected"}

@chezou
Copy link
Contributor Author

chezou commented Jan 23, 2025

@feldlime I addressed all the comments you made. PTAL

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