@@ -112,54 +112,6 @@ impl NemotronHCheckpointTemplate {
112112 }
113113}
114114
115- struct NeutralNemotronHObserver < ' a > {
116- inner : & ' a mut dyn eredu_runtime:: ActivationObserver < Array , Exception > ,
117- }
118-
119- impl eredu_runtime:: ActivationObserver < crate :: MlxTensor , eredu_nn:: Error >
120- for NeutralNemotronHObserver < ' _ >
121- {
122- fn observe ( & mut self , path : & str , value : & crate :: MlxTensor ) -> Result < ( ) , eredu_nn:: Error > {
123- self . inner
124- . observe ( path, value. as_array ( ) )
125- . map_err ( |error| eredu_nn:: Error :: backend ( error. to_string ( ) ) )
126- }
127-
128- fn intervene (
129- & mut self ,
130- path : & str ,
131- value : & crate :: MlxTensor ,
132- ) -> Result < Option < crate :: MlxTensor > , eredu_nn:: Error > {
133- self . inner
134- . intervene ( path, value. as_array ( ) )
135- . map ( |value| value. map ( crate :: MlxTensor :: from_array) )
136- . map_err ( |error| eredu_nn:: Error :: backend ( error. to_string ( ) ) )
137- }
138-
139- fn observe_routing (
140- & mut self ,
141- routing : eredu_runtime:: RoutingObservation < ' _ , crate :: MlxTensor > ,
142- ) -> Result < ( ) , eredu_nn:: Error > {
143- let routing = eredu_runtime:: RoutingObservation {
144- path : routing. path ,
145- selected_experts : routing. selected_experts . as_array ( ) ,
146- selected_scores : routing. selected_scores . as_array ( ) ,
147- route_weights : routing. route_weights . as_array ( ) ,
148- routed_output : routing. routed_output . as_array ( ) ,
149- local_routed_output : routing. local_routed_output . map ( crate :: MlxTensor :: as_array) ,
150- reduced_routed_output : routing
151- . reduced_routed_output
152- . map ( crate :: MlxTensor :: as_array) ,
153- shared_output : routing. shared_output . map ( crate :: MlxTensor :: as_array) ,
154- combined_output : routing. combined_output . map ( crate :: MlxTensor :: as_array) ,
155- expert_count : routing. expert_count ,
156- } ;
157- self . inner
158- . observe_routing ( routing)
159- . map_err ( |error| eredu_nn:: Error :: backend ( error. to_string ( ) ) )
160- }
161- }
162-
163115fn neutral_embedded_input < ' a > (
164116 input : eredu_architectures:: nemotron_h:: EmbeddedInput < ' a , Array > ,
165117) -> eredu_architectures:: nemotron_h:: EmbeddedInput < ' a , crate :: MlxTensor > {
@@ -1367,7 +1319,7 @@ impl NemotronHModel {
13671319 ) -> Result < Array , Error > {
13681320 let expert_cache = self . expert_cache . take ( ) ;
13691321 let result = {
1370- let mut observer = NeutralNemotronHObserver { inner : observer } ;
1322+ let mut observer = crate :: composition :: NeutralActivationObserver :: new ( observer) ;
13711323 match expert_cache. as_ref ( ) {
13721324 Some ( expert_cache) => {
13731325 let args = self . args . clone ( ) ;
@@ -1410,7 +1362,7 @@ impl NemotronHModel {
14101362 cache : & mut MlxHybridState ,
14111363 provider : & mut P ,
14121364 stream : & Stream ,
1413- observer : & mut NeutralNemotronHObserver < ' _ > ,
1365+ observer : & mut crate :: composition :: NeutralActivationObserver < ' _ > ,
14141366 ) -> Result < Array , Error >
14151367 where
14161368 P : eredu_runtime:: RoutedExpertProvider < MlxNeuralBackend > ,
0 commit comments