mlx-cluster 0.0.5__cp312-cp312-macosx_14_0_universal2.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ import mlx.core as mx
2
+
3
+ from ._ext import random_walk
4
+ from ._ext import rejection_sampling
Binary file
Binary file
Binary file
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: mlx_cluster
3
+ Version: 0.0.5
4
+ Summary: C++ extension for generating random graphs
5
+ Author-email: Vinay Pandya <vinayharshadpandya27@gmail.com>
6
+ Project-URL: Homepage, https://github.com/vinayhpandya/mlx_cluster
7
+ Project-URL: Issues, https://github.com/vinayhpandya/mlx_cluster/Issues
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: C++
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: MacOS
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Provides-Extra: dev
17
+ Provides-Extra: test
18
+ Requires-Dist: mlx-graphs>=0.0.8; extra == "test"
19
+ Requires-Dist: torch>=2.2.0; extra == "test"
20
+ Requires-Dist: mlx>=0.26.0; extra == "test"
21
+ Requires-Dist: pytest==7.4.4; extra == "test"
22
+ Requires-Dist: scipy>=1.13.0; extra == "test"
23
+ Requires-Dist: requests==2.31.0; extra == "test"
24
+ Requires-Dist: fsspec[http]==2024.2.0; extra == "test"
25
+ Requires-Dist: tqdm==4.66.1; extra == "test"
26
+ Dynamic: license-file
27
+ Dynamic: requires-python
28
+
29
+ # mlx_cluster
30
+
31
+ A C++ extension for generating random walks for Homogeneous graphs using mlx
32
+
33
+ ## Installation
34
+
35
+ To install the necessary dependencies:
36
+
37
+ Clone the repositories:
38
+ ```bash
39
+ git clone https://github.com/vinayhpandya/mlx_cluster.git
40
+ ```
41
+
42
+ After cloning the repository install library using
43
+
44
+ ```bash
45
+ python setup.py build_ext -j8 --inplace
46
+ ```
47
+
48
+ You can also just install the library via pip
49
+
50
+ ```bash
51
+ pip install mlx_cluster
52
+ ```
53
+
54
+ for testing purposes you need to have `mlx-graphs` and `torch_geometric` installed
55
+
56
+ ## Usage
57
+
58
+
59
+ ```
60
+ # Can also use mlx for generating starting indices
61
+ import torch
62
+ from torch.utils.data import DataLoader
63
+
64
+ loader = DataLoader(range(2708), batch_size=2000)
65
+ start_indices = next(iter(loader))
66
+
67
+
68
+ from mlx_graphs.datasets import PlanetoidDataset
69
+ from mlx_graphs.utils.sorting import sort_edge_index
70
+ from torch.utils.data import DataLoader
71
+ from mlx_cluster import random_walk
72
+
73
+ cora_dataset = PlanetoidDataset(name="cora", base_dir="~")
74
+ # For some reason int_64t and int_32t are not compatible
75
+ edge_index = cora_dataset.graphs[0].edge_index.astype(mx.int64)
76
+
77
+ # Convert edge index into a CSR matrix
78
+ sorted_edge_index = sort_edge_index(edge_index=edge_index)
79
+ row_mlx = sorted_edge_index[0][0]
80
+ col_mlx = sorted_edge_index[0][1]
81
+ _, counts_mlx = np.unique(np.array(row_mlx, copy=False), return_counts=True)
82
+ cum_sum_mlx = counts_mlx.cumsum()
83
+ row_ptr_mlx = mx.concatenate([mx.array([0]), mx.array(cum_sum_mlx)])
84
+ start_indices = mx.array(start_indices.numpy())
85
+
86
+ rand_data = mx.random.uniform(shape=[start_indices.shape[0], 5])
87
+
88
+ node_sequence = random_walk(
89
+ row_ptr_mlx, col_mlx, start_indices, rand_data, 5, stream=mx.cpu
90
+ )
91
+ ```
92
+
93
+ ## TODO
94
+
95
+ - [x] Add metal shaders to optimize the code
96
+ - [ ] Benchmark random walk against different frameworks
97
+ - [ ] Add more algorithms
98
+
99
+ ## Credits:
100
+
101
+ torch_cluster random walk implementation : [random_walk](https://github.com/rusty1s/pytorch_cluster/blob/master/csrc/cpu/rw_cpu.cpp)
@@ -0,0 +1,9 @@
1
+ mlx_cluster/__init__.py,sha256=PNgjmiw5F4DRhwCXwtJH5B22C-eB6dVD8Nqctj_3kaY,90
2
+ mlx_cluster/_ext.cpython-312-darwin.so,sha256=yGeRNJxpPD4fyh0ruKLX8x-vY-mPwUWhYeuW4AEla3o,132168
3
+ mlx_cluster/libmlx_cluster.dylib,sha256=jB1nGg6gKmOliPa6vt2_yjV05gAMxlendzkPJlYlcoY,68760
4
+ mlx_cluster/mlx_cluster.metallib,sha256=LdYPYY3iNcwYXpRY-yX_ANOMbDPx04iMx4QJaCFTanA,5416
5
+ mlx_cluster-0.0.5.dist-info/licenses/LICENSE,sha256=7ixsoVuroKzGl84-ZV90CDH6bQrQF2UXvgnTqtW4Zb4,1069
6
+ mlx_cluster-0.0.5.dist-info/METADATA,sha256=yGDaLgX9s97pJo8A8azxQo9RObR2-BVH17PromIadLg,3018
7
+ mlx_cluster-0.0.5.dist-info/WHEEL,sha256=YkHrUi3IRQEf_VfQuUNQu54AKI6RL0ESio4qNLEH7Hg,114
8
+ mlx_cluster-0.0.5.dist-info/top_level.txt,sha256=sERi0kZuQnKmsHnqOkAda1kkBXdQAwV25Y9L-ATj110,12
9
+ mlx_cluster-0.0.5.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-cp312-macosx_14_0_universal2
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 vinayhpandya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ mlx_cluster