QuantumReasoningConfig

Struct QuantumReasoningConfig 

Source
pub struct QuantumReasoningConfig {
    pub logical_reasoning: bool,
    pub causal_reasoning: bool,
    pub analogical_reasoning: bool,
    pub reasoning_steps: usize,
    pub circuit_depth: usize,
    pub entanglement_strength: f64,
}
Expand description

Quantum reasoning configuration

Fields§

§logical_reasoning: bool

Enable quantum logical reasoning

§causal_reasoning: bool

Enable quantum causal reasoning

§analogical_reasoning: bool

Enable quantum analogical reasoning

§reasoning_steps: usize

Number of reasoning steps

§circuit_depth: usize

Reasoning circuit depth

§entanglement_strength: f64

Quantum entanglement strength for reasoning

Implementations§

Source§

impl QuantumReasoningConfig

Source

pub fn default() -> Self

Default reasoning configuration

Examples found in repository?
examples/quantum_llm.rs (line 218)
214fn quantum_reasoning_demo() -> Result<()> {
215    println!("   Testing quantum reasoning modules...");
216
217    let reasoning_configs = vec![
218        ("Basic Logical", QuantumReasoningConfig::default()),
219        ("Enhanced Causal", QuantumReasoningConfig::enhanced()),
220        ("Advanced Analogical", QuantumReasoningConfig::advanced()),
221    ];
222
223    for (name, config) in reasoning_configs {
224        println!("\n   --- {name} Reasoning ---");
225
226        let mut reasoning_module = QuantumReasoningModule::new(config.clone())?;
227
228        println!("   Reasoning capabilities:");
229        println!("   - Logical reasoning: {}", config.logical_reasoning);
230        println!("   - Causal reasoning: {}", config.causal_reasoning);
231        println!("   - Analogical reasoning: {}", config.analogical_reasoning);
232        println!("   - Reasoning steps: {}", config.reasoning_steps);
233        println!("   - Circuit depth: {}", config.circuit_depth);
234        println!(
235            "   - Entanglement strength: {:.2}",
236            config.entanglement_strength
237        );
238
239        // Test reasoning on sample hidden states
240        let hidden_states = Array3::from_shape_fn((2, 8, 256), |(b, s, d)| {
241            // Create patterns that require reasoning
242            let logical_pattern = if s % 2 == 0 { 0.8 } else { 0.2 };
243            let causal_pattern = s as f64 * 0.1;
244            let base_value = logical_pattern + causal_pattern;
245
246            0.05f64.mul_add((d as f64).mul_add(0.001, b as f64), base_value)
247        });
248
249        println!("   Input hidden states shape: {:?}", hidden_states.dim());
250
251        // Apply quantum reasoning
252        let reasoned_output = reasoning_module.apply_reasoning(&hidden_states)?;
253        println!("   Reasoned output shape: {:?}", reasoned_output.dim());
254
255        // Analyze reasoning effects
256        let reasoning_enhancement =
257            analyze_reasoning_enhancement(&hidden_states, &reasoned_output)?;
258        println!("   Reasoning enhancement metrics:");
259        println!(
260            "   - Pattern amplification: {:.3}",
261            reasoning_enhancement.pattern_amplification
262        );
263        println!(
264            "   - Logical consistency: {:.3}",
265            reasoning_enhancement.logical_consistency
266        );
267        println!(
268            "   - Causal coherence: {:.3}",
269            reasoning_enhancement.causal_coherence
270        );
271
272        // Test quantum coherence during reasoning
273        let coherence = reasoning_module.measure_coherence()?;
274        println!("   Quantum coherence: {coherence:.3}");
275
276        // Test token selection enhancement
277        let sample_logits = Array1::from_shape_fn(1000, |i| {
278            0.01f64.mul_add((i as f64 * 0.1).sin(), 0.001 * fastrand::f64())
279        });
280
281        let enhanced_logits = reasoning_module.enhance_token_selection(&sample_logits)?;
282        let enhancement_effect = (&enhanced_logits - &sample_logits)
283            .mapv(f64::abs)
284            .mean()
285            .unwrap_or(0.0);
286        println!("   Token selection enhancement: {enhancement_effect:.4}");
287    }
288
289    Ok(())
290}
Source

pub fn enhanced() -> Self

Enhanced reasoning configuration

Examples found in repository?
examples/quantum_llm.rs (line 219)
214fn quantum_reasoning_demo() -> Result<()> {
215    println!("   Testing quantum reasoning modules...");
216
217    let reasoning_configs = vec![
218        ("Basic Logical", QuantumReasoningConfig::default()),
219        ("Enhanced Causal", QuantumReasoningConfig::enhanced()),
220        ("Advanced Analogical", QuantumReasoningConfig::advanced()),
221    ];
222
223    for (name, config) in reasoning_configs {
224        println!("\n   --- {name} Reasoning ---");
225
226        let mut reasoning_module = QuantumReasoningModule::new(config.clone())?;
227
228        println!("   Reasoning capabilities:");
229        println!("   - Logical reasoning: {}", config.logical_reasoning);
230        println!("   - Causal reasoning: {}", config.causal_reasoning);
231        println!("   - Analogical reasoning: {}", config.analogical_reasoning);
232        println!("   - Reasoning steps: {}", config.reasoning_steps);
233        println!("   - Circuit depth: {}", config.circuit_depth);
234        println!(
235            "   - Entanglement strength: {:.2}",
236            config.entanglement_strength
237        );
238
239        // Test reasoning on sample hidden states
240        let hidden_states = Array3::from_shape_fn((2, 8, 256), |(b, s, d)| {
241            // Create patterns that require reasoning
242            let logical_pattern = if s % 2 == 0 { 0.8 } else { 0.2 };
243            let causal_pattern = s as f64 * 0.1;
244            let base_value = logical_pattern + causal_pattern;
245
246            0.05f64.mul_add((d as f64).mul_add(0.001, b as f64), base_value)
247        });
248
249        println!("   Input hidden states shape: {:?}", hidden_states.dim());
250
251        // Apply quantum reasoning
252        let reasoned_output = reasoning_module.apply_reasoning(&hidden_states)?;
253        println!("   Reasoned output shape: {:?}", reasoned_output.dim());
254
255        // Analyze reasoning effects
256        let reasoning_enhancement =
257            analyze_reasoning_enhancement(&hidden_states, &reasoned_output)?;
258        println!("   Reasoning enhancement metrics:");
259        println!(
260            "   - Pattern amplification: {:.3}",
261            reasoning_enhancement.pattern_amplification
262        );
263        println!(
264            "   - Logical consistency: {:.3}",
265            reasoning_enhancement.logical_consistency
266        );
267        println!(
268            "   - Causal coherence: {:.3}",
269            reasoning_enhancement.causal_coherence
270        );
271
272        // Test quantum coherence during reasoning
273        let coherence = reasoning_module.measure_coherence()?;
274        println!("   Quantum coherence: {coherence:.3}");
275
276        // Test token selection enhancement
277        let sample_logits = Array1::from_shape_fn(1000, |i| {
278            0.01f64.mul_add((i as f64 * 0.1).sin(), 0.001 * fastrand::f64())
279        });
280
281        let enhanced_logits = reasoning_module.enhance_token_selection(&sample_logits)?;
282        let enhancement_effect = (&enhanced_logits - &sample_logits)
283            .mapv(f64::abs)
284            .mean()
285            .unwrap_or(0.0);
286        println!("   Token selection enhancement: {enhancement_effect:.4}");
287    }
288
289    Ok(())
290}
Source

pub fn advanced() -> Self

Advanced reasoning configuration

Examples found in repository?
examples/quantum_llm.rs (line 220)
214fn quantum_reasoning_demo() -> Result<()> {
215    println!("   Testing quantum reasoning modules...");
216
217    let reasoning_configs = vec![
218        ("Basic Logical", QuantumReasoningConfig::default()),
219        ("Enhanced Causal", QuantumReasoningConfig::enhanced()),
220        ("Advanced Analogical", QuantumReasoningConfig::advanced()),
221    ];
222
223    for (name, config) in reasoning_configs {
224        println!("\n   --- {name} Reasoning ---");
225
226        let mut reasoning_module = QuantumReasoningModule::new(config.clone())?;
227
228        println!("   Reasoning capabilities:");
229        println!("   - Logical reasoning: {}", config.logical_reasoning);
230        println!("   - Causal reasoning: {}", config.causal_reasoning);
231        println!("   - Analogical reasoning: {}", config.analogical_reasoning);
232        println!("   - Reasoning steps: {}", config.reasoning_steps);
233        println!("   - Circuit depth: {}", config.circuit_depth);
234        println!(
235            "   - Entanglement strength: {:.2}",
236            config.entanglement_strength
237        );
238
239        // Test reasoning on sample hidden states
240        let hidden_states = Array3::from_shape_fn((2, 8, 256), |(b, s, d)| {
241            // Create patterns that require reasoning
242            let logical_pattern = if s % 2 == 0 { 0.8 } else { 0.2 };
243            let causal_pattern = s as f64 * 0.1;
244            let base_value = logical_pattern + causal_pattern;
245
246            0.05f64.mul_add((d as f64).mul_add(0.001, b as f64), base_value)
247        });
248
249        println!("   Input hidden states shape: {:?}", hidden_states.dim());
250
251        // Apply quantum reasoning
252        let reasoned_output = reasoning_module.apply_reasoning(&hidden_states)?;
253        println!("   Reasoned output shape: {:?}", reasoned_output.dim());
254
255        // Analyze reasoning effects
256        let reasoning_enhancement =
257            analyze_reasoning_enhancement(&hidden_states, &reasoned_output)?;
258        println!("   Reasoning enhancement metrics:");
259        println!(
260            "   - Pattern amplification: {:.3}",
261            reasoning_enhancement.pattern_amplification
262        );
263        println!(
264            "   - Logical consistency: {:.3}",
265            reasoning_enhancement.logical_consistency
266        );
267        println!(
268            "   - Causal coherence: {:.3}",
269            reasoning_enhancement.causal_coherence
270        );
271
272        // Test quantum coherence during reasoning
273        let coherence = reasoning_module.measure_coherence()?;
274        println!("   Quantum coherence: {coherence:.3}");
275
276        // Test token selection enhancement
277        let sample_logits = Array1::from_shape_fn(1000, |i| {
278            0.01f64.mul_add((i as f64 * 0.1).sin(), 0.001 * fastrand::f64())
279        });
280
281        let enhanced_logits = reasoning_module.enhance_token_selection(&sample_logits)?;
282        let enhancement_effect = (&enhanced_logits - &sample_logits)
283            .mapv(f64::abs)
284            .mean()
285            .unwrap_or(0.0);
286        println!("   Token selection enhancement: {enhancement_effect:.4}");
287    }
288
289    Ok(())
290}

Trait Implementations§

Source§

impl Clone for QuantumReasoningConfig

Source§

fn clone(&self) -> QuantumReasoningConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QuantumReasoningConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V