-
Notifications
You must be signed in to change notification settings - Fork 127
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
Improve context API #395
Comments
Seeking input from other developers and the community. |
With #392 we can now separate out MPI initialize cleanly at the user level:
Devices must be attached to a partition
A default
|
Multiple simulation contexts do not work cleanly with the proposed command line entrypoint.
To reuse the same command line options, the user would need to explicitly reuse the device from the current context. MPI options like This fault is an argument against implementing the command line entrypoint. We should provide just one consistent API for defining devices. Users that which command line options for their scripts are free to implement them using this API. |
Many Python libraries and applications provide a |
This is a good proposal! In particular, I like option 2. I think that would offer a nice balance of intelligent defaults and simple learning curve for new users while still offering users plenty of control. |
Bug potential: We generally cache the output of |
I support removing |
The proposed API for v.3.0 will use |
Implemented on |
Description
There are many improvements to be made to HOOMD's context management. We should support
Proposed solution
I do not see any obvious targets for refactoring the C++ side ExecutionConfiguration. I propose
a pure python improvement to the python API using the existing C++ structure.
At the python level, device initialization will be separate from the simulation context:
Constructors will take fixed and mutable parameters, but fewer than
context.initialize
currently accepts.MPI domain decomposition options can already be passed to
hoomd.comm.decomposition
.Mutable execution device parameters will be exposed as properties:
Devices will be passed by variable, not stored in global state:
SimulationContext
uses CamelCase, unlike most of the HOOMD user API. It should behoomd.context.simulation
.Compared to
context.initialize
, this can also be a concise one-liner:There are a few options for implicit initialization.
hoomd.init.*
, create ahoomd.device.auto()
if the context is missing a device. In practice, this can only occur for the firstinit
command in the script - the one that uses the implicit empty context. Later ones would require an explicit userinstantiation of a simulation context:
hoomd.context.simulation
and insteadhoomd.init.*
methods each createand return a simulation context. The device would need to be passed as an argument:
hoomd
command line entry point. This tool would process command line options,create a device, simulation, and decomposition, then execute the user script:
Additional context
HOOMD started as a command line tool that ran scripts (which happened to be python scripts).
By v2, it evolved into first class python library, but kept some of its old tendencies. This proposal
is to remove those and make the API more flexible.
With the possibility for multiple and reusable devices, we could potentially move to a
pytest
testing framework.pytest
testsare simpler and cleaner than existing tests, plus it imports all tests into one process which would improve performance of many small
tests. I'm not certain how we would handle the long validation tests, or non-MPI tests vs test of different numbers of MPI ranks - but
that can be worked out later.
When implemented completely, this proposal would remove
context.initialize
,option
, and potentially change other APIs in v3.We could ease the transition by implementing the new library API alongside
context.initialize
in a 2.xrelease which would also deprecate the old API (this is not possible with option 3 as it would change the return type of
init.*
).Questions to consider
The text was updated successfully, but these errors were encountered: