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

Update channel and change group_by to chunk_by #462

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: nightly-2024-01-04
toolchain: nightly-2024-03-10
- uses: Swatinem/rust-cache@v2
- run: scripts/rust_fmt.sh --check

Expand All @@ -38,7 +38,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: nightly-2024-01-04
toolchain: nightly-2024-03-10
- uses: Swatinem/rust-cache@v2
- run: scripts/clippy.sh

Expand All @@ -48,7 +48,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-03-10
- uses: Swatinem/rust-cache@v2
- run: ./scripts/test_avx.sh

Expand All @@ -58,9 +58,9 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-03-10
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly-2024-01-04 test
- run: cargo +nightly-2024-03-10 test

udeps:
runs-on: ubuntu-latest
Expand All @@ -69,7 +69,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
name: "Rust Toolchain Setup"
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-03-10
- uses: Swatinem/rust-cache@v2
id: "cache-cargo"
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}
Expand All @@ -78,19 +78,18 @@ jobs:
wget -O - -c https://github.com/est31/cargo-udeps/releases/download/v0.1.35/cargo-udeps-v0.1.35-x86_64-unknown-linux-gnu.tar.gz | tar -xz
cargo-udeps-*/cargo-udeps udeps
env:
RUSTUP_TOOLCHAIN: nightly-2024-01-04

RUSTUP_TOOLCHAIN: nightly-2024-03-10

all-tests:
runs-on: ubuntu-latest
needs:
- clippy
- format
- run-tests
- run-avx-tests
- udeps
- clippy
- format
- run-tests
- run-avx-tests
- udeps
steps:
- name: Decide whether all the needed jobs succeeded or failed
uses: re-actors/[email protected]
with:
jobs: ${{ toJSON(needs) }}
- name: Decide whether all the needed jobs succeeded or failed
uses: re-actors/[email protected]
with:
jobs: ${{ toJSON(needs) }}
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: nightly-2024-01-04
toolchain: nightly-2024-03-10
- uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo +nightly-2024-01-04 llvm-cov --codecov --output-path codecov.json
run: cargo +nightly-2024-03-10 llvm-cov --codecov --output-path codecov.json
env:
RUSTFLAGS: "-C target-feature=+avx512f"
- name: Upload coverage to Codecov
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ warnings = "deny"
future-incompatible = "deny"
nonstandard-style = "deny"
rust-2018-idioms = "deny"
unused = "deny"

[features]
avx512 = []
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2024-01-04"
channel = "nightly-2024-03-10"
2 changes: 1 addition & 1 deletion scripts/clippy.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
cargo +nightly-2024-01-04 clippy "$@" --all-targets --all-features -- -D warnings -D future-incompatible \
cargo +nightly-2024-03-10 clippy "$@" --all-targets --all-features -- -D warnings -D future-incompatible \
-D nonstandard-style -D rust-2018-idioms -D unused
2 changes: 1 addition & 1 deletion scripts/rust_fmt.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

cargo +nightly-2024-01-04 fmt --all -- "$@"
cargo +nightly-2024-03-10 fmt --all -- "$@"
2 changes: 1 addition & 1 deletion scripts/test_avx.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# Can be used as a drop in replacement for `cargo test` with avx512f flag on.
# For example, `./scripts/test_avx.sh` will run all tests(not only avx).
RUSTFLAGS="-Awarnings -C target-cpu=native -C target-feature=+avx512f -C opt-level=2" cargo +nightly-2024-01-04 test "$@"
RUSTFLAGS="-Awarnings -C target-cpu=native -C target-feature=+avx512f -C opt-level=2" cargo +nightly-2024-03-10 test "$@"
6 changes: 2 additions & 4 deletions src/commitment_scheme/merkle_multilayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,14 @@ impl<H: Hasher> MerkleMultiLayer<H> {
}

// Hashes a single sub-tree.
fn hash_subtree<F: Field, H: Hasher, const IS_INTERMEDIATE: bool>(
fn hash_subtree<F: Field + IntoSlice<H::NativeType>, H: Hasher, const IS_INTERMEDIATE: bool>(
sub_tree_data: &mut [H::Hash],
input: &MerkleTreeInput<'_, F>,
relative_depth: usize,
prev_hashes: &[H::Hash],
config: &MerkleMultiLayerConfig,
index_in_layer: usize,
) where
F: IntoSlice<H::NativeType>,
{
) {
// First layer is special, as it is the only layer that might have inputs from the previous
// MultiLayer, and does not need to look at the current sub_tree for previous hash values.
let dst = sub_tree_data
Expand Down
2 changes: 1 addition & 1 deletion src/commitment_scheme/mixed_degree_merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ mod tests {
let first_column_queries = vec![0, 7];
let second_column_queries = vec![3, 7];
let third_column_queries = vec![1, 2];
let queries = vec![
let queries = [
zero_column_queries,
first_column_queries,
second_column_queries,
Expand Down
21 changes: 10 additions & 11 deletions src/commitment_scheme/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,11 @@ pub fn hash_merkle_tree<H: Hasher>(data: &mut [&mut [H::NativeType]]) {
/// Given a data of a tree, and a bottom layer of 'bottom_layer_node_size_bytes' sized nodes, hashes
/// the entire tree. Nodes are hashed individually at the bottom layer.
// TODO(Ohad): Write a similiar function for when F does not implement IntoSlice(Non le platforms).
pub fn hash_merkle_tree_from_bottom_layer<'a, F: Field, H: Hasher>(
pub fn hash_merkle_tree_from_bottom_layer<F: Field + IntoSlice<H::NativeType>, H: Hasher>(
bottom_layer: &[F],
bottom_layer_node_size_bytes: usize,
data: &mut [&mut [H::NativeType]],
) where
F: IntoSlice<H::NativeType>,
H::NativeType: 'a,
{
) {
// Hash bottom layer.
let dst_slice = data.get_mut(0).expect("Empty tree!");
let bottom_layer_data: &[H::NativeType] =
Expand Down Expand Up @@ -206,13 +203,13 @@ pub fn inject_hash_in_pairs<'a: 'b, 'b, H: Hasher>(
/// * `hash_inputs` - The hash inputs to inject into.
/// * `chunk_idx` - The index of the chunk to inject.
/// * `n_chunks_in_column` - The number of chunks every column is divided into.
pub fn inject_column_chunks<'b, 'a: 'b, H: Hasher, F: Field>(
pub fn inject_column_chunks<'b, 'a: 'b, H: Hasher, F>(
columns: &'a [&'a [F]],
hash_inputs: &'b mut [Vec<&'a [H::NativeType]>],
chunk_idx: usize,
n_chunks_in_column: usize,
) where
F: IntoSlice<H::NativeType>,
F: Field + IntoSlice<H::NativeType>,
{
for column in columns {
let column_slice = get_column_chunk(column, chunk_idx, n_chunks_in_column);
Expand Down Expand Up @@ -247,13 +244,15 @@ pub fn get_column_chunk<F>(column: &[F], index_to_view: usize, n_total_chunks: u
/// Hashes a layer of a Merkle tree. Nodes are injected with child hashes and chunks from the input
/// columns (if any).
// TODO(Ohad): Consider renaming after current hash_layer function is deprecated.
pub fn inject_and_hash_layer<H: Hasher, F: Field, const IS_INTERMEDIATE: bool>(
pub fn inject_and_hash_layer<
H: Hasher,
F: Field + IntoSlice<H::NativeType>,
const IS_INTERMEDIATE: bool,
>(
child_hashes: &[H::Hash],
dst: &mut [H::Hash],
input_columns: &Iter<'_, &[F]>,
) where
F: IntoSlice<H::NativeType>,
{
) {
let produced_layer_length = dst.len();
if IS_INTERMEDIATE {
assert_eq!(
Expand Down
1 change: 0 additions & 1 deletion src/core/air/evaluation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ mod tests {
use rand::{Rng, SeedableRng};

use super::*;
use crate::core::backend::cpu::CPUCircleEvaluation;
use crate::core::circle::CirclePoint;
use crate::core::fields::m31::{M31, P};
use crate::qm31;
Expand Down
2 changes: 1 addition & 1 deletion src/core/backend/cpu/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl FriOps for CPUBackend {

LineEvaluation::new(domain.double(), folded_values)
}
fn fold_circle_into_line<F: Field>(
fn fold_circle_into_line<F>(
dst: &mut LineEvaluation<Self, SecureField, BitReversedOrder>,
src: &CircleEvaluation<Self, F, BitReversedOrder>,
alpha: SecureField,
Expand Down
1 change: 0 additions & 1 deletion src/core/backend/cpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub type CPULineEvaluation<F, EvalOrder> = LineEvaluation<CPUBackend, F, EvalOrd
mod tests {
use itertools::Itertools;
use rand::prelude::*;
use rand::rngs::SmallRng;

use crate::core::backend::{CPUBackend, FieldOps};
use crate::core::fields::qm31::QM31;
Expand Down
6 changes: 3 additions & 3 deletions src/core/fri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub trait FriOps: FieldOps<SecureField> + Sized {
/// Panics if `src` is not double the length of `dst`.
// TODO(andrew): Make folding factor generic.
// TODO(andrew): Fold directly into FRI layer to prevent allocation.
fn fold_circle_into_line<F: Field>(
fn fold_circle_into_line<F>(
dst: &mut LineEvaluation<Self, SecureField, BitReversedOrder>,
src: &CircleEvaluation<Self, F, BitReversedOrder>,
alpha: SecureField,
Expand Down Expand Up @@ -746,7 +746,7 @@ impl<H: Hasher<NativeType = u8>> FriLayerVerifier<H> {
let mut all_subline_evals = Vec::new();

// Group queries by the subline they reside in.
for subline_queries in queries.group_by(|a, b| a >> FOLD_STEP == b >> FOLD_STEP) {
for subline_queries in queries.chunk_by(|a, b| a >> FOLD_STEP == b >> FOLD_STEP) {
let subline_start = (subline_queries[0] >> FOLD_STEP) << FOLD_STEP;
let subline_end = subline_start + (1 << FOLD_STEP);

Expand Down Expand Up @@ -816,7 +816,7 @@ impl<B: FriOps, H: Hasher<NativeType = u8>> FriLayerProver<B, H> {

// Group queries by the subline they reside in.
// TODO(andrew): Explain what a "subline" is at the top of the module.
for query_group in queries.group_by(|a, b| a >> FOLD_STEP == b >> FOLD_STEP) {
for query_group in queries.chunk_by(|a, b| a >> FOLD_STEP == b >> FOLD_STEP) {
let subline_start = (query_group[0] >> FOLD_STEP) << FOLD_STEP;
let subline_end = subline_start + (1 << FOLD_STEP);

Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#![feature(
array_chunks,
iter_array_chunks,
exact_size_is_empty,
get_many_mut,
int_roundings,
is_sorted,
iter_array_chunks,
new_uninit,
slice_group_by,
stdsimd,
get_many_mut,
int_roundings
stdarch_x86_avx512
)]
pub mod commitment_scheme;
pub mod core;
Expand Down
Loading