Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to simplify and reduce memory for multiringbuffer #2523

Merged
merged 7 commits into from
Mar 5, 2019

Conversation

ahnitz
Copy link
Member

@ahnitz ahnitz commented Feb 26, 2019

No description provided.

@titodalcanton
Copy link
Contributor

This is being tested.

@titodalcanton
Copy link
Contributor

I immediately got this:

2019-02-27 07:23:44,326 node742 0 background and zerolag coincs
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/mpi4py/__main__.py", line 7, in <module>
    main()
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/mpi4py/run.py", line 196, in main
    run_command_line(args)
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/mpi4py/run.py", line 47, in run_command_line
    run_path(sys.argv[0], run_name='__main__')
  File "/usr/lib64/python2.7/runpy.py", line 240, in run_path
    return _run_module_code(code, init_globals, run_name, path_name)
  File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/tito/projects/pycbc/live/multidetector/env/bin/pycbc_live", line 573, in <module>
    coinc_results.append(c.add_singles(results, data_reader))
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/pycbc/events/coinc.py", line 1116, in add_singles
    ifos=valid_ifos)
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/pycbc/events/coinc.py", line 1058, in _find_coincs
    coinc_results['background/time'] = numpy.array([self.background_time])
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/pycbc/events/coinc.py", line 838, in background_time
    time *= len(self.singles[ifo]) * self.analysis_block
TypeError: object of type 'MultiRingBuffer' has no len()

@titodalcanton
Copy link
Contributor

Can we just rename MultiRingBuffer.num_elements to __len__?

@ahnitz
Copy link
Member Author

ahnitz commented Feb 27, 2019

I've renamed it so it isn't len either, as it really was something else. It was supposed to be the number of time steps that have been added to the buffer. This maxes out at the max buffer size, but before this we need to know how many have been taken to correctly know the total background time.

@titodalcanton
Copy link
Contributor

New error:

Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/mpi4py/__main__.py",
 line 7, in <module>
    main()
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/mpi4py/run.py", line
 196, in main
    run_command_line(args)
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/mpi4py/run.py", line
 47, in run_command_line
    run_path(sys.argv[0], run_name='__main__')
  File "/usr/lib64/python2.7/runpy.py", line 240, in run_path
    return _run_module_code(code, init_globals, run_name, path_name)
  File "/usr/lib64/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/tito/projects/pycbc/live/multidetector/env/bin/pycbc_live", line 573, in <module>
    coinc_results.append(c.add_singles(results, data_reader))
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/pycbc/events/coinc.p
y", line 1118, in add_singles
    updated_indices = self._add_singles_to_buffer(results, ifos=valid_ifos)
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/pycbc/events/coinc.p
y", line 939, in _add_singles_to_buffer
    self.singles[ifo].add(trigs['template_id'], data)
  File "/home/tito/projects/pycbc/live/multidetector/env/lib/python2.7/site-packages/pycbc/events/coinc.p
y", line 578, in add
    self.buffer[i] = numpy.concatenate([self.buffer[i], v])
ValueError: all the input arrays must have same number of dimensions

Apparently v is a numpy.void and does not like to be concatenated with an empty array.

@titodalcanton
Copy link
Contributor

@ahnitz after the commits I just did, the analysis is running without errors. Could you double check that I did not mess anything up?

@ahnitz
Copy link
Member Author

ahnitz commented Feb 28, 2019

@titodalcanton Nothing glaringly obvious at least.

@titodalcanton
Copy link
Contributor

After several hours of running, the memory usage appears still limited to several Gb. Yay!

@titodalcanton
Copy link
Contributor

@ahnitz is this still a work in progress or just needs to be tested? Is the result expected to be identical to the previous version? If so, that is an easy test.

@ahnitz
Copy link
Member Author

ahnitz commented Mar 1, 2019 via email

Copy link
Contributor

@titodalcanton titodalcanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and tests are underway.

@titodalcanton
Copy link
Contributor

titodalcanton commented Mar 2, 2019

After running on my fake frames with injections, the exact same set of HDF and coinc XML files is generated, with identical file names, with respect to a run done with v1.13.4. However, I compared a few coinc XML files in detail and they are not identical.

Most of the differences are tiny changes in the SNR time series and PSDs, which look like numerical rounding in the least significant digits. I was a bit surprised to see even such a tiny difference, but whatever.

However in one case (coinc-1169265807.xml.gz for self reference) the coinc_inspiral:combined_far value went from 3.491173665171772e-05 to 0.0001112754634923875. The coinc_inspiral:snr is equal to 6 significant digits. I do not remember seeing combined_far change in a couple other coinc files. What do you think?

@ahnitz
Copy link
Member Author

ahnitz commented Mar 2, 2019 via email

@titodalcanton titodalcanton added this to the ER14 milestone Mar 4, 2019
@titodalcanton
Copy link
Contributor

Here is a comparison of the FARs for the coinc events generated for the injection run. X shows basically time (event index), y shows new / old FAR. So FARs tend to be systematically larger now.

far_check

@ahnitz
Copy link
Member Author

ahnitz commented Mar 4, 2019

@titodalcanton Yeah that's disconcerting. I think what I'll do is put together a test script with these two version and feed them random numbers to see what happens. One of them must have a bug, I think.

@ahnitz
Copy link
Member Author

ahnitz commented Mar 4, 2019

@titodalcanton Based on my test (see pycbc chat for more details) I think this is the right implementation and fixes a bug in the current version that is hit when the buffer resizes. My suggestion is that we merge this patch. What do you think?

@titodalcanton
Copy link
Contributor

Ok I think I get what the problem with the old class is. Let's merge and keep testing this, also given how much memory the old approach requires.

@titodalcanton titodalcanton merged commit a3de734 into gwastro:master Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants