mirror of
https://github.com/ollama/ollama.git
synced 2026-07-23 09:10:53 -05:00
* Update MLX and MLX-C * Run MLX CGO work on a locked OS thread MLX now relies on OS-thread-local execution state for streams, encoders, and caches. Add an mlxthread executor backed by runtime.LockOSThread and route runner initialization, model load, inference, status memory reads, and cleanup through the worker so Go goroutine migration cannot split MLX state across native threads. Also stop caching default MLX streams before the runner owns the thread and add worker/threaded MLX regression tests. * mlx: use common status writer * mlx: bundle missing libjaccl on arm64 Inspired by #15793 * review comments
75 lines
1.2 KiB
C
75 lines
1.2 KiB
C
/* Copyright © 2023-2024 Apple Inc. */
|
|
|
|
#ifndef MLX_DISTRIBUTED_GROUP_H
|
|
#define MLX_DISTRIBUTED_GROUP_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "mlx/c/stream.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* \defgroup mlx_distributed_group MLX distributed
|
|
*/
|
|
/**@{*/
|
|
|
|
/**
|
|
* A MLX distributed group object.
|
|
*/
|
|
typedef struct mlx_distributed_group_ {
|
|
void* ctx;
|
|
} mlx_distributed_group;
|
|
|
|
/**
|
|
* Create an empty group.
|
|
*/
|
|
mlx_distributed_group mlx_distributed_group_new(void);
|
|
|
|
/**
|
|
* Free the group.
|
|
*/
|
|
int mlx_distributed_group_free(mlx_distributed_group group);
|
|
|
|
/**
|
|
* Initialize distributed.
|
|
*/
|
|
int mlx_distributed_init(
|
|
mlx_distributed_group* res,
|
|
bool strict,
|
|
const char* bk /* may be null */);
|
|
|
|
/**
|
|
* Get the rank.
|
|
*/
|
|
int mlx_distributed_group_rank(mlx_distributed_group group);
|
|
|
|
/**
|
|
* Get the group size.
|
|
*/
|
|
int mlx_distributed_group_size(mlx_distributed_group group);
|
|
|
|
/**
|
|
* Split the group.
|
|
*/
|
|
int mlx_distributed_group_split(
|
|
mlx_distributed_group* res,
|
|
mlx_distributed_group group,
|
|
int color,
|
|
int key);
|
|
|
|
/**
|
|
* Check if distributed is available.
|
|
*/
|
|
bool mlx_distributed_is_available(const char* bk /* may be null */);
|
|
|
|
/**@}*/
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|