Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/crates/rusticol-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ loop-v2 = ["dep:ninjars", "symbolica-runtime"]
bincode.workspace = true
libloading = { version = "0.9", optional = true }
libc.workspace = true
ninjars = { git = "https://github.com/alphal00p/ninjars.git", rev = "a069504e3dc884d6e2682aadc75fb12a7f4e7c07", optional = true }
ninjars = { git = "https://github.com/alphal00p/ninjars.git", rev = "084e466bd464bf4cf847fe5708503d62bc835ca9", optional = true }
num-complex = { version = "0.4", optional = true }
rayon.workspace = true
serde.workspace = true
Expand Down
22 changes: 11 additions & 11 deletions rust/loop-reduction/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ license = "0BSD"
publish = false

[dependencies]
feynkit-amplitude = { git = "https://github.com/alphal00p/gammaloop.git", rev = "ee18b8e6386cb36ca88b1917e00ab2ebae93e68e", default-features = false, features = ["native"] }
feynkit-generator = { git = "https://github.com/alphal00p/gammaloop.git", rev = "ee18b8e6386cb36ca88b1917e00ab2ebae93e68e", default-features = false, features = ["native"] }
feynkit-graph = { git = "https://github.com/alphal00p/gammaloop.git", rev = "ee18b8e6386cb36ca88b1917e00ab2ebae93e68e", default-features = false, features = ["native"] }
idenso = { git = "https://github.com/alphal00p/gammaloop.git", rev = "ee18b8e6386cb36ca88b1917e00ab2ebae93e68e", default-features = false, features = ["native"] }
spenso = { git = "https://github.com/alphal00p/gammaloop.git", rev = "ee18b8e6386cb36ca88b1917e00ab2ebae93e68e", default-features = false, features = ["native", "shadowing"] }
spenso-hep-lib = { git = "https://github.com/alphal00p/gammaloop.git", rev = "ee18b8e6386cb36ca88b1917e00ab2ebae93e68e", default-features = false, features = ["native"] }
feynkit-model = { git = "https://github.com/alphal00p/gammaloop.git", rev = "ee18b8e6386cb36ca88b1917e00ab2ebae93e68e", default-features = false, features = ["native"] }
feynkit-kinematics = { git = "https://github.com/alphal00p/gammaloop.git", rev = "ee18b8e6386cb36ca88b1917e00ab2ebae93e68e", default-features = false, features = ["native"] }
feynkit-amplitude = { git = "https://github.com/alphal00p/gammaloop.git", rev = "6cbe1b4d296eb78767a55b9ce9cd25ef67feed41", default-features = false, features = ["native"] }
feynkit-generator = { git = "https://github.com/alphal00p/gammaloop.git", rev = "6cbe1b4d296eb78767a55b9ce9cd25ef67feed41", default-features = false, features = ["native"] }
feynkit-graph = { git = "https://github.com/alphal00p/gammaloop.git", rev = "6cbe1b4d296eb78767a55b9ce9cd25ef67feed41", default-features = false, features = ["native"] }
idenso = { git = "https://github.com/alphal00p/gammaloop.git", rev = "6cbe1b4d296eb78767a55b9ce9cd25ef67feed41", default-features = false, features = ["native"] }
spenso = { git = "https://github.com/alphal00p/gammaloop.git", rev = "6cbe1b4d296eb78767a55b9ce9cd25ef67feed41", default-features = false, features = ["native", "shadowing"] }
spenso-hep-lib = { git = "https://github.com/alphal00p/gammaloop.git", rev = "6cbe1b4d296eb78767a55b9ce9cd25ef67feed41", default-features = false, features = ["native"] }
feynkit-model = { git = "https://github.com/alphal00p/gammaloop.git", rev = "6cbe1b4d296eb78767a55b9ce9cd25ef67feed41", default-features = false, features = ["native"] }
feynkit-kinematics = { git = "https://github.com/alphal00p/gammaloop.git", rev = "6cbe1b4d296eb78767a55b9ce9cd25ef67feed41", default-features = false, features = ["native"] }
rusticol-core = { path = "../crates/rusticol-core", features = ["symbolica-runtime", "python-generation-bridge", "loop-v2"] }
ninjars = { git = "https://github.com/alphal00p/ninjars.git", rev = "a069504e3dc884d6e2682aadc75fb12a7f4e7c07" }
ninjars-graph = { git = "https://github.com/alphal00p/ninjars.git", rev = "a069504e3dc884d6e2682aadc75fb12a7f4e7c07" }
ninjars-symbolica = { git = "https://github.com/alphal00p/ninjars.git", rev = "a069504e3dc884d6e2682aadc75fb12a7f4e7c07", features = ["native-masters"] }
ninjars = { git = "https://github.com/alphal00p/ninjars.git", rev = "084e466bd464bf4cf847fe5708503d62bc835ca9" }
ninjars-graph = { git = "https://github.com/alphal00p/ninjars.git", rev = "084e466bd464bf4cf847fe5708503d62bc835ca9" }
ninjars-symbolica = { git = "https://github.com/alphal00p/ninjars.git", rev = "084e466bd464bf4cf847fe5708503d62bc835ca9", features = ["native-masters"] }
oneloop = { git = "https://github.com/alphal00p/oneloopmaster.git", rev = "8ec256fc26cb361b20e10f59c19beb35717ef32c", default-features = false }
symbolica = { version = "3.0.1", default-features = false, features = ["integer-gmp", "float-mpfr"] }
serde = { version = "1", features = ["derive"] }
Expand Down
1 change: 1 addition & 0 deletions rust/loop-reduction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod tree_correlations;
mod tree_color;
mod tree_components;
mod tree_norm;
pub mod tree_null_states;
pub mod tree_preparation;
mod tree_runtime;
pub mod verification;
Expand Down
13 changes: 1 addition & 12 deletions rust/loop-reduction/src/runtime/coefficients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,7 @@ impl CoefficientEvaluator {
arithmetic: Arithmetic,
bits: u32,
) -> ExecutionResult<Self> {
match arithmetic {
Arithmetic::Double if bits != 53 => {
return Err(error("double arithmetic requires exactly 53 bits"));
}
Arithmetic::DoubleDouble if bits != 106 => {
return Err(error("double-double arithmetic requires exactly 106 bits"));
}
Arithmetic::Arbitrary if bits < 2 => {
return Err(error("arbitrary arithmetic requires at least two bits"));
}
_ => {}
}
validate_working_precision(arithmetic, bits)?;
let exact = exact_state(state)?;
let evaluator = match arithmetic {
Arithmetic::Double => Coefficients::Double(batch_evaluator(exact, &0_f64)),
Expand Down
22 changes: 21 additions & 1 deletion rust/loop-reduction/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub use master_cache::{MasterCache, MasterStatistics};
pub use ninjars::fast::tensor_layout::monomials as tensor_monomials;
pub use reduction::{DecimalMomentum, PolynomialPlan, RawLane, ReductionBatch};
pub use schedule::{CoefficientKernelCache, CoefficientPlan};
pub(crate) use states::wavefunction_error;
pub use states::{
PartialStates, on_shell_wavefunctions_batch, wavefunctions_batch, wavefunctions_partial_batch,
};
Expand All @@ -45,6 +46,25 @@ pub fn register_scalar_primitives() {
}
pub type DecimalComplex = [String; 2];
pub type ExecutionResult<T> = Result<T, ExecutionError>;

// One shared working-carrier policy. This is declared attempt precision, not
// a lower bound on the reliable bits of values after numerical cancellation.
pub(crate) fn validate_working_precision(arithmetic: Arithmetic, bits: u32) -> ExecutionResult<()> {
match arithmetic {
Arithmetic::Double if bits != 53 => {
return Err(error("double arithmetic requires exactly 53 bits"));
}
Arithmetic::DoubleDouble if bits != 106 => {
return Err(error("double-double arithmetic requires exactly 106 bits"));
}
Arithmetic::Arbitrary if bits < 2 => {
return Err(error("arbitrary arithmetic requires at least two bits"));
}
_ => {}
}
Ok(())
}

#[derive(Debug, Clone)]
pub struct ExecutionError(rusticol_core::RusticolError);
impl ExecutionError {
Expand All @@ -63,7 +83,7 @@ impl ExecutionError {
value.to_string(),
))
}
fn context(self, value: impl Display) -> Self {
pub(crate) fn context(self, value: impl Display) -> Self {
Self(rusticol_core::RusticolError::with_kind(
self.kind(),
value.to_string(),
Expand Down
13 changes: 1 addition & 12 deletions rust/loop-reduction/src/runtime/reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,7 @@ impl PolynomialPlan {
bits: u32,
engine: &str,
) -> ExecutionResult<Self> {
match arithmetic {
Arithmetic::Double if bits != 53 => {
return Err(error("double arithmetic requires exactly 53 bits"));
}
Arithmetic::DoubleDouble if bits != 106 => {
return Err(error("double-double arithmetic requires exactly 106 bits"));
}
Arithmetic::Arbitrary if bits < 2 => {
return Err(error("arbitrary arithmetic requires at least two bits"));
}
_ => {}
}
validate_working_precision(arithmetic, bits)?;
if !matches!(engine, "generic" | "fast" | "fast-tensor") {
return Err(error("engine must be generic, fast or fast-tensor"));
}
Expand Down
32 changes: 18 additions & 14 deletions rust/loop-reduction/src/runtime/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,24 @@ fn state_components<T: BatchCarrier + KinematicScalar>(
PhysicalMomentum::from(std::array::from_fn::<_, 4, _>(|i| p[i].re.clone()))
.wavefunction(kind, helicity)
.map(|wavefunction| wavefunction.into_components())
.map_err(|failure| match failure {
WavefunctionError::NonFinite => ExecutionError::nonfinite_result(failure),
WavefunctionError::InsufficientPrecision { reason, .. } => {
// Input components may have lower tracked precision after prior
// arithmetic. Preserve the batch's original working precision.
ExecutionError::insufficient_precision(
working_bits,
format!(
"external-state chart needs more than {working_bits} working bits: {reason}"
),
)
}
_ => error(failure),
})
.map_err(|failure| wavefunction_error(failure, working_bits))
}

/// Preserve the original attempt precision and typed numerical category for
/// both generic and constructive source-specific FeynKit external states.
pub(crate) fn wavefunction_error(failure: WavefunctionError, working_bits: u32) -> ExecutionError {
match failure {
WavefunctionError::NonFinite => ExecutionError::nonfinite_result(failure),
WavefunctionError::InsufficientPrecision { reason, .. } => {
ExecutionError::insufficient_precision(
working_bits,
format!(
"external-state chart needs more than {working_bits} working bits: {reason}"
),
)
}
_ => error(failure),
}
}

fn evaluate<T: BatchCarrier + KinematicScalar>(
Expand Down
Loading
Loading