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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

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

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