Skip to content

Allow Reading from Hint Space for MULTI_OBSERVE - #41

Merged
kunxian-xia merged 14 commits into
feat/hint_bridgefrom
feat/hint_multi_observe
Mar 23, 2026
Merged

Allow Reading from Hint Space for MULTI_OBSERVE#41
kunxian-xia merged 14 commits into
feat/hint_bridgefrom
feat/hint_multi_observe

Conversation

@darth-cy

Copy link
Copy Markdown

No description provided.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_pos and len register parameters with a context array (ctx_ptr) and added a hint_id register 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 HintSpaceProviderChip into NativePoseidon2Filler to 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
FileDescription
extensions/native/recursion/src/challenger/duplex.rsPass None for new hint_id parameter
extensions/native/compiler/src/ir/poseidon.rsAllocate context array, pack params, read back result
extensions/native/compiler/src/ir/instructions.rsUpdate Poseidon2MultiObserve variant to use ctx_ptr and hint_id
extensions/native/compiler/src/conversion/mod.rsUpdate instruction field mapping for conversion
extensions/native/compiler/src/asm/instruction.rsUpdate ASM instruction docs and display
extensions/native/compiler/src/asm/compiler.rsUpdate DslIr→AsmInstruction mapping
extensions/native/circuit/src/poseidon2/execution.rsRead ctx array and hint data in execution path
extensions/native/circuit/src/poseidon2/columns.rsAdd ctx array, read_ctx, register columns; remove old fields
extensions/native/circuit/src/poseidon2/chip.rsAdd hint_space_provider, conditional hint reads in trace gen
extensions/native/circuit/src/poseidon2/air.rsAdd hint bus lookups, conditional memory reads, timestamp adjustments
extensions/native/circuit/src/extension/mod.rsReorder chip creation to pass hint_space_provider to poseidon2
extensions/native/circuit/cuda/src/poseidon2.cuUpdate CUDA trace fill for hint mode timestamps and reads

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadextensions/native/circuit/cuda/src/poseidon2.cu Outdated
Comment threadextensions/native/circuit/src/poseidon2/chip.rs
@darth-cy
darth-cy requested a review from CopilotMarch 19, 2026 00:58

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the native Poseidon2 MULTI_OBSERVE opcode to optionally source absorbed elements from hint space (via hint_id) instead of memory, by moving (init_pos, len, is_hint) into a context array and updating the VM IR/ASM, CPU executor/trace filler, AIR constraints, and CUDA tracegen plumbing accordingly.

Changes:

  • Update Poseidon2MultiObserve IR/ASM encoding to take (ctx_ptr, hint_id) and read/write init_pos via ctx[0].
  • Implement hint-mode execution/trace behavior (CPU + CUDA), including hint-bus lookups and updated timestamping.
  • Wire hint space provider availability/order into CPU and GPU extension initialization.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
extensions/native/recursion/src/challenger/duplex.rsUpdate callsite to new poseidon2_multi_observe(..., input_len, hint_id) signature.
extensions/native/compiler/src/ir/poseidon.rsBuilder API now constructs ctx array and emits updated Poseidon2MultiObserve.
extensions/native/compiler/src/ir/instructions.rsRedefine DslIr::Poseidon2MultiObserve operands to (ctx_ptr, hint_id) form.
extensions/native/compiler/src/conversion/mod.rsMap updated ASM operands to the MULTI_OBSERVE machine instruction fields.
extensions/native/compiler/src/asm/instruction.rsUpdate assembly enum + display formatting for new operand order/meaning.
extensions/native/compiler/src/asm/compiler.rsEmit updated Poseidon2MultiObserve instruction from IR.
extensions/native/circuit/src/poseidon2/execution.rsNative executor: read ctx, optionally read elements from hint space, write back final idx into ctx[0].
extensions/native/circuit/src/poseidon2/cuda.rsGPU chip: add optional hint-space provider and scan records to populate it pre-upload.
extensions/native/circuit/src/poseidon2/columns.rsAdd not_hint_multi_observe and expand multi-observe specific columns to include ctx + hint_id.
extensions/native/circuit/src/poseidon2/chip.rsCPU tracegen/executor: implement ctx reads, hint-mode element sourcing, timestamps, and ctx[0] writeback.
extensions/native/circuit/src/poseidon2/air.rsAIR: enforce ctx reads, hint-bus lookups, gated memory reads/writes, and updated timestamps.
extensions/native/circuit/src/jal_rangecheck/cuda.rsMinor import formatting change.
extensions/native/circuit/src/fri/cuda.rsMinor import formatting change.
extensions/native/circuit/src/extension/mod.rsReorder AIR/chip initialization so hint space provider is available before Poseidon2; pass provider into fillers.
extensions/native/circuit/src/extension/cuda.rsCreate CPU hint-space provider for GPU path and pass it into Poseidon2 GPU chip.
extensions/native/circuit/cuda/src/poseidon2.cuCUDA mem-fill logic updated for ctx read + hint_id read and hint-mode timestamps.
extensions/native/circuit/cuda/include/native/poseidon2.cuhCUDA struct layout updated to match new multi-observe columns.
crates/circuits/mod-builder/src/utils.rsTrailing newline added.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadextensions/native/compiler/src/ir/poseidon.rs
Comment threadextensions/native/circuit/src/poseidon2/execution.rs
Comment threadextensions/native/circuit/src/poseidon2/chip.rs
Comment threadextensions/native/circuit/src/poseidon2/air.rs
@kunxian-xia
kunxian-xia merged commit 23c956d into feat/hint_bridgeMar 23, 2026
3 of 35 checks passed
Sign up for freeto 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

@darth-cy@kunxian-xia