{"id":13958978,"url":"https://github.com/modichirag/flowpm","last_synced_at":"2025-07-21T00:32:48.927Z","repository":{"id":57431482,"uuid":"346329553","full_name":"modichirag/flowpm","owner":"modichirag","description":"Particle Mesh simulation in TensorFlow","archived":false,"fork":true,"pushed_at":"2021-04-25T22:43:31.000Z","size":15721,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-02T11:14:26.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"DifferentiableUniverseInitiative/flowpm","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/modichirag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-10T11:18:20.000Z","updated_at":"2024-03-02T03:21:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/modichirag/flowpm","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/modichirag/flowpm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modichirag%2Fflowpm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modichirag%2Fflowpm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modichirag%2Fflowpm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modichirag%2Fflowpm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modichirag","download_url":"https://codeload.github.com/modichirag/flowpm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modichirag%2Fflowpm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266221327,"owners_count":23894966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-08T13:02:22.319Z","updated_at":"2025-07-21T00:32:43.918Z","avatar_url":"https://github.com/modichirag.png","language":null,"funding_links":[],"categories":["其他"],"sub_categories":["网络服务_其他"],"readme":"# flowpm\n[![Build Status](https://travis-ci.org/modichirag/flowpm.svg?branch=master)](https://travis-ci.org/modichirag/flowpm) [![PyPI version](https://badge.fury.io/py/flowpm.svg)](https://badge.fury.io/py/flowpm) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/modichirag/flowpm/blob/master/notebooks/flowpm_tutorial.ipynb) [![arXiv:2010.11847](https://img.shields.io/badge/astro--ph.IM-arXiv%3A2010.11847-B31B1B.svg)](https://arxiv.org/abs/2010.11847) [![youtube](https://img.shields.io/badge/-youtube-red?logo=youtube\u0026labelColor=grey)](https://youtu.be/DHOaHTU61hM)   [![PEP8](https://img.shields.io/badge/code%20style-pep8-blue.svg)](https://www.python.org/dev/peps/pep-0008/) \n\n\nParticle Mesh Simulation in TensorFlow, based on [fastpm-python](https://github.com/rainwoodman/fastpm-python) simulations\n\nTry me out: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/modichirag/flowpm/blob/master/notebooks/flowpm_blog.ipynb)\n\nTo install:\n```\n$ pip install flowpm\n```\n\nFor a minimal working example of FlowPM, see this [notebook](notebook/flowpm_tutorial.ipynb). The steps are as follows:\n```python\nimport tensorflow as tf\nimport numpy as np\nimport flowpm\n\ncosmo = flowpm.cosmology.Planck15()\nstages = np.linspace(0.1, 1.0, 10, endpoint=True)\n\ninitial_conditions = flowpm.linear_field(32,          # size of the cube\n                                         100,         # Physical size of the cube\n                                         ipklin,      # Initial power spectrum\n                                         batch_size=16)\n\n# Sample particles\nstate = flowpm.lpt_init(cosmo, initial_conditions, a0=0.1)   \n\n# Evolve particles down to z=0\nfinal_state = flowpm.nbody(cosmo, state, stages, 32)         \n\n# Retrieve final density field\nfinal_field = flowpm.cic_paint(tf.zeros_like(initial_conditions), final_state[0])\n```\n\n## Mesh TensorFlow implementation\n\nFlowPM provides a Mesh TensorFlow implementation of FastPM, for running distributed\nsimulations across very large supercomputers.\n\nHere are the instructions for installing and running on Cori-GPU. More info about\nthis machine here: https://docs-dev.nersc.gov/cgpu/\n\n0) Login to a cori-gpu node to prepare the environment:\n```\n$ module add esslurm\n$ salloc -C gpu -N 1 -t 30 -c 10 --gres=gpu:1 -A m1759\n```\n\n1) First install dependencies\n```\n$ module purge \u0026\u0026 module load gcc/7.3.0 python3 cuda/10.1.243\n$ pip install --user tensorflow==2.1\n$ pip install --user mesh-tensorflow\n```\n**NOTE: we are installing our own tensorflow 2.1 version until a module is available at NERSC**\n\n3) Install the Mesh TensorFlow branch of FlowPM\n```\n$ git clone https://github.com/modichirag/flowpm.git\n$ cd flowpm\n$ git checkout mesh\n$ pip install --user -e .\n```\n\n4) To run the demo comparing the distributed computation to single GPU:\n```\n$ cd examples\n$ sbatch lpt_job.sh\n```\n\nThis will generate a plot `comparison.png` showing from a set of initial\nconditions, the result of a single LPT step on single GPU TensorFlow vs Mesh\nTensorFlow.\n\n### TPU setup\n\nTo run FlowPM on Google TPUs here is the procedure\n\n - Step 1: Setting up a cloud TPU in the desired zone, do from the GCP console:\n ```\n$ gcloud config set compute/region europe-west4\n$ gcloud config set compute/zone europe-west4-a\n$ ctpu up --name=flowpm --tpu-size=v3-32\n ```\n\n  - Step 2: Installing dependencies and FlowPM:\n```\n$ git clone https://github.com/modichirag/flowpm.git\n$ cd flowpm\n$ git checkout mesh\n$ pip3 install --user mesh-tensorflow\n$ pip3 install --user -e .\n```\n\nIt's so easy, it's almost criminal.\n\n#### Notes on using and profiling for TPUs\n\nThere a few things to keep in mind when using TPUs, in particular, the section\non `Excessive tensor padding` from this document: https://cloud.google.com/tpu/docs/troubleshooting\n\nSee the [README](scripts/README.md) in the script folder for more info on how to profile\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodichirag%2Fflowpm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodichirag%2Fflowpm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodichirag%2Fflowpm/lists"}