<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLComputePipelineDescriptor/optimizeForPersistentKernel",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(cs)MTLComputePipelineDescriptor(py)optimizeForPersistentKernel"
  },
  "title" : "optimizeForPersistentKernel"
}
-->

# optimizeForPersistentKernel

A Boolean value that indicates whether Metal tunes the pipeline for
persistent threads.

```
var optimizeForPersistentKernel: Bool { get set }
```

## Discussion

Set to `true` to tune the pipeline for long-lived kernels with
non-specific grid sizes, such as producer-consumer models. When `true`,
call the resulting [`MTLComputePipelineState`](/documentation/Metal/MTLComputePipelineState) instance’s
[`recommendedPersistentThreadgroupsPerGrid(forThreadsPerThreadgroup:)`](/documentation/Metal/MTLComputePipelineState/recommendedPersistentThreadgroupsPerGrid(forThreadsPerThreadgroup:))
method to get the optimal dispatch size.

This property can’t be `true` when [`forwardProgressUsage`](/documentation/Metal/MTLComputePipelineDescriptor/forwardProgressUsage) is
[`MTLForwardProgressUsage.weak`](/documentation/Metal/MTLForwardProgressUsage/weak) because
it’s an invalid configuration which may trigger unpredictable behavior
or an error.

The default value is `false`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)