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 the names of mul opcodes #347

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
13 changes: 6 additions & 7 deletions stwo_cairo_prover/crates/prover/src/cairo_air/debug_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ use crate::components::{
assert_eq_opcode_imm, call_opcode, call_opcode_op_1_base_fp, call_opcode_rel, generic_opcode,
jnz_opcode, jnz_opcode_dst_base_fp, jnz_opcode_taken, jnz_opcode_taken_dst_base_fp,
jump_opcode, jump_opcode_double_deref, jump_opcode_rel, jump_opcode_rel_imm,
memory_address_to_id, memory_id_to_big, mul_opcode_is_small_f_is_imm_f,
mul_opcode_is_small_f_is_imm_t, range_check_19, range_check_4_3, range_check_7_2_5,
range_check_9_9, ret_opcode, verify_instruction,
memory_address_to_id, memory_id_to_big, mul_opcode, mul_opcode_imm, range_check_19,
range_check_4_3, range_check_7_2_5, range_check_9_9, ret_opcode, verify_instruction,
};
use crate::felt::split_f252;
use crate::relations;
Expand Down Expand Up @@ -402,11 +401,11 @@ where
.entries(trace),
);
}
for claim in claim.opcodes.mul_f_f.clone() {
for claim in claim.opcodes.mul.clone() {
entries.extend(
RelationTrackerComponent::new(
tree_span_provider,
mul_opcode_is_small_f_is_imm_f::Eval {
mul_opcode::Eval {
claim,
memory_address_to_id_lookup_elements: relations::MemoryAddressToId::dummy(),
memory_id_to_big_lookup_elements: relations::MemoryIdToBig::dummy(),
Expand All @@ -419,11 +418,11 @@ where
.entries(trace),
);
}
for claim in claim.opcodes.mul_f_t.clone() {
for claim in claim.opcodes.mul_imm.clone() {
entries.extend(
RelationTrackerComponent::new(
tree_span_provider,
mul_opcode_is_small_f_is_imm_t::Eval {
mul_opcode_imm::Eval {
claim,
memory_address_to_id_lookup_elements: relations::MemoryAddressToId::dummy(),
memory_id_to_big_lookup_elements: relations::MemoryIdToBig::dummy(),
Expand Down
133 changes: 62 additions & 71 deletions stwo_cairo_prover/crates/prover/src/cairo_air/opcodes_air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ use crate::components::{
assert_eq_opcode_imm, call_opcode, call_opcode_op_1_base_fp, call_opcode_rel, generic_opcode,
jnz_opcode, jnz_opcode_dst_base_fp, jnz_opcode_taken, jnz_opcode_taken_dst_base_fp,
jump_opcode, jump_opcode_double_deref, jump_opcode_rel, jump_opcode_rel_imm,
memory_address_to_id, memory_id_to_big, mul_opcode_is_small_f_is_imm_f,
mul_opcode_is_small_f_is_imm_t, range_check_19, range_check_9_9, ret_opcode,
verify_instruction,
memory_address_to_id, memory_id_to_big, mul_opcode, mul_opcode_imm, range_check_19,
range_check_9_9, ret_opcode, verify_instruction,
};
use crate::input::state_transitions::StateTransitions;

Expand Down Expand Up @@ -48,8 +47,8 @@ pub struct OpcodeClaim {
pub jump_double_deref: Vec<jump_opcode_double_deref::Claim>,
pub jump_rel: Vec<jump_opcode_rel::Claim>,
pub jump_rel_imm: Vec<jump_opcode_rel_imm::Claim>,
pub mul_f_f: Vec<mul_opcode_is_small_f_is_imm_f::Claim>,
pub mul_f_t: Vec<mul_opcode_is_small_f_is_imm_t::Claim>,
pub mul: Vec<mul_opcode::Claim>,
pub mul_imm: Vec<mul_opcode_imm::Claim>,
pub ret: Vec<ret_opcode::Claim>,
}
impl OpcodeClaim {
Expand Down Expand Up @@ -88,8 +87,8 @@ impl OpcodeClaim {
.for_each(|c| c.mix_into(channel));
self.jump_rel.iter().for_each(|c| c.mix_into(channel));
self.jump_rel_imm.iter().for_each(|c| c.mix_into(channel));
self.mul_f_f.iter().for_each(|c| c.mix_into(channel));
self.mul_f_t.iter().for_each(|c| c.mix_into(channel));
self.mul.iter().for_each(|c| c.mix_into(channel));
self.mul_imm.iter().for_each(|c| c.mix_into(channel));
self.ret.iter().for_each(|c| c.mix_into(channel));
}

Expand Down Expand Up @@ -117,8 +116,8 @@ impl OpcodeClaim {
self.jump_double_deref.iter().map(|c| c.log_sizes()),
self.jump_rel.iter().map(|c| c.log_sizes()),
self.jump_rel_imm.iter().map(|c| c.log_sizes()),
self.mul_f_f.iter().map(|c| c.log_sizes()),
self.mul_f_t.iter().map(|c| c.log_sizes()),
self.mul.iter().map(|c| c.log_sizes()),
self.mul_imm.iter().map(|c| c.log_sizes()),
self.ret.iter().map(|c| c.log_sizes()),
))
}
Expand Down Expand Up @@ -147,8 +146,8 @@ pub struct OpcodesClaimGenerator {
jump_double_deref: Vec<jump_opcode_double_deref::ClaimGenerator>,
jump_rel: Vec<jump_opcode_rel::ClaimGenerator>,
jump_rel_imm: Vec<jump_opcode_rel_imm::ClaimGenerator>,
mul_f_f: Vec<mul_opcode_is_small_f_is_imm_f::ClaimGenerator>,
mul_f_t: Vec<mul_opcode_is_small_f_is_imm_t::ClaimGenerator>,
mul: Vec<mul_opcode::ClaimGenerator>,
mul_imm: Vec<mul_opcode_imm::ClaimGenerator>,
ret: Vec<ret_opcode::ClaimGenerator>,
}
impl OpcodesClaimGenerator {
Expand Down Expand Up @@ -176,8 +175,8 @@ impl OpcodesClaimGenerator {
let mut jump_double_deref = vec![];
let mut jump_rel = vec![];
let mut jump_rel_imm = vec![];
let mut mul_f_f = vec![];
let mut mul_f_t = vec![];
let mut mul = vec![];
let mut mul_imm = vec![];
let mut ret = vec![];
if !input.casm_states_by_opcode.add_opcode.is_empty() {
add.push(add_opcode::ClaimGenerator::new(
Expand Down Expand Up @@ -315,22 +314,14 @@ impl OpcodesClaimGenerator {
}
// Handle small mul in big mul component. Temporary until airs are written with Rc_3_6_6.
// TODO(Ohad): mul small.
if !input
.casm_states_by_opcode
.mul_opcode_is_small_f_is_imm_f
.is_empty()
{
mul_f_f.push(mul_opcode_is_small_f_is_imm_f::ClaimGenerator::new(
input.casm_states_by_opcode.mul_opcode_is_small_f_is_imm_f,
if !input.casm_states_by_opcode.mul_opcode.is_empty() {
mul.push(mul_opcode::ClaimGenerator::new(
input.casm_states_by_opcode.mul_opcode,
));
}
if !input
.casm_states_by_opcode
.mul_opcode_is_small_f_is_imm_t
.is_empty()
{
mul_f_t.push(mul_opcode_is_small_f_is_imm_t::ClaimGenerator::new(
input.casm_states_by_opcode.mul_opcode_is_small_f_is_imm_t,
if !input.casm_states_by_opcode.mul_opcode_imm.is_empty() {
mul_imm.push(mul_opcode_imm::ClaimGenerator::new(
input.casm_states_by_opcode.mul_opcode_imm,
));
}
if !input.casm_states_by_opcode.ret_opcode.is_empty() {
Expand Down Expand Up @@ -361,8 +352,8 @@ impl OpcodesClaimGenerator {
jump_double_deref,
jump_rel,
jump_rel_imm,
mul_f_f,
mul_f_t,
mul,
mul_imm,
ret,
}
}
Expand Down Expand Up @@ -645,8 +636,8 @@ impl OpcodesClaimGenerator {
)
})
.unzip();
let (mul_f_f_claims, mul_f_f_interaction_gens) = self
.mul_f_f
let (mul_claims, mul_interaction_gens) = self
.mul
.into_iter()
.map(|gen| {
gen.write_trace(
Expand All @@ -658,8 +649,8 @@ impl OpcodesClaimGenerator {
)
})
.unzip();
let (mul_f_t_claims, mul_f_t_interaction_gens) = self
.mul_f_t
let (mul_imm_claims, mul_imm_interaction_gens) = self
.mul_imm
.into_iter()
.map(|gen| {
gen.write_trace(
Expand Down Expand Up @@ -707,8 +698,8 @@ impl OpcodesClaimGenerator {
jump_double_deref: jump_double_deref_claims,
jump_rel: jump_rel_claims,
jump_rel_imm: jump_rel_imm_claims,
mul_f_f: mul_f_f_claims,
mul_f_t: mul_f_t_claims,
mul: mul_claims,
mul_imm: mul_imm_claims,
ret: ret_claims,
},
OpcodesInteractionClaimGenerator {
Expand All @@ -734,8 +725,8 @@ impl OpcodesClaimGenerator {
jump_double_deref: jump_double_deref_interaction_gens,
jump_rel: jump_rel_interaction_gens,
jump_rel_imm: jump_rel_imm_interaction_gens,
mul_f_f: mul_f_f_interaction_gens,
mul_f_t: mul_f_t_interaction_gens,
mul: mul_interaction_gens,
mul_imm: mul_imm_interaction_gens,
ret_interaction_gens,
},
)
Expand Down Expand Up @@ -766,8 +757,8 @@ pub struct OpcodeInteractionClaim {
jump_double_deref: Vec<jump_opcode_double_deref::InteractionClaim>,
jump_rel: Vec<jump_opcode_rel::InteractionClaim>,
jump_rel_imm: Vec<jump_opcode_rel_imm::InteractionClaim>,
mul_f_f: Vec<mul_opcode_is_small_f_is_imm_f::InteractionClaim>,
mul_f_t: Vec<mul_opcode_is_small_f_is_imm_t::InteractionClaim>,
mul: Vec<mul_opcode::InteractionClaim>,
mul_imm: Vec<mul_opcode_imm::InteractionClaim>,
ret: Vec<ret_opcode::InteractionClaim>,
}
impl OpcodeInteractionClaim {
Expand Down Expand Up @@ -806,8 +797,8 @@ impl OpcodeInteractionClaim {
.for_each(|c| c.mix_into(channel));
self.jump_rel.iter().for_each(|c| c.mix_into(channel));
self.jump_rel_imm.iter().for_each(|c| c.mix_into(channel));
self.mul_f_f.iter().for_each(|c| c.mix_into(channel));
self.mul_f_t.iter().for_each(|c| c.mix_into(channel));
self.mul.iter().for_each(|c| c.mix_into(channel));
self.mul_imm.iter().for_each(|c| c.mix_into(channel));
self.ret.iter().for_each(|c| c.mix_into(channel));
}

Expand Down Expand Up @@ -967,14 +958,14 @@ impl OpcodeInteractionClaim {
None => total_sum,
};
}
for interaction_claim in &self.mul_f_f {
for interaction_claim in &self.mul {
let (total_sum, claimed_sum) = interaction_claim.logup_sums;
sum += match claimed_sum {
Some((claimed_sum, ..)) => claimed_sum,
None => total_sum,
};
}
for interaction_claim in &self.mul_f_t {
for interaction_claim in &self.mul_imm {
let (total_sum, claimed_sum) = interaction_claim.logup_sums;
sum += match claimed_sum {
Some((claimed_sum, ..)) => claimed_sum,
Expand Down Expand Up @@ -1015,8 +1006,8 @@ pub struct OpcodesInteractionClaimGenerator {
jump_double_deref: Vec<jump_opcode_double_deref::InteractionClaimGenerator>,
jump_rel: Vec<jump_opcode_rel::InteractionClaimGenerator>,
jump_rel_imm: Vec<jump_opcode_rel_imm::InteractionClaimGenerator>,
mul_f_f: Vec<mul_opcode_is_small_f_is_imm_f::InteractionClaimGenerator>,
mul_f_t: Vec<mul_opcode_is_small_f_is_imm_t::InteractionClaimGenerator>,
mul: Vec<mul_opcode::InteractionClaimGenerator>,
mul_imm: Vec<mul_opcode_imm::InteractionClaimGenerator>,
ret_interaction_gens: Vec<ret_opcode::InteractionClaimGenerator>,
}
impl OpcodesInteractionClaimGenerator {
Expand Down Expand Up @@ -1314,8 +1305,8 @@ impl OpcodesInteractionClaimGenerator {
)
})
.collect();
let mul_f_f_interaction_claims = self
.mul_f_f
let mul_interaction_claims = self
.mul
.into_iter()
.map(|gen| {
gen.write_interaction_trace(
Expand All @@ -1328,8 +1319,8 @@ impl OpcodesInteractionClaimGenerator {
)
})
.collect();
let mul_f_t_interaction_claims = self
.mul_f_t
let mul_imm_interaction_claims = self
.mul_imm
.into_iter()
.map(|gen| {
gen.write_interaction_trace(
Expand Down Expand Up @@ -1378,8 +1369,8 @@ impl OpcodesInteractionClaimGenerator {
jump_double_deref: jump_double_deref_interaction_claims,
jump_rel: jump_rel_interaction_claims,
jump_rel_imm: jump_rel_imm_interaction_claims,
mul_f_f: mul_f_f_interaction_claims,
mul_f_t: mul_f_t_interaction_claims,
mul: mul_interaction_claims,
mul_imm: mul_imm_interaction_claims,
ret: ret_interaction_claims,
}
}
Expand Down Expand Up @@ -1408,8 +1399,8 @@ pub struct OpcodeComponents {
jump_double_deref: Vec<jump_opcode_double_deref::Component>,
jump_rel: Vec<jump_opcode_rel::Component>,
jump_rel_imm: Vec<jump_opcode_rel_imm::Component>,
mul_f_f: Vec<mul_opcode_is_small_f_is_imm_f::Component>,
mul_f_t: Vec<mul_opcode_is_small_f_is_imm_t::Component>,
mul: Vec<mul_opcode::Component>,
mul_imm: Vec<mul_opcode_imm::Component>,
ret: Vec<ret_opcode::Component>,
}
impl OpcodeComponents {
Expand Down Expand Up @@ -1945,14 +1936,14 @@ impl OpcodeComponents {
)
})
.collect();
let mul_f_f_components = claim
.mul_f_f
let mul_components = claim
.mul
.iter()
.zip(interaction_claim.mul_f_f.iter())
.zip(interaction_claim.mul.iter())
.map(|(&claim, &interaction_claim)| {
mul_opcode_is_small_f_is_imm_f::Component::new(
mul_opcode::Component::new(
tree_span_provider,
mul_opcode_is_small_f_is_imm_f::Eval {
mul_opcode::Eval {
claim,
memory_address_to_id_lookup_elements: interaction_elements
.memory_address_to_id
Expand All @@ -1970,14 +1961,14 @@ impl OpcodeComponents {
)
})
.collect_vec();
let mul_f_t_components = claim
.mul_f_t
let mul_imm_components = claim
.mul_imm
.iter()
.zip(interaction_claim.mul_f_t.iter())
.zip(interaction_claim.mul_imm.iter())
.map(|(&claim, &interaction_claim)| {
mul_opcode_is_small_f_is_imm_t::Component::new(
mul_opcode_imm::Component::new(
tree_span_provider,
mul_opcode_is_small_f_is_imm_t::Eval {
mul_opcode_imm::Eval {
claim,
memory_address_to_id_lookup_elements: interaction_elements
.memory_address_to_id
Expand Down Expand Up @@ -2042,8 +2033,8 @@ impl OpcodeComponents {
jump_double_deref: jump_double_deref_components,
jump_rel: jump_rel_components,
jump_rel_imm: jump_rel_imm_components,
mul_f_f: mul_f_f_components,
mul_f_t: mul_f_t_components,
mul: mul_components,
mul_imm: mul_imm_components,
ret: ret_components,
}
}
Expand Down Expand Up @@ -2161,12 +2152,12 @@ impl OpcodeComponents {
.map(|component| component as &dyn ComponentProver<SimdBackend>),
);
vec.extend(
self.mul_f_f
self.mul
.iter()
.map(|component| component as &dyn ComponentProver<SimdBackend>),
);
vec.extend(
self.mul_f_t
self.mul_imm
.iter()
.map(|component| component as &dyn ComponentProver<SimdBackend>),
);
Expand Down Expand Up @@ -2225,10 +2216,10 @@ impl std::fmt::Display for OpcodeComponents {
writeln!(f, "{}", display_components(&self.jump_rel))?;
writeln!(f, "jump_rel_imm:")?;
writeln!(f, "{}", display_components(&self.jump_rel_imm))?;
writeln!(f, "mul_f_f:")?;
writeln!(f, "{}", display_components(&self.mul_f_f))?;
writeln!(f, "mul_f_t:")?;
writeln!(f, "{}", display_components(&self.mul_f_t))?;
writeln!(f, "mul:")?;
writeln!(f, "{}", display_components(&self.mul))?;
writeln!(f, "mul_imm:")?;
writeln!(f, "{}", display_components(&self.mul_imm))?;
writeln!(f, "ret:")?;
writeln!(f, "{}", display_components(&self.ret))?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions stwo_cairo_prover/crates/prover/src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub mod utils;
pub mod verify_instruction;

// TODO(Ohad): mul small.
pub mod mul_opcode_is_small_f_is_imm_f;
pub mod mul_opcode_is_small_f_is_imm_t;
pub mod mul_opcode;
pub mod mul_opcode_imm;

pub use memory::{memory_address_to_id, memory_id_to_big};
pub use range_check_vector::{range_check_19, range_check_4_3, range_check_7_2_5, range_check_9_9};
Loading
Loading