feat(v2.1-rv64): switch to u16 limbs in riscv adapters and modular airs #2805
feat(v2.1-rv64): switch to u16 limbs in riscv adapters and modular airs #2805shuklaayush wants to merge 1 commit into
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
1a2b51d to
77d6de4
Compare
This comment was marked as outdated.
This comment was marked as outdated.
77d6de4 to
4eecc82
Compare
This comment was marked as outdated.
This comment was marked as outdated.
4eecc82 to
513501d
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
513501d to
53d1b4b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
Claude finished @shuklaayush's task in 2m 21s —— View job Code Review: u16-shape W adapters and modular is-eq
Thorough review of all 48 changed files complete. This is a clean, mechanically consistent migration from u8-shaped to u16-shaped trace columns across the W-adapters, loadstore, heap adapters, and modular Soundness — Verified CorrectPointer range check pattern ( W-adapter bus packing ( Loadstore
DEFERRAL_AS guards ( Modular
Heap adapters pointer checks. All three migrated adapters (
CUDA Parity — CompleteAll
Minor Observations (non-blocking)
VerdictLooks good to merge. Constraint arithmetic is preserved at u16 granularity across all adapters, |
Note: cells_used metrics omitted because CUDA tracegen does not expose unpadded trace heights. Commit: 53d1b4b |
PR 4 of the memory-bus-u16 split, stacked on PR 2. Shrinks adapter trace columns that only reconstruct packed memory-bus payloads, and migrates the algebra modular
is_eqchip to u16 limbs.This PR sits on PR 2 (not #2794) because the PR 2 squash extended the shared vec-heap u16 adapter family and dropped the
INT256_NUM_U8_LIMBSfromriscv/circuit::adapters; PR 4 builds on those changes.Why
#2794 already reshaped these adapters' memory-aux columns and bus payloads to packed u16 blocks, but the trace columns that reconstruct those payloads were still byte-shaped:
alu_w/mul_wstoredrs1_high/rs2_highas 4 u8 limbs even though the bus consumes them as 2 u16 cells.loadstorestoredrs1_dataas 8 u8 limbs even though pointer arithmetic only needs the low 32 bits as 2 u16 cells.vec_heap,vec_heap_branch,eq_mod) reconstructed register pointers through byte limbs and bitwise byte-pair range checks.All of these can store the column as u16 cells directly and replace the high-byte range check with a scaled 16-bit range check on the high u16 cell, removing the
BitwiseOperationLookuptraffic.Separately, algebra's modular
is_eqchip operates on packed u16 operands and only needs limb-level range checks atLIMB_BITS = 16, so it can migrate to the new u16 adapter introduced in PR 2.What changes
RISC-V W-adapters and loadstore
Files:
extensions/riscv/circuit/src/adapters/{alu_w,mul_w,loadstore,mod}.rs,extensions/riscv/circuit/src/loadstore/{execution,tests}.rs,extensions/riscv/circuit/src/{base_alu_w,divrem_w,mul_w,shift_w}/tests.rs,extensions/riscv/circuit/cuda/include/riscv/adapters/{alu_w,mul_w,loadstore}.cuh.alu_w/mul_w:rs1_high,rs2_highare packed as two u16 cells; bus reads zero-extend the lower 32 bits and pull u16-shaped upper cells directly from the trace.loadstore:rs1_datashrinks toRS1_DATA_U16S = 2u16 cells (the low 32 bits of the rs1 register). Bus reads zero-extend the upper half on the wire.DEFERRAL_ASis explicitly unsupported in this adapter and the now-deadtimed_write_deferralpath is removed — feat(v2.1-rv64): switch memory bus blocks to u16 cells #2794 already dropped that opcode, and the remaining call would have instantiatedTracingMemory::write::<F, 8>, which violatesBLOCK_FE_WIDTH. The F-celled path needs a separate two-message bus shape if it is ever reintroduced.base_alu_w,divrem_w,mul_w,shift_w) updated to prank u16 cells where the column is migrated.Shared heap-data adapters
Files:
extensions/riscv-adapters/src/{vec_heap,vec_heap_branch,eq_mod,eq_mod_u16,lib}.rs,extensions/riscv-adapters/cuda/include/riscv-adapters/{constants,vec_heap,vec_heap_branch}.cuh.vec_heap,vec_heap_branch, andeq_modmaterialize register pointer values (rs_val/rd_val) as u16 cells.VariableRangeCheckeron the high u16 cell instead of byte-pairBitwiseOperationLookupsend_range.READ_SIZE/WRITE_SIZEconst generics so byte-shaped 256-bit chips (BaseAlu256,Mul256,Shift256) and u16-shaped 256-bit chips (LessThan256) can share the same wrapper without losing the block-size information needed forMemoryWriteAuxColsand pointer arithmetic.Rv64IsEqualModU16Adapter*for the new u16-shaped modularis_eq.Algebra modular
is_eqFiles:
extensions/algebra/circuit/src/modular_chip/{is_eq,addsub,muldiv,mod,tests}.rs,extensions/algebra/circuit/src/extension/{modular,hybrid,fp2}.rs,extensions/algebra/circuit/src/{execution,fields,preflight,lib}.rs,extensions/algebra/circuit/src/fp2_chip/{addsub,mod,muldiv,tests}.rs.LIMB_BITS8 → 16 where the chip's limbs are only consumed as packed u16 values.Rv64IsEqualModU16adapter variant.VariableRangeCheckerforb_lt_diff - 1andc_lt_diff - 1instead of byte-pair bitwise checks.Rv64IsEqualModU16Adapter*.[F; 4]byte arrays now prank[F; 2]u16 cells where the column is migrated; positive coverage preserved.is_eqexecutor memory reads were already adjusted in #2794 forMEMORY_BLOCK_BYTES; PR 4 does not rework that API.Cascade through dependents
Files:
extensions/bigint/circuit/src/{lib,extension/mod,tests}.rs,extensions/bigint/circuit/cuda/src/bigint.cu,extensions/ecc/circuit/src/weierstrass_chip/{add_ne,double}/mod.rs.READ_SIZE/WRITE_SIZEgeneric positions onRv64VecHeapAdapter*. Byte-shaped 256-bit chips passMEMORY_BLOCK_BYTES; u16-shaped chips passBLOCK_FE_WIDTH.INT256_NUM_U8_LIMBSfrom the bigint crate root (per PR 2's reviewer feedback) instead ofriscv/circuit::adapters.Migration notes
Rv64VecHeapAdapter*now takes 5 const generics (NUM_READS, BLOCKS_PER_READ, BLOCKS_PER_WRITE, READ_SIZE, WRITE_SIZE). Byte-shaped 256-bit chips: passMEMORY_BLOCK_BYTESfor both sizes. u16-shaped chips: useRv64VecHeapU16Adapter.alu_w/mul_wadapter callsites that materializedrs_highbytes should pull u16-shaped upper cells from the new column slot.loadstorers1_datacolumns shrink from 8 u8s to 2 u16 cells; trace-fillers that previously wrote 8 byte cells should write 2 u16 cells (low 32 bits) and let the AIR zero-extend on the bus.is_eqmodular chip callers should switch fromRv64IsEqualModAdapter*toRv64IsEqualModU16Adapter*and passLANE_SIZE = BLOCK_FE_WIDTH(= 4 u16 cells per heap-read block).DEFERRAL_ASis no longer routed throughRv64LoadStoreAdapter; the F-celled deferral-store path was already removed in feat(v2.1-rv64): switch memory bus blocks to u16 cells #2794 and any reintroduction needs a dedicated two-message bus shape.resolves int-7830, int-7831