Skip to content

refactor(gpu): moving unsigned_scalar_div_rem and signed_scalar_div_rem to the backend #2499

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

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

enzodimaria
Copy link
Contributor

closes: please link all relevant issues

PR content/description

Check-list:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Relevant issues are marked as resolved/closed, related issues are linked in the description
  • Check for breaking changes (including serialization changes) and add them to commit message following the conventional commit specification

Copy link
Contributor

@agnesLeroy agnesLeroy left a comment

Choose a reason for hiding this comment

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

Hello! Thank you for this PR! Here are my comments 🙂

Base automatically changed from edm/unchecked_signed_scalar_div_async_to_backend to main July 3, 2025 07:52
@enzodimaria enzodimaria force-pushed the edm/unchecked_scalar_div_rem_to_backend branch from eccbfc2 to 20e3d03 Compare July 3, 2025 12:29
@zama-bot zama-bot removed the approved label Jul 3, 2025
@enzodimaria enzodimaria requested a review from pdroalves July 3, 2025 12:29
@enzodimaria enzodimaria force-pushed the edm/unchecked_scalar_div_rem_to_backend branch from 20e3d03 to 263179e Compare July 3, 2025 13:01
@zama-bot zama-bot removed the approved label Jul 3, 2025
@enzodimaria enzodimaria force-pushed the edm/unchecked_scalar_div_rem_to_backend branch from 263179e to 13da67d Compare July 7, 2025 13:10
@zama-bot zama-bot removed the approved label Jul 7, 2025
@enzodimaria enzodimaria force-pushed the edm/unchecked_scalar_div_rem_to_backend branch from 13da67d to 42bd244 Compare July 7, 2025 13:30
Copy link
Contributor

@pdroalves pdroalves left a comment

Choose a reason for hiding this comment

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

Thanks a lot @enzodimaria .
I added some comments regarding format and consistency within the backend. I'm not capable of reviewing the logic, though.

this->params = params;
this->allocate_gpu_memory = allocate_gpu_memory;

this->bitop_mem = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can move this type of initialization to the variable definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this->bitop_mem is only useful if is_divisor_power_of_two is true, I think it's better to keep this default initialization to nullptr, in order not to allocate potentially unused objects. That was a recommendation from Agnès. What do you think?

    this->bitop_mem = nullptr;
     ...

    if (is_divisor_power_of_two) {

      this->bitop_mem = new int_bitop_buffer<Torus>(
          streams, gpu_indexes, gpu_count, SCALAR_BITAND, params,
          num_radix_blocks, allocate_gpu_memory, size_tracker);
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we need initialization but I was thinking on initializing them on declaretion, as in:

...
   int_unsigned_scalar_div_mem<Torus> *unsigned_div_mem = nullptr;
  int_bitop_buffer<Torus> *bitop_mem  = nullptr;
  int_scalar_mul_buffer<Torus> *scalar_mul_mem  = nullptr;
  int_sub_and_propagate<Torus> *sub_and_propagate_mem  = nullptr;

This should be equivalent to what you are doing, since it's on a constructor, but more succinct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see! I can do that. But can I do it in a next PR, the one where I remove the booleans?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, other functions already merge following this logic. So for consistency with what is already merged, I think we should keep everything like this. Then in a future PR, I will re-harmonize everything

Copy link
Contributor

Choose a reason for hiding this comment

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

(the PR will come right after we merge this @pdroalves)

@enzodimaria enzodimaria requested a review from pdroalves July 8, 2025 09:03
@enzodimaria
Copy link
Contributor Author

Thanks a lot @enzodimaria . I added some comments regarding format and consistency within the backend. I'm not capable of reviewing the logic, though.

Thank you very much!

@enzodimaria enzodimaria force-pushed the edm/unchecked_scalar_div_rem_to_backend branch from 42bd244 to 8d3c638 Compare July 8, 2025 11:02
@enzodimaria enzodimaria force-pushed the edm/unchecked_scalar_div_rem_to_backend branch from 8d3c638 to 7682716 Compare July 8, 2025 14:31
@zama-bot zama-bot removed the approved label Jul 8, 2025
Copy link

github-actions bot commented Jul 9, 2025

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

@enzodimaria enzodimaria force-pushed the edm/unchecked_scalar_div_rem_to_backend branch from badd8fd to acb4b32 Compare July 9, 2025 14:43
@enzodimaria enzodimaria changed the title refactor(gpu): moving unsigned_scalar_div_rem to the backend refactor(gpu): moving unsigned_scalar_div_rem and signed_scalar_div_rem to the backend Jul 9, 2025
@enzodimaria enzodimaria requested a review from agnesLeroy July 9, 2025 14:44
@enzodimaria enzodimaria merged commit e376df2 into main Jul 10, 2025
105 checks passed
@enzodimaria enzodimaria deleted the edm/unchecked_scalar_div_rem_to_backend branch July 10, 2025 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants