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

feat: general offline checker #164

Merged
merged 32 commits into from
Jul 24, 2024
Merged

feat: general offline checker #164

merged 32 commits into from
Jul 24, 2024

Conversation

bfan05
Copy link
Contributor

@bfan05 bfan05 commented Jul 19, 2024

Resolves INT-1765

A bit bigger of a PR than I had anticipated but the overlapping logic for page r/w checker and vm memory checker have been combined.

Note: general offline checker does not constrain anything about data being equal across rows (only that the same_data bit is computed correctly). Each individual offline checker handles this according to its needs.

Copy link

linear bot commented Jul 19, 2024

INT-1765 General Offline Checker

Create implementation of offline checker that has common parts from page r/w checker and vm memory checker

Refactor page r/w checker and memory checker to use general offline checker

chips/src/offline_checker/air.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/air.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/columns.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/columns.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/columns.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/mod.rs Show resolved Hide resolved
chips/src/page_rw_checker/offline_checker/air.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/columns.rs Outdated Show resolved Hide resolved
/// this bit indicates if (idx, clk) is strictly more than the one in the previous row
pub lt_bit: T,
/// a bit to indicate if this is a valid operation row
pub is_valid: T,
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer is_extra to indicate auxiliary rows. is_valid sounds like we're making a check for something 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@OsamaAlkhodairy I need it to be is_valid right now for the interactions for the VM memory chip (should send with count is_valid); we can change this once Jonathan's pr is merged

chips/src/offline_checker/trace.rs Outdated Show resolved Hide resolved
@jonathanpwang
Copy link
Contributor

@bfan05 lmk when you finish addressing Osama's comments and I'll take a final pass.

btw @bfan05 @OsamaAlkhodairy after we allow the interactions to have up to degree 2, were there any things to potentially change in OfflineChecker?

@bfan05 bfan05 requested a review from OsamaAlkhodairy July 19, 2024 23:14
chips/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

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

This can be merged after is_equal_data is fixed, and after @OsamaAlkhodairy gives the OK.

@jonathanpwang
Copy link
Contributor

@OsamaAlkhodairy can you take a look

@OsamaAlkhodairy
Copy link
Contributor

@OsamaAlkhodairy can you take a look

Will do this tomorrow

Copy link
Contributor

@OsamaAlkhodairy OsamaAlkhodairy left a comment

Choose a reason for hiding this comment

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

LGTM after addressing comments. For the comments I left on the PageOfflineChecker, try to see if there's something analogous in the MemoryOfflineChecker that should be changed similarly.

chips/src/offline_checker/air.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/bridge.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/trace.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/trace.rs Outdated Show resolved Hide resolved
chips/src/page_rw_checker/offline_checker/air.rs Outdated Show resolved Hide resolved
chips/src/page_rw_checker/offline_checker/trace.rs Outdated Show resolved Hide resolved
chips/src/page_rw_checker/tests.rs Outdated Show resolved Hide resolved
vm/src/memory/offline_checker/columns.rs Outdated Show resolved Hide resolved
chips/src/offline_checker/trace.rs Outdated Show resolved Hide resolved
vm/src/memory/offline_checker/trace.rs Show resolved Hide resolved
@OsamaAlkhodairy
Copy link
Contributor

OsamaAlkhodairy commented Jul 23, 2024

@bfan05 @jonathanpwang I ran a benchmark on one config on main~3 (main before InteractionBuilder was merged) vs this branch. Here are the results: main-results, general-offline-checker-results.

It seems like the trace generation time went up by 5 seconds in this branch vs main~3. The time it took for the other parts of proving were similar but a little different, so the total proving time went up by only 2 seconds vs main~3. There are usually some fluctuations in each benchmark run, so I'm not totally sure about the significance of those results.

I discussed with Ben some improvements for trace generation (basically to use borrowing instead of cloning index and data multiple times). Since the VM memory uses arrays of fixed length instead of vectors everywhere, we will have to clone only there (if we store the underlying idx and data as vectors to make trace generation for PageOfflineChecker faster), but I think that's okay since idx_len and data_len are small for memory, unlike pages.

If we think the results of this benchmark are okay, we can merge this and add the mentioned optimizations in another PR (hopefully having the general OfflineChecker doesn't fundamentally make things slower). What do you think @jonathanpwang?

@jonathanpwang
Copy link
Contributor

@OsamaAlkhodairy I think we can merge -- let me handle the resolving of conflicts.

We should then make some flamegraphs (turn off parallelism) to do a more detailed analysis.
Still surprising to me trace generation takes so long - my default guess is it's a mixture of cloning and also possibly the data structures used.

@jonathanpwang
Copy link
Contributor

@bfan05 @OsamaAlkhodairy the unit test failed after I merged main. I'm not sure where the problem is

@bfan05
Copy link
Contributor Author

bfan05 commented Jul 24, 2024

@jonathanpwang will see if i can fix

@jonathanpwang
Copy link
Contributor

@bfan05 it seems to be something about the OfflineChecker's receive, maybe the order of fields isn't right (although I tried to check it). Or I messed with the is valid?

@bfan05
Copy link
Contributor Author

bfan05 commented Jul 24, 2024

@jonathanpwang i sent you a message in slack; I found a fix but it increases number of interactions unnecessarily

@bfan05 bfan05 merged commit d991bae into main Jul 24, 2024
5 checks passed
@bfan05 bfan05 deleted the feat/general-offline-checker branch July 24, 2024 17:00
luffykai pushed a commit that referenced this pull request Dec 13, 2024
* first commit

* chore: deduplicate is_equal indicator for IsEqualVec

* wip

* fix group by and other tests

* chore: use aux instead of indexing into flatten for is_equal_data

* feat: air and trace for general offline checker

* wip

* wip

* wip

* feat: general offline checker

* feat: memory offline checker uses general offline checker

* wip

* feat: page r/w checker uses general offline checker

* chore: remove rustc files

* chore: address comments

* chore: remove same_data and corresponding aux cols from general oc

* chore: add file

* chore: fix lints

* chore: use p3-maybe-rayon

* remove rayon

* chore: fix MemoryChip

* address comments

* temp interaction fix

* feat: is_receive column for offline checker

* chore: remove is_internal column from PageOfflineChecker and use OfflineChecker is_receive instead

---------

Co-authored-by: Jonathan Wang <31040440+jonathanpwang@users.noreply.github.com>
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