Skip to main content

ActivationObserver

Trait ActivationObserver 

Source
pub trait ActivationObserver<T, E> {
    // Required method
    fn observe(&mut self, path: &str, value: &T) -> Result<(), E>;

    // Provided methods
    fn routing_control(
        &mut self,
        _path: &str,
        _token_rows: u64,
    ) -> Result<Option<GroupSelectionControl>, E> { ... }
    fn routing_applied(
        &mut self,
        _path: &str,
        _original: Option<RoutingDecision<'_, T>>,
        _effective: RoutingDecision<'_, T>,
    ) -> Result<(), E> { ... }
    fn routing_failed(&mut self, _path: &str, _message: &str) { ... }
    fn finish(&mut self) -> Result<(), E> { ... }
    fn intervene(&mut self, _path: &str, _value: &T) -> Result<Option<T>, E> { ... }
    fn observe_routing(
        &mut self,
        _routing: RoutingObservation<'_, T>,
    ) -> Result<(), E> { ... }
}
Expand description

Statically dispatched activation observation and intervention contract.

Required Methods§

Source

fn observe(&mut self, path: &str, value: &T) -> Result<(), E>

Observes a named backend-native tensor.

Provided Methods§

Source

fn routing_control( &mut self, _path: &str, _token_rows: u64, ) -> Result<Option<GroupSelectionControl>, E>

Obtains a validated control before the selector dispatches any experts. The default ordinary path allocates and materializes nothing.

Source

fn routing_applied( &mut self, _path: &str, _original: Option<RoutingDecision<'_, T>>, _effective: RoutingDecision<'_, T>, ) -> Result<(), E>

Receives original/effective decisions before they reach the expert provider.

Source

fn routing_failed(&mut self, _path: &str, _message: &str)

Records a failed control under the enclosing forward pass’s failure owner.

Source

fn finish(&mut self) -> Result<(), E>

Completes an ordinary forward pass under its existing failure owner. Scheduled-but-missing interventions must fail before prediction commitment.

Source

fn intervene(&mut self, _path: &str, _value: &T) -> Result<Option<T>, E>

Optionally replaces an activation before it is consumed or returned.

Source

fn observe_routing( &mut self, _routing: RoutingObservation<'_, T>, ) -> Result<(), E>

Observes normalized routed-expert decisions and contributions.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<B, E, F> ActivationObserver<<B as CaptureBackend>::Tensor, E> for CaptureObserver<'_, B, F>

Source§

impl<T, E, F> ActivationObserver<T, E> for F
where F: FnMut(&str, &T) -> Result<(), E>,

Source§

impl<T, E> ActivationObserver<T, E> for NoopObserver