(self, model_config: MLXModelConfig, cache_manager)
| 302 | """MLX-based inference pipeline that mirrors PyTorch pipeline interface""" |
| 303 | |
| 304 | def __init__(self, model_config: MLXModelConfig, cache_manager): |
| 305 | self.model_config = model_config |
| 306 | self.cache_manager = cache_manager |
| 307 | self.last_used = time.time() |
| 308 | |
| 309 | if not MLX_AVAILABLE: |
| 310 | raise RuntimeError("MLX framework not available. Install with: pip install mlx-lm") |
| 311 | |
| 312 | if not is_apple_silicon(): |
| 313 | raise RuntimeError("MLX framework is only supported on Apple Silicon") |
| 314 | |
| 315 | try: |
| 316 | logger.info(f"Loading MLX model: {model_config.model_id}") |
| 317 | self.model, self.tokenizer = self._load_mlx_model(model_config.model_id) |
| 318 | logger.info("MLX model loaded successfully") |
| 319 | except Exception as e: |
| 320 | logger.error(f"Failed to load MLX model: {str(e)}") |
| 321 | raise |
| 322 | |
| 323 | def _load_mlx_model(self, model_id: str): |
| 324 | """Load MLX model and tokenizer with caching""" |
nothing calls this directly
no test coverage detected