Skip to content

Commit

Permalink
[fix] Multiple Phase Lookup (#162)
Browse files Browse the repository at this point in the history
Fix multiple phase lookup
  • Loading branch information
nyunyunyunyu committed Sep 19, 2023
1 parent 26b81a3 commit 30cc021
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions halo2-base/src/gates/circuit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ impl<F: ScalarField> BaseCircuitBuilder<F> {
let cell = advice[0].cell.as_ref().unwrap();
let copy_manager = self.core.copy_manager.lock().unwrap();
let acell = copy_manager.assigned_advices[cell];
assert_eq!(
acell.column,
config.gate.basic_gates[phase][0].value.into(),
"lookup column does not match"
);
q_lookup.enable(region, acell.row_offset).unwrap();
}
}
Expand Down
5 changes: 3 additions & 2 deletions halo2-base/src/gates/range/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ impl<F: ScalarField> RangeConfig<F> {
for (phase, &num_columns) in num_lookup_advice.iter().enumerate() {
let num_advice = *gate_params.num_advice_per_phase.get(phase).unwrap_or(&0);
let mut columns = Vec::new();
// if num_columns is set to 0, then we assume you do not want to perform any lookups in that phase
if num_advice == 1 && num_columns != 0 {
// If num_columns is set to 0, then we assume you do not want to perform any lookups in that phase.
// Disable this optimization in phase > 0 because you might set selectors based a cell from other columns.
if phase == 0 && num_advice == 1 && num_columns != 0 {
q_lookup.push(Some(meta.complex_selector()));
} else {
q_lookup.push(None);
Expand Down

0 comments on commit 30cc021

Please sign in to comment.