https://github.com/mars-project/mars

Mars is a tensor-based unified framework for large-scale data computation which scales numpy, pandas, scikit-learn and Python functions.

https://github.com/mars-project/mars

Keywords

dask dataframe joblib lightgbm machine-learning numpy pandas python pytorch ray scikit-learn statsmodels tensor tensorflow xgboost

Keywords from Contributors

distributed parallel hyperparameter-optimization hyperparameter-search reinforcement-learning serving rllib llm-serving llm-inference large-language-models
Last synced: 9 months ago · JSON representation

Repository

Mars is a tensor-based unified framework for large-scale data computation which scales numpy, pandas, scikit-learn and Python functions.

Basic Info
Statistics
  • Stars: 2,731
  • Watchers: 91
  • Forks: 327
  • Open Issues: 215
  • Releases: 117
Topics
dask dataframe joblib lightgbm machine-learning numpy pandas python pytorch ray scikit-learn statsmodels tensor tensorflow xgboost
Created over 7 years ago · Last pushed over 2 years ago
Metadata Files
Readme Contributing License Code of conduct Codeowners Support

README.rst

.. image:: https://raw.githubusercontent.com/mars-project/mars/master/docs/source/images/mars-logo-title.png

|PyPI version| |Docs| |Build| |Coverage| |Quality| |License|

Mars is a tensor-based unified framework for large-scale data computation
which scales numpy, pandas, scikit-learn and many other libraries.

`Documentation`_, `中文文档`_

Installation
------------

Mars is easy to install by

.. code-block:: bash

    pip install pymars


Installation for Developers
```````````````````````````

When you want to contribute code to Mars, you can follow the instructions below to install Mars
for development:

.. code-block:: bash

    git clone https://github.com/mars-project/mars.git
    cd mars
    pip install -e ".[dev]"

More details about installing Mars can be found at
`installation `_ section in
Mars document.


Architecture Overview
---------------------

.. image:: https://raw.githubusercontent.com/mars-project/mars/master/docs/source/images/architecture.png


Getting Started
---------------

Starting a new runtime locally via:

.. code-block:: python

    >>> import mars
    >>> mars.new_session()

Or connecting to a Mars cluster which is already initialized.

.. code-block:: python

    >>> import mars
    >>> mars.new_session('http://:')


Mars Tensor
-----------

Mars tensor provides a familiar interface like Numpy.

+-----------------------------------------------+-----------------------------------------------+
| **Numpy**                                     | **Mars tensor**                               |
+-----------------------------------------------+-----------------------------------------------+
|.. code-block:: python                         |.. code-block:: python                         |
|                                               |                                               |
|    import numpy as np                         |    import mars.tensor as mt                   |
|    N = 200_000_000                            |    N = 200_000_000                            |
|    a = np.random.uniform(-1, 1, size=(N, 2))  |    a = mt.random.uniform(-1, 1, size=(N, 2))  |
|    print((np.linalg.norm(a, axis=1) < 1)      |    print(((mt.linalg.norm(a, axis=1) < 1)     |
|          .sum() * 4 / N)                      |            .sum() * 4 / N).execute())         |
|                                               |                                               |
+-----------------------------------------------+-----------------------------------------------+
|.. code-block::                                |.. code-block::                                |
|                                               |                                               |
|    3.14174502                                 |     3.14161908                                |
|    CPU times: user 11.6 s, sys: 8.22 s,       |     CPU times: user 966 ms, sys: 544 ms,      |
|               total: 19.9 s                   |                total: 1.51 s                  |
|    Wall time: 22.5 s                          |     Wall time: 3.77 s                         |
|                                               |                                               |
+-----------------------------------------------+-----------------------------------------------+

Mars can leverage multiple cores, even on a laptop, and could be even faster for a distributed setting.


Mars DataFrame
--------------

Mars DataFrame provides a familiar interface like pandas.

+-----------------------------------------+-----------------------------------------+
| **Pandas**                              | **Mars DataFrame**                      |
+-----------------------------------------+-----------------------------------------+
|.. code-block:: python                   |.. code-block:: python                   |
|                                         |                                         |
|    import numpy as np                   |    import mars.tensor as mt             |
|    import pandas as pd                  |    import mars.dataframe as md          |
|    df = pd.DataFrame(                   |    df = md.DataFrame(                   |
|        np.random.rand(100000000, 4),    |        mt.random.rand(100000000, 4),    |
|        columns=list('abcd'))            |        columns=list('abcd'))            |
|    print(df.sum())                      |    print(df.sum().execute())            |
|                                         |                                         |
+-----------------------------------------+-----------------------------------------+
|.. code-block::                          |.. code-block::                          |
|                                         |                                         |
|    CPU times: user 10.9 s, sys: 2.69 s, |    CPU times: user 1.21 s, sys: 212 ms, |
|               total: 13.6 s             |               total: 1.42 s             |
|    Wall time: 11 s                      |    Wall time: 2.75 s                    |
+-----------------------------------------+-----------------------------------------+


Mars Learn
----------

Mars learn provides a familiar interface like scikit-learn.

+---------------------------------------------+----------------------------------------------------+
| **Scikit-learn**                            | **Mars learn**                                     |
+---------------------------------------------+----------------------------------------------------+
|.. code-block:: python                       |.. code-block:: python                              |
|                                             |                                                    |
|    from sklearn.datasets import make_blobs  |    from mars.learn.datasets import make_blobs      |
|    from sklearn.decomposition import PCA    |    from mars.learn.decomposition import PCA        |
|    X, y = make_blobs(                       |    X, y = make_blobs(                              |
|        n_samples=100000000, n_features=3,   |        n_samples=100000000, n_features=3,          |
|        centers=[[3, 3, 3], [0, 0, 0],       |        centers=[[3, 3, 3], [0, 0, 0],              |
|                 [1, 1, 1], [2, 2, 2]],      |                  [1, 1, 1], [2, 2, 2]],            |
|        cluster_std=[0.2, 0.1, 0.2, 0.2],    |        cluster_std=[0.2, 0.1, 0.2, 0.2],           |
|        random_state=9)                      |        random_state=9)                             |
|    pca = PCA(n_components=3)                |    pca = PCA(n_components=3)                       |
|    pca.fit(X)                               |    pca.fit(X)                                      |
|    print(pca.explained_variance_ratio_)     |    print(pca.explained_variance_ratio_)            |
|    print(pca.explained_variance_)           |    print(pca.explained_variance_)                  |
|                                             |                                                    |
+---------------------------------------------+----------------------------------------------------+

Mars learn also integrates with many libraries:

- `TensorFlow `_
- `PyTorch `_
- `XGBoost `_
- `LightGBM `_
- `Joblib `_
- `Statsmodels `_

Mars remote
-----------

Mars remote allows users to execute functions in parallel.

+-------------------------------------------+--------------------------------------------+
| **Vanilla function calls**                | **Mars remote**                            |
+-------------------------------------------+--------------------------------------------+
|.. code-block:: python                     |.. code-block:: python                      |
|                                           |                                            |
|    import numpy as np                     |    import numpy as np                      |
|                                           |    import mars.remote as mr                |
|                                           |                                            |
|    def calc_chunk(n, i):                  |    def calc_chunk(n, i):                   |
|        rs = np.random.RandomState(i)      |        rs = np.random.RandomState(i)       |
|        a = rs.uniform(-1, 1, size=(n, 2)) |        a = rs.uniform(-1, 1, size=(n, 2))  |
|        d = np.linalg.norm(a, axis=1)      |        d = np.linalg.norm(a, axis=1)       |
|        return (d < 1).sum()               |        return (d < 1).sum()                |
|                                           |                                            |
|    def calc_pi(fs, N):                    |    def calc_pi(fs, N):                     |
|        return sum(fs) * 4 / N             |        return sum(fs) * 4 / N              |
|                                           |                                            |
|    N = 200_000_000                        |    N = 200_000_000                         |
|    n = 10_000_000                         |    n = 10_000_000                          |
|                                           |                                            |
|    fs = [calc_chunk(n, i)                 |    fs = [mr.spawn(calc_chunk, args=(n, i)) |
|          for i in range(N // n)]          |          for i in range(N // n)]           |
|    pi = calc_pi(fs, N)                    |    pi = mr.spawn(calc_pi, args=(fs, N))    |
|    print(pi)                              |    print(pi.execute().fetch())             |
|                                           |                                            |
+-------------------------------------------+--------------------------------------------+
|.. code-block::                            |.. code-block::                             |
|                                           |                                            |
|    3.1416312                              |    3.1416312                               |
|    CPU times: user 32.2 s, sys: 4.86 s,   |    CPU times: user 616 ms, sys: 307 ms,    |
|               total: 37.1 s               |               total: 923 ms                |
|    Wall time: 12.4 s                      |    Wall time: 3.99 s                       |
|                                           |                                            |
+-------------------------------------------+--------------------------------------------+

DASK on Mars
------------

Refer to `DASK on Mars`_ for more information.

Eager Mode
```````````

Mars supports eager mode which makes it friendly for developing and easy to debug.

Users can enable the eager mode by options, set options at the beginning of the program or console session.

.. code-block:: python

    >>> from mars.config import options
    >>> options.eager_mode = True

Or use a context.

.. code-block:: python

    >>> from mars.config import option_context
    >>> with option_context() as options:
    >>>     options.eager_mode = True
    >>>     # the eager mode is on only for the with statement
    >>>     ...

If eager mode is on, tensor, DataFrame etc will be executed immediately
by default session once it is created.

.. code-block:: python

    >>> import mars.tensor as mt
    >>> import mars.dataframe as md
    >>> from mars.config import options
    >>> options.eager_mode = True
    >>> t = mt.arange(6).reshape((2, 3))
    >>> t
    array([[0, 1, 2],
           [3, 4, 5]])
    >>> df = md.DataFrame(t)
    >>> df.sum()
    0    3
    1    5
    2    7
    dtype: int64


Mars on Ray
------------
Mars also has deep integration with Ray and can run on `Ray `_ efficiently and
interact with the large ecosystem of machine learning and distributed systems built on top of the core Ray.

Starting a new Mars on Ray runtime locally via:

.. code-block:: python

    import mars
    mars.new_session(backend='ray')
    # Perform computation

Interact with Ray Dataset:

.. code-block:: python

    import mars.tensor as mt
    import mars.dataframe as md
    df = md.DataFrame(
        mt.random.rand(1000_0000, 4),
        columns=list('abcd'))
    # Convert mars dataframe to ray dataset
    ds = md.to_ray_dataset(df)
    print(ds.schema(), ds.count())
    ds.filter(lambda row: row["a"] > 0.5).show(5)
    # Convert ray dataset to mars dataframe
    df2 = md.read_ray_dataset(ds)
    print(df2.head(5).execute())

Refer to `Mars on Ray`_ for more information.


Easy to scale in and scale out
------------------------------

Mars can scale in to a single machine, and scale out to a cluster with thousands of machines.
It's fairly simple to migrate from a single machine to a cluster to
process more data or gain a better performance.


Bare Metal Deployment
`````````````````````

Mars is easy to scale out to a cluster by starting different components of
mars distributed runtime on different machines in the cluster.

A node can be selected as supervisor which integrated a web service,
leaving other nodes as workers.  The supervisor can be started with the following command:

.. code-block:: bash

    mars-supervisor -h  -p  -w 

Workers can be started with the following command:

.. code-block:: bash

    mars-worker -h  -p  -s 

After all mars processes are started, users can run

.. code-block:: python

    >>> sess = new_session('http://:')
    >>> # perform computation


Kubernetes Deployment
`````````````````````

Refer to `Run on Kubernetes`_ for more information.


Yarn Deployment
```````````````

Refer to `Run on Yarn`_ for more information.


Getting involved
----------------

- Read `development guide `_.
- Join our Slack workgroup: `Slack `_.
- Join the mailing list: send an email to `mars-dev@googlegroups.com`_.
- Please report bugs by submitting a `GitHub issue`_.
- Submit contributions using `pull requests`_.

Thank you in advance for your contributions!


.. |Build| image:: https://github.com/mars-project/mars/workflows/Mars%20CI%20Core/badge.svg
   :target: https://github.com/mars-project/mars/actions
.. |Coverage| image:: https://codecov.io/gh/mars-project/mars/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/mars-project/mars
.. |Quality| image:: https://img.shields.io/codacy/grade/6a80bb4659ed410eb33795f580c8615e.svg
   :target: https://app.codacy.com/project/mars-project/mars/dashboard
.. |PyPI version| image:: https://img.shields.io/pypi/v/pymars.svg
   :target: https://pypi.python.org/pypi/pymars
.. |Docs| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg
   :target: `Documentation`_
.. |License| image:: https://img.shields.io/pypi/l/pymars.svg
   :target: https://github.com/mars-project/mars/blob/master/LICENSE
.. _`mars-dev@googlegroups.com`: https://groups.google.com/forum/#!forum/mars-dev
.. _`GitHub issue`: https://github.com/mars-project/mars/issues
.. _`pull requests`: https://github.com/mars-project/mars/pulls
.. _`Documentation`: https://mars-project.readthedocs.io
.. _`中文文档`: https://mars-project.readthedocs.io/zh_CN/latest/
.. _`Mars on Ray`: https://mars-project.readthedocs.io/en/latest/installation/ray.html
.. _`Run on Kubernetes`: https://mars-project.readthedocs.io/en/latest/installation/kubernetes.html
.. _`Run on Yarn`: https://mars-project.readthedocs.io/en/latest/installation/yarn.html
.. _`DASK on Mars`: https://mars-project.readthedocs.io/en/latest/user_guide/contrib/dask.html

Owner

  • Name: mars-project
  • Login: mars-project
  • Kind: organization

GitHub Events

Total
  • Watch event: 59
  • Issue comment event: 1
  • Fork event: 3
Last Year
  • Watch event: 59
  • Issue comment event: 1
  • Fork event: 3

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 1,296
  • Total Committers: 51
  • Avg Commits per committer: 25.412
  • Development Distribution Score (DDS): 0.649
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Wenjun Si w****j@a****m 455
Xuye (Chris) Qin x****n@a****m 279
He Kaisheng h****3@1****m 201
Liu Bao f****e@o****m 84
Shawn s****g@g****m 61
Tao He s****w@g****m 44
Qin Xuye c****u@g****m 38
bermaker 4****1@q****m 25
RandomY-2 6****2 15
Xuye (Chris) Qin q****n@q****e 10
Felix Vh 2****v 9
Jialing He b****b@g****m 6
yuyiming 3****g 5
rg070836rg 7****0@q****m 5
Yufei Wu w****f 5
Alexander Yi 3****t 3
Fernando 4****o 3
Shantam Gilra 6****8 3
Yoshiera h****r@1****m 3
keyile 3****e 3
黄浩杰 6****r 3
loopyme p****r@m****h 3
dependabot[bot] 4****] 2
Simon_CQK c****0@g****m 2
Da Li l****a@g****m 2
mmm311 1****6@q****m 2
cclauss c****s@m****m 1
lipi l****h@q****m 1
odidev o****v@p****m 1
qxzhou1010 3****0 1
and 21 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 57
  • Total pull requests: 67
  • Average time to close issues: 3 months
  • Average time to close pull requests: about 2 months
  • Total issue authors: 22
  • Total pull request authors: 16
  • Average comments per issue: 1.56
  • Average comments per pull request: 0.75
  • Merged pull requests: 43
  • Bot issues: 0
  • Bot pull requests: 8
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • fyrestone (17)
  • zhongchun (6)
  • dlee992 (5)
  • chaokunyang (5)
  • hekaisheng (2)
  • ericpai (2)
  • vcfgv (2)
  • Ukon233 (1)
  • azraelxuemo (1)
  • HeloWong (1)
  • kexuedaishu (1)
  • Alexia-I (1)
  • Suphx (1)
  • PaulWongDlut (1)
  • wil70 (1)
Pull Request Authors
  • fyrestone (14)
  • wjsi (8)
  • dependabot[bot] (8)
  • zhongchun (7)
  • chaokunyang (6)
  • hekaisheng (4)
  • vcfgv (4)
  • dlee992 (3)
  • ericpai (2)
  • vineethsaivs (2)
  • sighingnow (2)
  • yuyiming (1)
  • mimeku (1)
  • hoarjour (1)
  • Shaun2h (1)
Top Labels
Issue Labels
type: bug (16) good first issue (4) task: easy (3) mod: learn (3) shuffle (3) pr welcome (2) mod: dataframe (2) type: feature (2) type: tests (2) proposal (1) help wanted (1) mod: graph (1) type: enhancement (1) mod: scheduling service (1) mod: optimization (1) mod: deploy (1) mod: metric (1) task: hard (1) mod: ray integration (1) Hacktoberfest (1)
Pull Request Labels
type: enhancement (15) to be backported (14) mod: web (9) mod: ray integration (6) mod: task service (6) type: bug (4) mod: dataframe (3) type: docs (2) mod: optimization (1) mod: graph (1) type: tests (1) mod: lib (1) type: feature (1) mod: deploy (1) mod: tensor (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 18,868 last-month
  • Total docker downloads: 24,486,032
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 86
    (may contain duplicates)
  • Total versions: 175
  • Total maintainers: 3
pypi.org: pymars

MARS: a tensor-based unified framework for large-scale data computation.

  • Versions: 117
  • Dependent Packages: 1
  • Dependent Repositories: 86
  • Downloads: 18,868 Last month
  • Docker Downloads: 24,486,032
Rankings
Downloads: 1.0%
Stargazers count: 1.4%
Docker downloads count: 1.4%
Dependent repos count: 1.6%
Average: 1.9%
Forks count: 2.9%
Dependent packages count: 3.3%
Maintainers (3)
Last synced: 9 months ago
proxy.golang.org: github.com/mars-project/mars
  • Versions: 58
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 1.0%
Stargazers count: 1.1%
Average: 4.6%
Dependent packages count: 7.0%
Dependent repos count: 9.3%
Last synced: 9 months ago

Dependencies

mars/services/web/ui/package-lock.json npm
  • 613 dependencies
mars/services/web/ui/package.json npm
  • @babel/core ^7.12.3 development
  • @babel/node ^7.12.3 development
  • @babel/preset-env ^7.12.1 development
  • @babel/preset-react ^7.12.1 development
  • babel-loader ^8.1.0 development
  • cross-env ^7.0.0 development
  • css-loader ^5.2.0 development
  • eslint ^7.32.0 development
  • eslint-plugin-react ^7.24.0 development
  • express ^4.16.2 development
  • less-loader ^10.0.0 development
  • react-hot-loader ^4.13.0 development
  • style-loader ^2.0.0 development
  • url-loader ^4.0.0 development
  • webpack ^5.3.2 development
  • webpack-cli ^4.1.0 development
  • @material-ui/core ^4.0.0
  • @material-ui/icons ^4.0.0
  • cytoscape ^3.19.1
  • cytoscape-dagre ^2.3.2
  • d3 ^7.0.0
  • dagre-d3 ^0.6.4
  • lodash ^4.17.0
  • prop-types ^15.6.0
  • react ^16.8.0
  • react-dom ^16.8.0
  • react-router-dom ^5.0.0
ci/requirements-wheel.txt pypi
  • cloudpickle >=1.5.0
  • cython ==0.29.26
  • oldest-supported-numpy *
  • pandas ==1.2.2
  • pandas ==1.0.4
  • pandas ==1.1.3
  • pandas ==1.3.4
  • requests >=2.4.0
  • scipy ==1.5.3
  • scipy ==1.4.1
  • scipy ==1.5.4
  • scipy ==1.7.2
docs/requirements-doc.txt pypi
  • cloudpickle >=1.0.0
  • cython >=0.29
  • dask >=2021.07.2
  • ipython >=4.0
  • lightgbm >=3.0.0
  • matplotlib >=3.0.0
  • numpy >=1.14.0
  • pandas >=1.0.0
  • pyarrow >=0.11.0,
  • pydata-sphinx-theme >=0.3.0
  • pytest >=3.5.0
  • pytest-asyncio >=0.14.0
  • pytest-cov >=2.5.0
  • pytest-timeout >=1.2.0
  • scikit-learn >=0.20.3
  • sphinx >=3.0.0
  • sphinx-intl >=0.9.9
  • sqlalchemy >=1.2.0
  • statsmodels >=0.12.0
  • tornado >=6.0
  • xgboost >=1.3.0