Skip to content

Move memory related API from GPU into Memory namespace.#296

Merged
davidkoski merged 3 commits intomainfrom
memory
Nov 18, 2025
Merged

Move memory related API from GPU into Memory namespace.#296
davidkoski merged 3 commits intomainfrom
memory

Conversation

@davidkoski
Copy link
Collaborator

  • work for linux related tasks #294
  • the underlying mlx API has moved from being GPU related to being Memory related
  • old API remains with deprecation

@incertum

@davidkoski davidkoski requested a review from awni November 5, 2025 22:44
/// ### See Also
/// - <doc:running-on-ios>
/// - ``Memory``
public enum GPU {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the old GPU.swift file cut down:

  • the methods and properties that are now in Memory are deprecated and cover the implementations in Memory
  • the GPU (metal) specific code remains

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this!

mlx_set_cache_limit(&current, cacheLimit)
/// ### See Also
/// - ``memoryLimit``
public static var cacheLimit: Int {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: previously you would read from this property and write via set(cacheLimit:) but that isn't quire idiomatic swift. Using the property for both get/set is.

///
/// See [the documentation](https://ml-explore.github.io/mlx/build/html/dev/metal_debugger.html)
/// for more information.
public static func startCapture(url: URL) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the GPU parts.

Copy link
Contributor

@incertum incertum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM wrt new split and approach. @awni will be better positioned to double check the changes and approve the PR.

I'll rebase my other PR once this is merged, thanks a bunch @davidkoski!

/// ### See Also
/// - <doc:running-on-ios>
/// - ``Memory``
public enum GPU {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this!

/// Control the size of cache memory via ``Memory/cacheLimit``
/// and the overall memory limit with ``Memory/memoryLimit``.
///
/// This might be used to eamine memory use over a run or sample it during a run:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eamine -> examine

Copy link
Member

@awni awni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

- work for #294
- the underlying mlx API has moved from being GPU related to being Memory related
- old API remains with deprecation
@davidkoski davidkoski merged commit 024b92e into main Nov 18, 2025
1 of 2 checks passed
@davidkoski davidkoski deleted the memory branch November 18, 2025 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants