Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 20 additions & 31 deletions MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

## Adding a New Package

Here is adding `MLXFFT`:
Here is adding `MLXOptimizers`:

1. `Package.swift` add a new product (for anything that should be exported) and target:

```
products: [
...
.library(name: "MLXFFT", targets: ["MLXFFT"]),
.library(name: "MLXOptimizers", targets: ["MLXOptimizers"]),
```

```
targets: [
...
.target(
name: "MLXFFT",
name: "MLXOptimizers",
dependencies: ["MLX"]
),
```
Expand All @@ -36,18 +36,17 @@ add to MLXTests:
```
.testTarget(
name: "MLXTests",
dependencies: ["MLX", "MLXRandom", "MLXNN", "MLXOptimizers", "MLXFFT"]
dependencies: ["MLX", "MLXNN", "MLXOptimizers"]
),
```


2. Update `CMakeLists`

```
# MLXFFT package
file(GLOB MLXFFT-src ${CMAKE_CURRENT_LIST_DIR}/Source/MLXFFT/*.swift)
add_library(MLXFFT STATIC ${MLXFFT-src})
target_link_libraries(MLXFFT PRIVATE MLX)
# MLXOptimizers package
file(GLOB MLXOptimizers-src ${CMAKE_CURRENT_LIST_DIR}/Source/MLXOptimizers/*.swift)
add_library(MLXOptimizers STATIC ${MLXOptimizers-src})
target_link_libraries(MLXOptimizers PRIVATE MLX)
```

3. Create directory in `Source`
Expand All @@ -56,18 +55,13 @@ target_link_libraries(MLXFFT PRIVATE MLX)

5. Add source files and documentation

6. Add linkage to the other documentation, e.g. in `MLXFFT.md`
6. Add linkage to the other documentation, e.g. in `MLXOptimizers.md`

```
## Other MLX Packages

- [MLX](mlx)
- [MLXRandom](mlxrandom)
- [MLXNN](mlxnn)
- [MLXOptimizers](mlxoptimizers)
- [MLXFFT](mlxfft)
- [MLXLinalg](mlxlinalg)
- [MLXFast](mlxfast)

- [Python `mlx`](https://ml-explore.github.io/mlx/build/html/index.html)
```
Expand All @@ -78,27 +72,23 @@ target_link_libraries(MLXFFT PRIVATE MLX)
## Other MLX Packages

...
- [MLXFFT](../mlxfft/)
- [MLXOptimizers](../mlxoptimizers/)
```

8. Update README.md

```
dependencies: [.product(name: "MLX", package: "mlx-swift"),
.product(name: "MLXRandom", package: "mlx-swift"),
.product(name: "MLXNN", package: "mlx-swift"),
.product(name: "MLXOptimizers", package: "mlx-swift"),
.product(name: "MLXFFT", package: "mlx-swift")]
.product(name: "MLXOptimizers", package: "mlx-swift")]
```

9. Update install.md

```
dependencies: [.product(name: "MLX", package: "mlx-swift"),
.product(name: "MLXRandom", package: "mlx-swift"),
.product(name: "MLXNN", package: "mlx-swift"),
.product(name: "MLXOptimizers", package: "mlx-swift"),
.product(name: "MLXFFT", package: "mlx-swift")]
.product(name: "MLXOptimizers", package: "mlx-swift")]
```

10. Update `tools/generate_integration_tests.py` as needed
Expand All @@ -113,7 +103,7 @@ import MLXNN
12. Update `tools/build-documentation.sh`

```
for x in MLX MLXRandom MLXNN MLXOptimizers MLXFFT; do
for x in MLX MLXNN MLXOptimizers; do
```

13. Add to `.spi.yml` for swift package index
Expand All @@ -129,25 +119,24 @@ pre-commit run --all-files
## Updating `mlx` and `mlx-c`

SwiftPM is able to fetch repositories from github and build them _if_ they have
a `Package.swift` at the top level. It is unable to do this for repositories
that do not have a `Package.swift`. For this reason `mlx-swift` uses
a `Package.swift` at the top level. It is unable to do this for repositories
that do not have a `Package.swift`. For this reason `mlx-swift` uses
git submodules to include the `mlx` and `mlx-c` repositories.

When a new version of `mlx` and its equivalent `mlx-c` are to be used, there is a
process to go through to update `mlx-swift`.

Additionally, SwiftPM supports plugins that can produce derived source for
building, but this can only produce new swift source. It is possible to use
building, but this can only produce new swift source. It is possible to use
plugins to generate new source `.cpp` files and even compile them, but at
best the `.o` is copied into the output as a resource, not linked.
This is important because `mlx` has some build-time source generation
(e.g. `make_compiled_preamble.sh`). This is handled in `mlx-swift` by
(e.g. `make_compiled_preamble.sh`). This is handled in `mlx-swift` by
pre-generating the source when updating the `mlx` version.

1. Update the `mlx` and `mlx-c` submodules via `git pull` or `git checkout ...`
- `Source/Cmlx/mlx`
- `Source/Cmlx/mlx-c`

- `Source/Cmlx/mlx`
- `Source/Cmlx/mlx-c`
2. Add any vendored dependencies as needed in `/vendor`

3. Regenerate any build-time source: `./tools/update-mlx.sh`
Expand Down
1 change: 0 additions & 1 deletion Source/MLX/Documentation.docc/MLX.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ are the CPU and GPU.

## Other MLX Packages

- [MLX](mlx)
- [MLXNN](mlxnn)
- [MLXOptimizers](mlxoptimizers)

Expand Down
5 changes: 0 additions & 5 deletions Source/MLXNN/Documentation.docc/MLXNN.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ See <doc:training>
## Other MLX Packages

- [MLX](mlx)
- [MLXRandom](mlxrandom)
- [MLXNN](mlxnn)
- [MLXOptimizers](mlxoptimizers)
- [MLXFFT](mlxfft)
- [MLXLinalg](mlxlinalg)
- [MLXFast](mlxfast)

- [Python `mlx`](https://ml-explore.github.io/mlx/build/html/index.html)

Expand Down
5 changes: 0 additions & 5 deletions Source/MLXOptimizers/Documentation.docc/MLXOptimizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ for _ in 0 ..< epochs {
## Other MLX Packages

- [MLX](mlx)
- [MLXRandom](mlxrandom)
- [MLXNN](mlxnn)
- [MLXOptimizers](mlxoptimizers)
- [MLXFFT](mlxfft)
- [MLXLinalg](mlxlinalg)
- [MLXFast](mlxfast)

- [Python `mlx`](https://ml-explore.github.io/mlx/build/html/index.html)

Expand Down