{
  "id": 371166,
  "title": "Matrix Factorization with GPU: 6.5x faster!",
  "url": "/competitions/otto-recommender-system/discussion/371166",
  "author_name": "",
  "post_date": "2022-12-08T10:54:05.527090900Z",
  "votes": 26,
  "comment_count": 4,
  "views": 0,
  "content": "<p><a href=\"https://www.kaggle.com/radek1\" target=\"_blank\">@radek1</a> shared a <a href=\"https://www.kaggle.com/code/radek1/matrix-factorization-pytorch-merlin-dataloader\" target=\"_blank\">very interesting notebook to compute matrix factorization,</a> using polar, annoy, Merlin data loader and pytorch. The only issue I may have with it is that it did not leverage GPU acceleration. I therefore created a GPU version of his notebook available at <a href=\"https://www.kaggle.com/code/cpmpml/matrix-factorization-with-gpu\" target=\"_blank\">https://www.kaggle.com/code/cpmpml/matrix-factorization-with-gpu</a></p>\n<p>Main differences between Radek's notebook and this notebook are:</p>\n<ul>\n<li>Radek used polar to handle dataframes, I use cudf. </li>\n<li>Radek used annoy for nearest neighbors, I use cuml. </li>\n<li>Radek trained his factorization model on CPU, I use GPU.</li>\n</ul>\n<p>I kept Merlin dataloader as it is much faster than a simple pytorch data loader.<br>\nI also kept the logic used in Radeks notebook to create the submission. Better handcrafted ways to build submissions have been shared by Radek, <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> and others. Nothing prevents you from combining the GPU code from this notebook with these better submission logic.</p>\n<p>The notebook score is the same as Radek's score. It runs much faster though, 6 min vs 40 min.</p>",
  "messages": [
    {
      "id": "2058954",
      "postDate": "12/08/2022 10:54:05",
      "content": "<p><a href=\"https://www.kaggle.com/radek1\" target=\"_blank\">@radek1</a> shared a <a href=\"https://www.kaggle.com/code/radek1/matrix-factorization-pytorch-merlin-dataloader\" target=\"_blank\">very interesting notebook to compute matrix factorization,</a> using polar, annoy, Merlin data loader and pytorch. The only issue I may have with it is that it did not leverage GPU acceleration. I therefore created a GPU version of his notebook available at <a href=\"https://www.kaggle.com/code/cpmpml/matrix-factorization-with-gpu\" target=\"_blank\">https://www.kaggle.com/code/cpmpml/matrix-factorization-with-gpu</a></p>\n<p>Main differences between Radek's notebook and this notebook are:</p>\n<ul>\n<li>Radek used polar to handle dataframes, I use cudf. </li>\n<li>Radek used annoy for nearest neighbors, I use cuml. </li>\n<li>Radek trained his factorization model on CPU, I use GPU.</li>\n</ul>\n<p>I kept Merlin dataloader as it is much faster than a simple pytorch data loader.<br>\nI also kept the logic used in Radeks notebook to create the submission. Better handcrafted ways to build submissions have been shared by Radek, <a href=\"https://www.kaggle.com/cdeotte\" target=\"_blank\">@cdeotte</a> and others. Nothing prevents you from combining the GPU code from this notebook with these better submission logic.</p>\n<p>The notebook score is the same as Radek's score. It runs much faster though, 6 min vs 40 min.</p>",
      "rawMarkdown": "radek1 shared a [very interesting notebook to compute matrix factorization,](https://www.kaggle.com/code/radek1/matrix-factorization-pytorch-merlin-dataloader) using polar, annoy, Merlin data loader and pytorch. The only issue I may have with it is that it did not leverage GPU acceleration. I therefore created a GPU version of his notebook available at https://www.kaggle.com/code/cpmpml/matrix-factorization-with-gpu\n\nMain differences between Radek's notebook and this notebook are:\n\n- Radek used polar to handle dataframes, I use cudf. \n- Radek used annoy for nearest neighbors, I use cuml. \n- Radek trained his factorization model on CPU, I use GPU.\n\nI kept Merlin dataloader as it is much faster than a simple pytorch data loader.\nI also kept the logic used in Radeks notebook to create the submission. Better handcrafted ways to build submissions have been shared by Radek, @cdeotte and others. Nothing prevents you from combining the GPU code from this notebook with these better submission logic.\n\nThe notebook score is the same as Radek's score. It runs much faster though, 6 min vs 40 min.",
      "votes": null
    },
    {
      "id": "2058969",
      "postDate": "12/08/2022 11:12:02",
      "content": "<p>Wow, this is outstanding! 🙌 Didn't realize <code>cuml</code> had an implementation of nearest neighbor search 🤦‍♂️So looking to dive in! 🙂</p>\n<p>BTW I a  not sure what could be going on there (possibly you didn't set the notebook to public?) -- I am getting a 400 when I go to the link above.</p>\n<p>Thank you for putting this together 🙏 There is a lot of experimentation one needs to put into looking for better ways of generating candidates, this will be of great help! (plus is genuinely interesting, very eager to learn about how you leveraged <code>cudf</code> and <code>cuml</code> to run this on the GPU 🙂)</p>",
      "rawMarkdown": "Wow, this is outstanding! 🙌 Didn't realize `cuml` had an implementation of nearest neighbor search 🤦‍♂️So looking to dive in! 🙂\n\nBTW I a  not sure what could be going on there (possibly you didn't set the notebook to public?) -- I am getting a 400 when I go to the link above.\n\nThank you for putting this together 🙏 There is a lot of experimentation one needs to put into looking for better ways of generating candidates, this will be of great help! (plus is genuinely interesting, very eager to learn about how you leveraged `cudf` and `cuml` to run this on the GPU 🙂)",
      "votes": null
    },
    {
      "id": "2058978",
      "postDate": "12/08/2022 11:23:45",
      "content": "<p>Oops, forgot to share it. It is public now, thanks for the ping!</p>",
      "rawMarkdown": "Oops, forgot to share it. It is public now, thanks for the ping!",
      "votes": null
    },
    {
      "id": "2059009",
      "postDate": "12/08/2022 11:56:02",
      "content": "<p>This is super exciting, thank you for sharing that notebook, <a href=\"https://www.kaggle.com/cpmpml\" target=\"_blank\">@cpmpml</a> 🙂 Learned a lot from it!</p>\n<p>In particular, I didn't realize <code>cuml</code> had nearest neighbor search nor how awesome the API was! What a find! 🙂</p>\n<p>I added a note to my matrix factorization notebook (rerunning it now so it can take a while for it to appear) to send people in the right direction 🙂</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F83267%2F8db70e007db3f8cb527d69ed5e25464e%2FScreenshot%202022-12-08%20215019.png?generation=1670500525178021&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "This is super exciting, thank you for sharing that notebook, @cpmpml 🙂 Learned a lot from it!\n\nIn particular, I didn't realize `cuml` had nearest neighbor search nor how awesome the API was! What a find! 🙂\n\nI added a note to my matrix factorization notebook (rerunning it now so it can take a while for it to appear) to send people in the right direction 🙂\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F83267%2F8db70e007db3f8cb527d69ed5e25464e%2FScreenshot%202022-12-08%20215019.png?generation=1670500525178021&alt=media)",
      "votes": null
    },
    {
      "id": "2059071",
      "postDate": "12/08/2022 13:00:40",
      "content": "<p>Awesome! Thanks for sharing CPMP</p>",
      "rawMarkdown": "Awesome! Thanks for sharing CPMP",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2058969,
      "author_name": "radek1",
      "author_url": "",
      "post_date": "12/08/2022 11:12:02",
      "content": "<p>Wow, this is outstanding! 🙌 Didn't realize <code>cuml</code> had an implementation of nearest neighbor search 🤦‍♂️So looking to dive in! 🙂</p>\n<p>BTW I a  not sure what could be going on there (possibly you didn't set the notebook to public?) -- I am getting a 400 when I go to the link above.</p>\n<p>Thank you for putting this together 🙏 There is a lot of experimentation one needs to put into looking for better ways of generating candidates, this will be of great help! (plus is genuinely interesting, very eager to learn about how you leveraged <code>cudf</code> and <code>cuml</code> to run this on the GPU 🙂)</p>",
      "votes": null,
      "replies": [
        {
          "id": 2058978,
          "author_name": "cpmpml",
          "author_url": "",
          "post_date": "12/08/2022 11:23:45",
          "content": "<p>Oops, forgot to share it. It is public now, thanks for the ping!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 2059009,
          "author_name": "radek1",
          "author_url": "",
          "post_date": "12/08/2022 11:56:02",
          "content": "<p>This is super exciting, thank you for sharing that notebook, <a href=\"https://www.kaggle.com/cpmpml\" target=\"_blank\">@cpmpml</a> 🙂 Learned a lot from it!</p>\n<p>In particular, I didn't realize <code>cuml</code> had nearest neighbor search nor how awesome the API was! What a find! 🙂</p>\n<p>I added a note to my matrix factorization notebook (rerunning it now so it can take a while for it to appear) to send people in the right direction 🙂</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F83267%2F8db70e007db3f8cb527d69ed5e25464e%2FScreenshot%202022-12-08%20215019.png?generation=1670500525178021&amp;alt=media\" alt=\"\"></p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 2059071,
      "author_name": "cdeotte",
      "author_url": "",
      "post_date": "12/08/2022 13:00:40",
      "content": "<p>Awesome! Thanks for sharing CPMP</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2058954": "radek1 shared a [very interesting notebook to compute matrix factorization,](https://www.kaggle.com/code/radek1/matrix-factorization-pytorch-merlin-dataloader) using polar, annoy, Merlin data loader and pytorch. The only issue I may have with it is that it did not leverage GPU acceleration. I therefore created a GPU version of his notebook available at https://www.kaggle.com/code/cpmpml/matrix-factorization-with-gpu\n\nMain differences between Radek's notebook and this notebook are:\n\n- Radek used polar to handle dataframes, I use cudf. \n- Radek used annoy for nearest neighbors, I use cuml. \n- Radek trained his factorization model on CPU, I use GPU.\n\nI kept Merlin dataloader as it is much faster than a simple pytorch data loader.\nI also kept the logic used in Radeks notebook to create the submission. Better handcrafted ways to build submissions have been shared by Radek, @cdeotte and others. Nothing prevents you from combining the GPU code from this notebook with these better submission logic.\n\nThe notebook score is the same as Radek's score. It runs much faster though, 6 min vs 40 min.",
    "2058969": "Wow, this is outstanding! 🙌 Didn't realize `cuml` had an implementation of nearest neighbor search 🤦‍♂️So looking to dive in! 🙂\n\nBTW I a  not sure what could be going on there (possibly you didn't set the notebook to public?) -- I am getting a 400 when I go to the link above.\n\nThank you for putting this together 🙏 There is a lot of experimentation one needs to put into looking for better ways of generating candidates, this will be of great help! (plus is genuinely interesting, very eager to learn about how you leveraged `cudf` and `cuml` to run this on the GPU 🙂)",
    "2058978": "Oops, forgot to share it. It is public now, thanks for the ping!",
    "2059009": "This is super exciting, thank you for sharing that notebook, @cpmpml 🙂 Learned a lot from it!\n\nIn particular, I didn't realize `cuml` had nearest neighbor search nor how awesome the API was! What a find! 🙂\n\nI added a note to my matrix factorization notebook (rerunning it now so it can take a while for it to appear) to send people in the right direction 🙂\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F83267%2F8db70e007db3f8cb527d69ed5e25464e%2FScreenshot%202022-12-08%20215019.png?generation=1670500525178021&alt=media)",
    "2059071": "Awesome! Thanks for sharing CPMP"
  },
  "source": "meta"
}