@@ -101,7 +101,7 @@ def get_keys(self):
101101_BaseEngine = engine_api .Engine if (not is_decoupled () and hasattr (engine_api , "Engine" )) else object
102102
103103
104- class MaxEngine (_BaseEngine ):
104+ class MaxEngine (_BaseEngine ): # pyrefly: ignore[invalid-inheritance]
105105 """The computational core of the generative model server.
106106
107107 Engine defines an API that models must adhere to as they plug into the
@@ -192,7 +192,7 @@ def _nnx_init_cache_dict(self, mode: str = MODEL_MODE_PREFILL) -> dict:
192192 """Zero-filled pure-dict cache matching the abstract NNX model."""
193193 src = self ._abstract_model_for_mode (mode )
194194 _ , cache_state , _ = nnx .split (src , nnx .Cache , ...)
195- cache_dict = cache_state .to_pure_dict ()
195+ cache_dict = cache_state .to_pure_dict () # pyrefly: ignore[missing-attribute]
196196 return jax .tree .map (lambda x : jnp .zeros (x .shape , x .dtype ), cache_dict )
197197
198198 def _nnx_run_model (
@@ -219,7 +219,7 @@ def _nnx_run_model(
219219 nnx .replace_by_pure_dict (cache_state , cache_dict )
220220 # copy=True avoids reusing Variable objects across traces (TraceContextError),
221221 # mirroring the workaround in train.py's diff_wrapper.
222- model = nnx .merge (self .graphdef , params , cache_state , self ._nnx_rest_state , copy = True )
222+ model = nnx .merge (self .graphdef , params , cache_state , self ._nnx_rest_state , copy = True ) # pyrefly: ignore[no-matching-overload]
223223 logits = model (
224224 decoder_input_tokens ,
225225 decoder_positions ,
@@ -280,7 +280,7 @@ def _layout(x, s, l):
280280 if x .format == l :
281281 return x
282282 # Somehow this can be None sometimes.
283- dll = (l .layout if jax .__version_info__ >= (0 , 6 , 3 ) else l .device_local_layout ) if isinstance (l , Format ) else l
283+ dll = (l .layout if jax .__version_info__ >= (0 , 6 , 3 ) else l .device_local_layout ) if isinstance (l , Format ) else l # pyrefly: ignore[missing-attribute]
284284 f = jax .jit (self ._identity , out_shardings = Format (dll , s )).lower (x ).compile (compiler_options = xla_flags )
285285 y = f (x )
286286 # Achieves donation of the input argument, but allows for different memory
@@ -409,7 +409,7 @@ def _load_params_nnx(self, params, rng):
409409 with nn_partitioning .axis_rules (self .config .logical_axis_rules ):
410410 full_sharding = sharding .nnx_construct_named_sharding (full_abs , self ._mesh )
411411 concrete_model = maxtext_utils_nnx .create_nnx_sharded_model (
412- self .model , self ._create_model_fn , mesh = self ._mesh , named_sharding = full_sharding
412+ self .model , self ._create_model_fn , mesh = self ._mesh , named_sharding = full_sharding # pyrefly: ignore[bad-argument-type]
413413 )
414414 graphdef , _ , _ , rest_state = nnx .split (concrete_model , nnx .Param , nnx .Cache , ...)
415415 self .graphdef = graphdef
@@ -435,16 +435,16 @@ def _load_params_nnx(self, params, rng):
435435 # PREFILL/AR attention ops have different cache variable shapes, and a
436436 # mismatch trips the `assert prefill_kv_cache` check inside attention_op.
437437 with nn_partitioning .axis_rules (self .config .logical_axis_rules ):
438- concrete_model = self ._create_model_fn ()
438+ concrete_model = self ._create_model_fn () # pyrefly: ignore[not-callable]
439439 graphdef , _ , _ , rest_state = nnx .split (concrete_model , nnx .Param , nnx .Cache , ...)
440440 # Overlay loaded non-Param/non-Cache leaves (e.g. AQT qrhs.frozen) onto
441441 # the PREFILL-mode rest_state. The PREFILL concrete_model already has
442442 # placeholder qrhs vars at the right paths; we just swap in the loaded
443443 # values. Anything only in `loaded_rest_state` (e.g. AR-only RNG slots)
444444 # is ignored. We keep PREFILL rest_state as the base so RNG variables
445445 # match the PREFILL graphdef's expectations.
446- loaded_rest_dict = loaded_rest_state .to_pure_dict ()
447- rest_dict = rest_state .to_pure_dict ()
446+ loaded_rest_dict = loaded_rest_state .to_pure_dict () # pyrefly: ignore[missing-attribute]
447+ rest_dict = rest_state .to_pure_dict () # pyrefly: ignore[missing-attribute]
448448
449449 def _overlay (dst , src ):
450450 if isinstance (dst , dict ) and isinstance (src , dict ):
@@ -768,7 +768,7 @@ def _prefill_jit(
768768 one_d_output = ones_to_keep * DECODING_ACTIVE_SEQUENCE_INDICATOR
769769 sequence_indicator = jnp .expand_dims (one_d_output , 0 )
770770
771- rng , new_rng = jax .random .split (rng )
771+ rng , new_rng = jax .random .split (rng ) # pyrefly: ignore[bad-argument-type]
772772 if self .config .pure_nnx :
773773 # Prefill always operates on batch=1 (one padded prompt at a time).
774774 nnx_cache = (
@@ -1026,7 +1026,7 @@ def _prefill_multisampling_jit(
10261026 one_d_output = ones_to_keep * DECODING_ACTIVE_SEQUENCE_INDICATOR
10271027 sequence_indicator = jnp .expand_dims (one_d_output , 0 )
10281028
1029- rng , new_rng = jax .random .split (rng )
1029+ rng , new_rng = jax .random .split (rng ) # pyrefly: ignore[bad-argument-type]
10301030 if self .config .pure_nnx :
10311031 # Prefill is batch=1 (one prompt); multi-sampling only draws several first
10321032 # tokens from the shared logits below. Mirror the _prefill_jit NNX branch.
0 commit comments