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

specific simd batch inverse functions #985

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

ohad-starkware
Copy link
Collaborator

No description provided.

Copy link
Collaborator Author

ohad-starkware commented Jan 13, 2025

@reviewable-StarkWare
Copy link

This change is Reviewable

@ohad-starkware ohad-starkware self-assigned this Jan 13, 2025
@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch from eeeccf7 to 9d80d73 Compare January 13, 2025 13:39
@ohad-starkware ohad-starkware force-pushed the ohad/chunked_batch_inverse branch from e304b42 to 110b581 Compare January 14, 2025 08:31
@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch from 9d80d73 to 80513ec Compare January 14, 2025 08:32
@ohad-starkware ohad-starkware force-pushed the ohad/chunked_batch_inverse branch from 110b581 to 48e6c9d Compare January 14, 2025 11:33
@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch 2 times, most recently from 302f0dd to f6b261b Compare January 14, 2025 14:09
@ohad-starkware ohad-starkware force-pushed the ohad/chunked_batch_inverse branch 3 times, most recently from 2c61a02 to 11011c8 Compare January 14, 2025 14:51
@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch from f6b261b to 109fb1f Compare January 14, 2025 14:51
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @ohad-starkware)


crates/prover/src/core/backend/simd/m31.rs line 255 at r1 (raw file):

    }

    fn invert_many(column: &[Self]) -> Vec<Self> {

It makes sense to call those batch_inverse as well, right?

Suggestion:

fn batch_inverse(column: &[Self]) -> Vec<Self> {

crates/prover/src/core/backend/simd/m31.rs line 256 at r1 (raw file):

    fn invert_many(column: &[Self]) -> Vec<Self> {
        const OPTIMAL_PACKED_M31_BATCH_INVERSE_CHUNK_SIZE: usize = 1 << 9;

I think those constant should be on top of file and be documented

Code quote:

const OPTIMAL_PACKED_M31_BATCH_INVERSE_CHUNK_SIZE: usize = 1 << 9;

crates/prover/src/core/backend/simd/qm31.rs line 176 at r1 (raw file):

    fn invert_many(column: &[Self]) -> Vec<Self> {
        const OPTIMAL_PACKED_QM31_BATCH_INVERSE_CHUNK_SIZE: usize = 1 << 11;

how come that for QM31 this number is higher than for M31
Shouldn't it be the other way around?

Code quote:

 const OPTIMAL_PACKED_QM31_BATCH_INVERSE_CHUNK_SIZE: usize = 1 << 11;

@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch from 109fb1f to 47292dd Compare January 14, 2025 16:05
Copy link
Collaborator Author

@ohad-starkware ohad-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @shaharsamocha7)


crates/prover/src/core/backend/simd/m31.rs line 255 at r1 (raw file):

Previously, shaharsamocha7 wrote…

It makes sense to call those batch_inverse as well, right?

I have too, just didnt rebase
done.


crates/prover/src/core/backend/simd/m31.rs line 256 at r1 (raw file):

Previously, shaharsamocha7 wrote…

I think those constant should be on top of file and be documented

ill document
re top of the file, I disagree - this number is specifically tailored for this function call, no one else should be able to use it, not even in this file.

@ohad-starkware ohad-starkware force-pushed the ohad/chunked_batch_inverse branch from 2e2ddba to 8e3237b Compare January 14, 2025 16:13
@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch from 47292dd to 016a4db Compare January 14, 2025 16:13
@ohad-starkware ohad-starkware changed the base branch from ohad/chunked_batch_inverse to graphite-base/985 January 14, 2025 16:17
@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch from 016a4db to 760ee74 Compare January 14, 2025 16:17
@ohad-starkware ohad-starkware changed the base branch from graphite-base/985 to dev January 14, 2025 16:18
@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch from 760ee74 to dac1f59 Compare January 14, 2025 16:18
Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ohad-starkware)


crates/prover/src/core/backend/simd/m31.rs line 256 at r1 (raw file):

Previously, ohad-starkware (Ohad) wrote…

ill document
re top of the file, I disagree - this number is specifically tailored for this function call, no one else should be able to use it, not even in this file.

I see your point about scoping but my view is about code structure.
For me, it make more sense that these 3 constants would be defined in the same location in code.
That is because if one of them needs to be changed (due to different benchmarks) it will also make sense to change the others.
Ideally, I think that the magic number should be only for M31 type, and the other constants should be defined relatively to that. e.g.

// Optimal chunk sizes were determined empirically on an intel 155u machine.
const PACKED_M31_BATCH_INVERSE_CHUNK_SIZE: usize = 1 << 9;
const PACKED_CM31_BATCH_INVERSE_CHUNK_SIZE = 2 *  PACKED_M31_BATCH_INVERSE_CHUNK_SIZE;
const PACKED_QM31_BATCH_INVERSE_CHUNK_SIZE = 2 * PACKED_CM31_BATCH_INVERSE_CHUNK_SIZE;

Your call, unblocking

@ohad-starkware ohad-starkware force-pushed the ohad/specific_batch_inverse branch from dac1f59 to 03135cd Compare January 23, 2025 13:26
Copy link
Collaborator Author

@ohad-starkware ohad-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @ohad-starkware and @shaharsamocha7)


crates/prover/src/core/backend/simd/m31.rs line 256 at r1 (raw file):

Previously, shaharsamocha7 wrote…

I see your point about scoping but my view is about code structure.
For me, it make more sense that these 3 constants would be defined in the same location in code.
That is because if one of them needs to be changed (due to different benchmarks) it will also make sense to change the others.
Ideally, I think that the magic number should be only for M31 type, and the other constants should be defined relatively to that. e.g.

// Optimal chunk sizes were determined empirically on an intel 155u machine.
const PACKED_M31_BATCH_INVERSE_CHUNK_SIZE: usize = 1 << 9;
const PACKED_CM31_BATCH_INVERSE_CHUNK_SIZE = 2 *  PACKED_M31_BATCH_INVERSE_CHUNK_SIZE;
const PACKED_QM31_BATCH_INVERSE_CHUNK_SIZE = 2 * PACKED_CM31_BATCH_INVERSE_CHUNK_SIZE;

Your call, unblocking

about the location, I took the suggestion
re relative, I'm not sure it will always apply, so I left it as raw numbers, no need to couple them IMO.


crates/prover/src/core/backend/simd/qm31.rs line 176 at r1 (raw file):

Previously, shaharsamocha7 wrote…

how come that for QM31 this number is higher than for M31
Shouldn't it be the other way around?

right, it does make sense, I guess the final inverse is the main culprit,
I have bench code at ohad/bench_batch_inverse (it's rough). We can revisit these numbers when we do machine-specific optimizations.

@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 92.26%. Comparing base (eef4936) to head (03135cd).
Report is 4 commits behind head on dev.

Files with missing lines Patch % Lines
crates/prover/src/core/backend/simd/qm31.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #985      +/-   ##
==========================================
- Coverage   92.27%   92.26%   -0.02%     
==========================================
  Files         105      105              
  Lines       14221    14230       +9     
  Branches    14221    14230       +9     
==========================================
+ Hits        13123    13129       +6     
- Misses       1024     1027       +3     
  Partials       74       74              

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

Copy link
Collaborator

@shaharsamocha7 shaharsamocha7 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ohad-starkware)

Copy link
Collaborator Author

ohad-starkware commented Jan 29, 2025

Merge activity

  • Jan 29, 4:50 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Jan 29, 4:51 AM EST: A user merged this pull request with Graphite.

@ohad-starkware ohad-starkware merged commit 5345457 into dev Jan 29, 2025
17 of 19 checks passed
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.

4 participants