Allow Reading from Hint Space for MULTI_OBSERVE#41
Open
darth-cy wants to merge 2 commits intofeat/hint_bridgefrom
Open
Allow Reading from Hint Space for MULTI_OBSERVE#41darth-cy wants to merge 2 commits intofeat/hint_bridgefrom
MULTI_OBSERVE#41darth-cy wants to merge 2 commits intofeat/hint_bridgefrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the MULTI_OBSERVE Poseidon2 instruction to optionally read input data from hint space instead of memory. Previously, MULTI_OBSERVE always read input elements from a memory array pointer. Now, a context array is used to pass parameters (init_pos, len, is_hint, reserved), and when is_hint=1, data is read from hint space via the hint bus instead of memory.
Changes:
- Replaced separate
init_posandlenregister parameters with a context array (ctx_ptr) and added ahint_idregister parameter across the entire instruction pipeline (compiler IR, ASM, conversion, execution, AIR, columns). - Added conditional hint space lookup in the AIR constraints and trace generation: in hint mode, memory reads are skipped and hint bus lookups are used instead, with adjusted timestamp increments (1 per element instead of 2).
- Wired
HintSpaceProviderChipintoNativePoseidon2Fillerto register hint bus interactions during trace filling.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
extensions/native/recursion/src/challenger/duplex.rs |
Pass None for new hint_id parameter |
extensions/native/compiler/src/ir/poseidon.rs |
Allocate context array, pack params, read back result |
extensions/native/compiler/src/ir/instructions.rs |
Update Poseidon2MultiObserve variant to use ctx_ptr and hint_id |
extensions/native/compiler/src/conversion/mod.rs |
Update instruction field mapping for conversion |
extensions/native/compiler/src/asm/instruction.rs |
Update ASM instruction docs and display |
extensions/native/compiler/src/asm/compiler.rs |
Update DslIr→AsmInstruction mapping |
extensions/native/circuit/src/poseidon2/execution.rs |
Read ctx array and hint data in execution path |
extensions/native/circuit/src/poseidon2/columns.rs |
Add ctx array, read_ctx, register columns; remove old fields |
extensions/native/circuit/src/poseidon2/chip.rs |
Add hint_space_provider, conditional hint reads in trace gen |
extensions/native/circuit/src/poseidon2/air.rs |
Add hint bus lookups, conditional memory reads, timestamp adjustments |
extensions/native/circuit/src/extension/mod.rs |
Reorder chip creation to pass hint_space_provider to poseidon2 |
extensions/native/circuit/cuda/src/poseidon2.cu |
Update CUDA trace fill for hint mode timestamps and reads |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+384
to
+403
| // is_hint = ctx[2] | ||
| uint32_t is_hint = | ||
| specific[COL_INDEX(MultiObserveCols, ctx[2])].asUInt32(); | ||
| uint32_t ts_per_element = 2 - is_hint; | ||
| for (uint32_t j = chunk_start; j < chunk_end; ++j) { | ||
| if (!is_hint) { | ||
| // Non-hint mode: fill read_data aux | ||
| mem_fill_base( | ||
| mem_helper, | ||
| start_timestamp, | ||
| specific.slice_from(COL_INDEX(MultiObserveCols, read_data[j].base)) | ||
| ); | ||
| } | ||
| // Write timestamp: start_timestamp + (1 - is_hint) for non-hint, start_timestamp for hint | ||
| mem_fill_base( | ||
| mem_helper, | ||
| start_timestamp, | ||
| specific.slice_from(COL_INDEX(MultiObserveCols, read_data[j].base)) | ||
| ); | ||
| mem_fill_base( | ||
| mem_helper, | ||
| start_timestamp + 1, | ||
| start_timestamp + (1 - is_hint), | ||
| specific.slice_from(COL_INDEX(MultiObserveCols, write_data[j].base)) | ||
| ); | ||
| start_timestamp += 2; | ||
| start_timestamp += ts_per_element; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.