ModelComputeOptions configures which compute units (CPU, GPU, Neural Engine) are used for each component of the WhisperKit transcription pipeline.
Overview
WhisperKit models consist of multiple components that can run on different compute units.ModelComputeOptions allows fine-grained control over where each component executes for optimal performance.
Properties
Compute units for mel spectrogram generation.
Compute units for audio encoding. Defaults to Neural Engine on newer OS versions for better performance.
Compute units for text decoding.
Compute units for KV cache prefill operations.
Initialization
Parameters
Compute units for mel spectrogram extraction.
Compute units for audio encoding. When
nil, automatically selects .cpuAndNeuralEngine on iOS 17+/macOS 14+ and .cpuAndGPU on older versions.Compute units for text decoding.
Compute units for prefill operations.
MLComputeUnits Values
Apple’sMLComputeUnits enum specifies which processors can execute a Core ML model:
.cpuOnly- Only the CPU.cpuAndGPU- CPU and GPU.cpuAndNeuralEngine- CPU and Neural Engine (recommended for most models).all- All available compute units
Usage Examples
Default Configuration
Custom Configuration
Force CPU-Only Execution
Simulator Handling
When running on the iOS Simulator, all compute options are automatically overridden to.cpuOnly since the simulator doesn’t support GPU or Neural Engine execution.
Performance Considerations
Neural Engine
The Neural Engine provides the best performance for most Whisper models on Apple Silicon devices:- Recommended for
audioEncoderComputeandtextDecoderCompute - Requires iOS 17+/macOS 14+ for optimal audio encoder performance
- Most efficient for battery-powered devices
GPU
The GPU can be beneficial for certain operations:- Recommended for
melComputeon most devices - May provide better throughput on some Mac models
- Consider for batch processing scenarios
CPU Only
CPU-only execution:- Required for
prefillComputeoperations - Use when Neural Engine/GPU are unavailable
- May be necessary for debugging or compatibility