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

CoreNeuron Rebalancer #206

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

CoreNeuron Rebalancer #206

wants to merge 9 commits into from

Conversation

ferdonline
Copy link
Collaborator

@ferdonline ferdonline commented Oct 23, 2024

Context

CoreNeuron runs, in particular those using multi-cycle, may end up distributing cells unoptimally.

We want to mitigate that by introducing a post processing step which distributes the CoreNeuron input files evenly across ranks, based on their size.

Scope

Added rebalance-corenrn-data.py to neurodamus/tools.

CLI:

neurodamus/tools $ ./rebalance-corenrn-data.py -h
usage: rebalance-corenrn-data.py [-h] [--max-entries MAX_ENTRIES] [--output-file OUTPUT_FILE] [-v] [--histogram] input_file n_ranks

Redistribute CoreNeuron dat files, optimizing for a given number of ranks

positional arguments:
  input_file            Path to the CoreNeuron input file, typically files.dat
  n_ranks               Number of target ranks

options:
  -h, --help            show this help message and exit
  --max-entries MAX_ENTRIES
                        Consider only the first N entries of the input file
  --output-file OUTPUT_FILE
                        The rebalanced output file path
  -v, --verbose         Enable verbose output for debugging.
  --histogram           Additionally display the histogram of the ranks accumulated sizes

Testing

Using /gpfs/bbp.cscs.ch/data/scratch/proj134/home/king/BBPP134-917/o_MultiCycle_Support/output/2557873/coreneuron_input/files.dat for testing

Example

leite@bbpv2 ~/dev/neurodamus/neurodamus-py/tools (leite/corenrn-rebalancer %)$ python rebalance-corenrn-data.py /gpfs/bbp.cscs.ch/data/scratch/proj134/home/king/BBPP134-917/o_MultiCycle_Support/output/2557873/coreneuron_input/files.dat 10 --max-entries=1000
INFO :: Reading from input file: /gpfs/bbp.cscs.ch/data/scratch/proj134/home/king/BBPP134-917/o_MultiCycle_Support/output/2557873/coreneuron_input/files.dat'
WARNING :: files.dat (line 2): reduced number of entries: 1000'
INFO :: Distributing files into 10 buckets...'
INFO :: Processing 1000 entries'
         0 [  0%]
        20 [  2%]
...
       980 [ 98%]
INFO :: Writing out data from 10 buckets to file: rebalanced-files.dat'
INFO :: DONE'

Review

  • PR description is complete
  • Coding style (imports, function length, New functions, classes or files) are good
  • Unit/Scientific test added
  • Updated Readme, in-code, developer documentation

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@ferdonline ferdonline marked this pull request as ready for review October 24, 2024 14:39
@bbpbuildbot
Copy link


# Numpy may be required (histogram)
numpy = None

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it makes sense to have some constants (for example):

PROGRESS_UPDATE_FREQUENCY = 50
DEFAULT_OUTPUT_FILE = "rebalanced-files.dat"
FILL_VALUE = "-1\n"

Or the names you think makes more sense

print(f" [{bin_start/(1024*1024):5.0f} - {bin_end/(1024*1024):5.0f}]: {count:0d}")
bin_start = bin_end


Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is a tool to be used in the future and not only a script that will be discarded soon maybe makes sense to have a class?
something like

class RebalancerConfig:
...
class CoreNeuronRebalancer:
    def __init__(self, config: RebalancerConfig):
        self.config = config
        self.logger = self._setup_logger()
        self.buckets = []
        ...

def main():
        # Parse arguments and create config
        args = parse_args()
        config = RebalancerConfig.from_args(args)

        # Create and run rebalancer
        rebalancer = CoreNeuronRebalancer(config)
        rebalancer.rebalance()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants