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

Debugging relativity on numba_montecarlo #1136

Merged

Conversation

arjunsavel
Copy link
Contributor

@arjunsavel arjunsavel commented Apr 22, 2020

Description

I'm working to fix the relativity functionality on the numba_montecarlo branch.

  • Specific to relativity, I've corrected a distance calculation equation.
  • I've added missing montecarlo_configuration arguments to function calls
  • I've removed a kwarg from the MonteCarloConfiguration, as numba jitclass does not currently support kwargs.
  • Added logging decorator capabilities
  • Added debugging capabailities
  • Added logging / debugging documentation
  • Reverted the logic prior to the MonteCarloException; this now runs again, so long as enable_full_relativity is false.

Motivation and Context

Full relativity currently isn't working on the numba_montecarlo branch, preventing it from being merged with master.

How Has This Been Tested?

Advanced unit tests are currently failing due to. I can write tests after I address these failings to ensure that the relativity portion runs as expected. No new bugs seem to be introduced.

Screenshots (if appropriate):

I can add screenshots if desired.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@arjunsavel arjunsavel marked this pull request as draft May 27, 2020 15:03
@harpolea
Copy link
Contributor

I noticed that @njit has been converted to @jit in several places - is there a reason for this?

@arjunsavel
Copy link
Contributor Author

@harpolea This is just for debugging reasons — in nopython mode, the MonteCarloException wasn't showing up as such, and I was just getting a TypingError. Once I figure out what's triggering the exception, I'm planning on changing the @jits back to @njits. Alternatively, I could figure out a better way to have exceptions shown in nopython mode...

@arjunsavel arjunsavel marked this pull request as draft June 18, 2020 14:57
@arjunsavel arjunsavel marked this pull request as ready for review June 18, 2020 21:17
@wkerzendorf wkerzendorf merged commit feee984 into tardis-sn:numba_montecarlo Jul 2, 2020
atharva-2001 pushed a commit to atharva-2001/tardis that referenced this pull request Oct 1, 2021
* removing kwarg from MonteCarloConfiguration, as jitclass does not support them

* need to pass enable_full_relativity to configuration_initialize, as removed kwarg in MonteCarloConfiguration

* move_r_packet and trace_packet both require montecarlo_configuration arg

* r_packet object used in distance calculation in place of r_packet.r value

* the full_relativity bool was being passed as a different kwarg

* added montecarlo_configuration to args of trace_vpacket_volley and trace_vpacket, so that relativity attribute continues to get passed down

* making sure the vpacket funcs that now require montecarlo_configuration get called with this arg

* Added random seed; does not work with numba

* Changed to numpy random seed

* Commented out MonteCarloException block; will test how this impacts output

* Need the MonteCarloException block to be run, otherwise large discrepancies between numba branch and master branch

* Adding custom seeds to vpackets; few line adjustments

* changed from njit to jit to ease debugging

* More descriptive montecarloexception, with optional printing beforehand

* Changed njit to jit in single_loop to ease debugging

* Added single-packet debugging capabilities to MonteCarloRunner.

* Removing plotting funcs from montecarlo

* Added basic logging capabilities to montecarlo_numba

* Generalized logger to *args

* Tweaking configuration of logging in module

* Logger can now handle kwargs

* Renamed logger

* Make logging more in line with other TARDIS loggers.

* Share global variable DEBUG_MODE across modules with montecarlo init.

* No longer calling removed plot_single_packet; also referring to __init__ DEBUG_MODE

* Now referring to montecarlo __init__ DEBUG_MODE global

* Remove dangling  else statement

* no longer need plotting in montecarlo_numba base.py

* Remove import of function that no longer exists.

* No longer holding global variables in montecarlo init

* Importing mc_logger for global variables now

* Moving log_decorator from base.py

* Adding logger to new montecarlo_logger file

* Add new logger to, remove print statements from r_packet.py

* Ensure that DEBUG_MODE is referenced within the montecarlo_logger file

* Allow the function being decorated to take its kwargs.

* Apply wraps correctly

* Make else block logic more apparent

* Get rid of extra blank line

* Got rid of a few todos

* Add note about why decorator behavior will not change according to config

* removing reference to logger in base

* Added crude buffer

* Increase buffer; check DEBUG_MODE checked during call, not init

* Set default buffer in montecarlo logger to stated default

* Allow specification of buffer in montecarlo yml

* Make sure logger_buffer is passed through to montecarlo logger

* Remove todo, question from log_decorator

* Adding better docstrings to log_decorator

* Add newline at end of montecarlo_logger file

* Make logger config happen outside of decorator

* Moved print statement to exception;

* Added logging to file

* No longer profiling calculate_distance_line

* Add functionality to profile incomplete packet runs

* Rename previous debug mode, as it was not for single packets

* Added single packet seed to yml

* Propagate single_packet_seed throughout configurations

* Reference single packet seed from montecarloconfiguration

* Add bool type to single packet seed type

* Catch exception better, catch extra random seed

* Set whole index, including energies, not just random seed

* Change where loop is broken.

* Move close_line_threshold check past montecarloexception

* Add single-packet debug documentation and script

* Add jitclass arg for single packet seed in montecarloconfiguration

* Now the default for single_packet_seed cannot be a bool

* Added new debug page to developer part of documentation

* Now the single_packet_seed has to be not 1, not not False

* Pause using log_decorator, remove try/except for nopython

* Vpacket jitclass now allows for an int64 index

* Exceptions args must be compile-time constants in nopython mode

* Allow 0 nu_diff to not throw exception.

* v_packets should have the same random seed as their r_packet

* Fix MonteCarloException throw

* Fix estimator typos

* Make sure return is not made before relativity block

* Rename esitmators to keep them consistent

* Also rename the estimators in montecarlo.pyx

* Rename estimators in numba_interface

* Clean up estimator typos; change back to njit

* Include Doppler factor in energy calculation for full_relativity

* Add back not statement

* Added relativistic Doppler factor

* Add in Doppler factor relativity for interaction

* Add angle aberration

* add angle aberration to interactions

* Update numba version

* Remove relativity branching

* Logger no longer prints to console if printing to file

* Initialize configuration with external module, not jitclass

* Remove extra repr of logger.handlers

* Ensure the angle aberration is called on vpacket, remove jitclass reference

* Convert montecarloconfiguration refs from jitclass to module

* Add more references to global module, complete relativistic branching

* Pass r_packet.mu to angle aberration calculation

* Clarify angle aberration calc, include doppler factor to distance calc

* Remove reference to MonteCarloConfiguration

* Trying to delete C tests

* Remove C montecarlo

* Remove references to C module

* Alter formal integral tests for python version

* Rewrite formal integral in python
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.

3 participants