-
Notifications
You must be signed in to change notification settings - Fork 279
Fix the release dry-run publish cycle and preserve leaf-only DAG imports #2931
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
102bb38
Keep the release dry-run from finding a publish cycle
huitseeker a59e164
Preserve leaf-only DAG imports with explicit snapshots
huitseeker ea9089b
Delete the stale publish-release backup script
huitseeker 398dced
chore: CHANGELOG
huitseeker f242c9d
Simplify DagBuilder internals and deduplicate test helpers
huitseeker e2789df
Merge branch 'next' into fix/release-dry-run-cycle-and-dag-snapshots
huitseeker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| use miden_ace_codegen::{ | ||
| AceConfig, AceError, EXT_DEGREE, InputKey, LayoutKind, build_ace_circuit_for_air, | ||
| build_ace_dag_for_air, emit_circuit, | ||
| testing::{ | ||
| eval_dag, eval_folded_constraints, eval_periodic_values, eval_quotient, fill_inputs, | ||
| zps_for_chunk, | ||
| }, | ||
| }; | ||
| use miden_air::{LiftedAir, ProcessorAir}; | ||
| use miden_core::{Felt, field::QuadFelt}; | ||
| use miden_crypto::{ | ||
| field::{Field, PrimeCharacteristicRing}, | ||
| stark::air::symbolic::{AirLayout, SymbolicAirBuilder}, | ||
| }; | ||
|
|
||
| #[test] | ||
| fn processor_air_dag_matches_manual_eval() { | ||
| let air = ProcessorAir; | ||
| let config = AceConfig { | ||
| num_quotient_chunks: 2, | ||
| num_vlpi_groups: 0, | ||
| layout: LayoutKind::Native, | ||
| }; | ||
| let artifacts = build_ace_dag_for_air::<_, Felt, QuadFelt>(&air, config).unwrap(); | ||
| let layout = artifacts.layout.clone(); | ||
| let inputs: Vec<QuadFelt> = fill_inputs(&layout); | ||
| let z_k = inputs[layout.index(InputKey::ZK).unwrap()]; | ||
| let periodic_values = eval_periodic_values::<Felt, QuadFelt>( | ||
| &LiftedAir::<Felt, QuadFelt>::periodic_columns(&air), | ||
| z_k, | ||
| ); | ||
|
|
||
| let air_layout = AirLayout { | ||
| preprocessed_width: 0, | ||
| main_width: layout.counts.width, | ||
| num_public_values: layout.counts.num_public, | ||
| permutation_width: layout.counts.aux_width, | ||
| num_permutation_challenges: layout.counts.num_randomness, | ||
| num_permutation_values: LiftedAir::<Felt, QuadFelt>::num_aux_values(&air), | ||
| num_periodic_columns: layout.counts.num_periodic, | ||
| }; | ||
| let mut builder = SymbolicAirBuilder::<Felt, QuadFelt>::new(air_layout); | ||
| LiftedAir::<Felt, QuadFelt>::eval(&air, &mut builder); | ||
|
|
||
| let acc = eval_folded_constraints( | ||
| &builder.base_constraints(), | ||
| &builder.extension_constraints(), | ||
| &builder.constraint_layout(), | ||
| &inputs, | ||
| &layout, | ||
| &periodic_values, | ||
| ); | ||
| let z_pow_n = inputs[layout.index(InputKey::ZPowN).unwrap()]; | ||
| let vanishing = z_pow_n - QuadFelt::ONE; | ||
| let expected = acc - eval_quotient::<Felt, QuadFelt>(&layout, &inputs) * vanishing; | ||
|
|
||
| let actual = eval_dag(&artifacts.dag, &inputs, &layout).unwrap(); | ||
| assert_eq!(actual, expected); | ||
| } | ||
|
|
||
| #[test] | ||
| fn processor_air_dag_rejects_mismatched_layout() { | ||
| let air = ProcessorAir; | ||
| let dag_config = AceConfig { | ||
| num_quotient_chunks: 8, | ||
| num_vlpi_groups: 0, | ||
| layout: LayoutKind::Native, | ||
| }; | ||
| let layout_config = AceConfig { | ||
| num_quotient_chunks: 1, | ||
| num_vlpi_groups: 0, | ||
| layout: LayoutKind::Native, | ||
| }; | ||
|
|
||
| let dag = build_ace_dag_for_air::<_, Felt, QuadFelt>(&air, dag_config).unwrap().dag; | ||
| let wrong_layout = | ||
| build_ace_dag_for_air::<_, Felt, QuadFelt>(&air, layout_config).unwrap().layout; | ||
| let inputs: Vec<QuadFelt> = fill_inputs(&wrong_layout); | ||
|
|
||
| let err = eval_dag(&dag, &inputs, &wrong_layout).unwrap_err(); | ||
| assert!( | ||
| matches!(err, AceError::InvalidInputLayout { .. }), | ||
| "expected InvalidInputLayout, got {err:?}" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| #[allow(clippy::print_stdout)] | ||
| fn processor_air_chiplet_rows() { | ||
| let air = ProcessorAir; | ||
| let config = AceConfig { | ||
| num_quotient_chunks: 8, | ||
| num_vlpi_groups: 1, | ||
| layout: LayoutKind::Masm, | ||
| }; | ||
|
|
||
| let circuit = build_ace_circuit_for_air::<_, Felt, QuadFelt>(&air, config).unwrap(); | ||
| let encoded = circuit.to_ace().unwrap(); | ||
| let read_rows = encoded.num_read_rows(); | ||
| let eval_rows = encoded.num_eval_rows(); | ||
| let total_rows = read_rows + eval_rows; | ||
|
|
||
| println!( | ||
| "ACE chiplet rows (ProcessorAir): read={}, eval={}, total={}, inputs={}, constants={}, nodes={}", | ||
| read_rows, | ||
| eval_rows, | ||
| total_rows, | ||
| encoded.num_inputs(), | ||
| encoded.num_constants(), | ||
| encoded.num_nodes() | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn synthetic_ood_adjusts_quotient_to_zero() { | ||
| let config = AceConfig { | ||
| num_quotient_chunks: 8, | ||
| num_vlpi_groups: 0, | ||
| layout: LayoutKind::Masm, | ||
| }; | ||
|
|
||
| let artifacts = | ||
| build_ace_dag_for_air::<_, Felt, QuadFelt>(&ProcessorAir, config).expect("ace dag"); | ||
| let circuit = emit_circuit(&artifacts.dag, artifacts.layout.clone()).expect("ace circuit"); | ||
|
|
||
| let mut inputs: Vec<QuadFelt> = fill_inputs(&artifacts.layout); | ||
| let root = circuit.eval(&inputs).expect("circuit eval"); | ||
|
|
||
| let z_pow_n = inputs[artifacts.layout.index(InputKey::ZPowN).unwrap()]; | ||
| let vanishing = z_pow_n - QuadFelt::ONE; | ||
| let zps_0 = zps_for_chunk::<Felt, QuadFelt>(&artifacts.layout, &inputs, 0); | ||
| let delta = root * (zps_0 * vanishing).inverse(); | ||
|
|
||
| let idx = artifacts | ||
| .layout | ||
| .index(InputKey::QuotientChunkCoord { offset: 0, chunk: 0, coord: 0 }) | ||
| .unwrap(); | ||
| inputs[idx] += delta; | ||
|
|
||
| let result = circuit.eval(&inputs).expect("circuit eval"); | ||
| assert!(result.is_zero(), "ACE circuit must evaluate to zero"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn quotient_next_inputs_do_not_affect_eval() { | ||
| let config = AceConfig { | ||
| num_quotient_chunks: 8, | ||
| num_vlpi_groups: 0, | ||
| layout: LayoutKind::Masm, | ||
| }; | ||
|
|
||
| let artifacts = | ||
| build_ace_dag_for_air::<_, Felt, QuadFelt>(&ProcessorAir, config).expect("ace dag"); | ||
| let circuit = emit_circuit(&artifacts.dag, artifacts.layout.clone()).expect("ace circuit"); | ||
|
|
||
| let mut inputs: Vec<QuadFelt> = fill_inputs(&artifacts.layout); | ||
|
|
||
| let root = circuit.eval(&inputs).expect("circuit eval"); | ||
| let z_pow_n = inputs[artifacts.layout.index(InputKey::ZPowN).unwrap()]; | ||
| let vanishing = z_pow_n - QuadFelt::ONE; | ||
| let zps_0 = zps_for_chunk::<Felt, QuadFelt>(&artifacts.layout, &inputs, 0); | ||
| let delta = root * (zps_0 * vanishing).inverse(); | ||
| let idx = artifacts | ||
| .layout | ||
| .index(InputKey::QuotientChunkCoord { offset: 0, chunk: 0, coord: 0 }) | ||
| .unwrap(); | ||
| inputs[idx] += delta; | ||
| assert!( | ||
| circuit.eval(&inputs).expect("circuit eval").is_zero(), | ||
| "precondition: zero root" | ||
| ); | ||
|
|
||
| for chunk in 0..artifacts.layout.counts.num_quotient_chunks { | ||
| for coord in 0..EXT_DEGREE { | ||
| let idx = artifacts | ||
| .layout | ||
| .index(InputKey::QuotientChunkCoord { offset: 1, chunk, coord }) | ||
| .unwrap(); | ||
| inputs[idx] += QuadFelt::from(Felt::new(123 + (chunk * 7 + coord) as u64)); | ||
| } | ||
| } | ||
|
|
||
| let result = circuit.eval(&inputs).expect("circuit eval"); | ||
| assert!(result.is_zero(), "quotient_next should not affect ACE eval"); | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.