Skip to content

Commit

Permalink
Merge pull request #50 from HERA-Team/clean-gpu
Browse files Browse the repository at this point in the history
Updated vis_gpu API to match vis_cpu
  • Loading branch information
steven-murray authored Aug 11, 2022
2 parents f6df26e + 7e749d6 commit c741675
Show file tree
Hide file tree
Showing 44 changed files with 3,451 additions and 1,484 deletions.
5 changes: 4 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[run]
branch = True
source = vis_cpu
omit = */vis_gpu.py
omit = */cli.py

[paths]
source =
Expand All @@ -22,6 +22,9 @@ exclude_lines =
# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError
except ImportError
raise ImportError
HAVE_GPU:

# Don't complain if non-runnable code isn't run:
if 0:
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/run_notebooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Run Notebooks

# Test on all pushes, except when the push is literally just a tag (because we
# tag automatically via CI, and therefore there's no extra code in that push).
# Also, only test on pull requests into master/dev.
on:
push:
tags-ignore:
- 'v*'
pull_request:
branches:
- 'main'

jobs:
notebooks:
name: Running Docs Notebooks
runs-on: ubuntu-latest
defaults:
run:
# Adding -l {0} ensures conda can be found properly in each step
shell: bash -l {0}
steps:
- uses: actions/checkout@main
with:
fetch-depth: 1

- name: Cache conda
uses: actions/cache@v2
env:
# Increase this value to reset cache if ci/test-env.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ matrix.python-version }}-${{ hashFiles('ci/test-env.yml', 'setup.cfg') }}

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2.1.1
with:
# auto-update-conda: true
miniconda-version: "latest"
python-version: '3.10'
environment-file: ci/notebook-env.yml
activate-environment: viscpu
channels: conda-forge,defaults
channel-priority: strict
use-only-tar-bz2: true

- name: Conda Info
run: |
conda info -a
conda list
- name: Install
run: |
echo $(which pip)
pip install .[test]
- name: Install ipykernel
run: python -m ipykernel install --user --name viscpu --display-name "viscpu"

- name: Run Notebooks
run: |
papermill -k viscpu docs/tutorials/vis_cpu_tutorial.ipynb tmp.ipynb
10 changes: 1 addition & 9 deletions .github/workflows/test_suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8, 3.9]
python-version: [3.8, 3.9, "3.10"]
defaults:
run:
# Adding -l {0} ensures conda can be found properly in each step
Expand Down Expand Up @@ -72,11 +72,3 @@ jobs:
- name: Run Tests
run: |
python -m pytest --cov=vis_cpu --cov-config=.coveragerc --cov-report xml:./coverage.xml --durations=25
- name: Upload Coverage
uses: codecov/codecov-action@v1.5.2
if: matrix.os == 'ubuntu-latest' && success()
with:
file: ./coverage.xml # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
82 changes: 82 additions & 0 deletions .github/workflows/test_suite_gpu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: GPU Tests

# Test on all pushes, except when the push is literally just a tag (because we
# tag automatically via CI, and therefore there's no extra code in that push).
# Also, only test on pull requests into master/dev.
on:
push:
tags-ignore:
- 'v*'
pull_request:
branches:
- 'main'

jobs:
tests:
env:
ENV_NAME: tests
PYTHON: "3.10"
OS: Ubuntu
name: Self-Hosted Tests (GPU)
runs-on: [self-hosted, gpu]
defaults:
run:
# Adding -l {0} ensures conda can be found properly in each step
shell: bash -l {0}
steps:
- name: Add Home to PATH
run: |
echo "/home/locoadmin/bin" >> $GITHUB_PATH
echo "/usr/local/cuda/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- uses: actions/checkout@main
with:
fetch-depth: 0

- name: Cache conda
uses: actions/cache@v2
env:
# Increase this value to reset cache if ci/test-env.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ env.PYTHON }}-${{ hashFiles('ci/test-env.yml', 'setup.cfg') }}

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2.1.1
with:
# auto-update-conda: true
miniconda-version: "latest"
python-version: ${{ env.PYTHON }}
environment-file: ci/test-env.yml
activate-environment: tests
channels: conda-forge,defaults
channel-priority: strict
use-only-tar-bz2: true

- name: Conda Info
run: |
conda info -a
conda list
PYVER=`python -c "import sys; print('{:d}.{:d}'.format(sys.version_info.major, sys.version_info.minor))"`
if [[ $PYVER != $PYTHON ]]; then
exit 1;
fi
- name: Install
run: |
echo $(which pip)
pip install .[test,gpu]
- name: Run Tests
run: |
python -m pytest --cov=vis_cpu --cov-config=.coveragerc --cov-report xml:./coverage.xml --durations=25 --log-cli-level=DEBUG
- uses: codecov/codecov-action@v2
if: success()
with:
fail_ci_if_error: true
verbose: true
file: ./coverage.xml
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__pycache__/*
.cache/*
.*.swp
*/.ipynb_checkpoints/*
**/.ipynb_checkpoints/*
.DS_Store

# Project files
Expand Down Expand Up @@ -45,7 +45,11 @@ docs/_rst/*
docs/_build/*
cover/*
MANIFEST
docs/_autosummary/*

# Per-project virtualenvs
.venv*/
.vscode/
full-stats-*.txt
stats-*.pkl
summary-stats-*.pkl
20 changes: 13 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
exclude: '^docs/conf.py|^tests/data/'
exclude: '^docs/conf.py|^src/vis_cpu/data/'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
Expand Down Expand Up @@ -33,7 +33,7 @@ repos:
- flake8-print

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black

Expand All @@ -47,7 +47,13 @@ repos:
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
hooks:
- id: pyupgrade
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.1
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.20.2
hooks:
- id: setup-cfg-fmt
43 changes: 41 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,53 @@
Changelog
=========

dev-version
===========
Version 1.0.0
=============

Version 1.0 is a major update that brings the GPU implementation up to the same API
as the CPU implementation. It also *removes* support for (l,m)-grid beams.

Removed
-------

- Support for ``bm_pix`` and ``use_pixel_beams`` (in both CPU and GPU implementations).
Now, using a ``UVBeam`` object will automatically use interpolation on the gridded
underlying data (which is typically in az/za). This can be done directly using
methods in ``UVBeam``, or via new GPU methods. If you input an ``AnalyticBeam``, the
beam will instead just merely be evaluated.

Added
-----

- Polarization support for GPU implementation.

Changed
-------

- Faster performance if using ``beam_list`` and the frequency is not in the ``freq_array``.
(interpolation done before the loop).
- Factor of ~10x speed-up of ``vis_cpu`` due to changing the final ``einsum`` into a
matrix product.
- **BREAKING CHANGE:** the output from the CPU and GPU implementations has changed
shape: it is now ``(Ntimes, Nfeed, Nfeed, Nant, Nant)`` (and without the feed axes
for non-polarized data).

Internals
---------

- ``vis_cpu`` and ``vis_gpu`` *modules* renamed to ``cpu`` and ``gpu`` respectively, to
avoid some problems with name clashes.
- New more comprehensive tests comparing the GPU and CPU implementations against
each other and against pyuvsim.
- New tests of documentation notebooks to ensure they're up to date.

Documentation
-------------

- Updated sphinx them to Furo.
- More complete Module Reference documentation.
- Updated tutorial to match the new API.
- Added a new "Understanding the Algorithm" page (with math!)

Version 0.4.3
=============
Expand Down
23 changes: 23 additions & 0 deletions ci/notebook-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: viscpu
channels:
- conda-forge
- defaults
dependencies:
- mpi4py>=3.0 # Required here so that we get
- astropy>=4
- numpy>=1.20
- scipy>=1.6
- pip>=21.1
- pytest>=6.2.4
- pytest-cov>=2.11.1
- matplotlib>=3.3.4
- ipython>=7.22
- h5py>=3.2
- ffmpeg
- pyuvdata # For testing when using UVBeam object
- jupyter
- ipykernel
- papermill
- pip:
- pyuvsim[sim]>=1.2
- pyradiosky>=0.1.1
6 changes: 0 additions & 6 deletions docs/_autosummary/vis_cpu.vis_cpu.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/_autosummary/vis_cpu.vis_gpu.rst

This file was deleted.

26 changes: 24 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,30 @@
API Summary
===========

High-Level Wrapper
------------------

.. autosummary::
:template: custom-module.rst
:toctree: _autosummary

vis_cpu.wrapper


Simulator implementations
-------------------------
.. autosummary::
:template: custom-module.rst
:toctree: _autosummary

vis_cpu.cpu
vis_cpu.gpu

Other Utilities
---------------
.. autosummary::
:template: custom-module.rst
:toctree: _autosummary

vis_cpu.vis_cpu
vis_cpu.vis_gpu
vis_cpu.plot
vis_cpu.conversions
Loading

0 comments on commit c741675

Please sign in to comment.