Add fixed-cell i-PI socket driver#7609
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
| { | ||
| ModuleBase::TITLE("Driver", "driver_run"); | ||
|
|
||
| const std::string cal = PARAM.inp.calculation; |
There was a problem hiding this comment.
it is not a good idea to add new function here,
| return GlobalV::MY_RANK == IPI_RANK_ROOT; | ||
| } | ||
|
|
||
| void bcast_int(int& value) |
There was a problem hiding this comment.
we have 'bcast_int' function that can be used without writing a new one
| const std::string message = bcast_string(root_message); | ||
| if (root_failed != 0) | ||
| { | ||
| throw std::runtime_error(message.empty() ? "i-PI socket I/O failed" : message); |
| CalculationModeGuard calculation_guard("scf"); | ||
|
|
||
| UnitCell ucell; | ||
| ucell.setup(PARAM.inp.latname, PARAM.inp.ntype, PARAM.inp.lmaxmax, PARAM.inp.init_vel, PARAM.inp.fixed_axes); |
There was a problem hiding this comment.
I would suggest not using PARAM (global variable)
Route calculation=socket through Relax_Driver, keep ESolver lifecycle in driver_run, and add source_relax socket transport tests.
341a302 to
fe2c2a3
Compare
| const bool socket_mode = (socket_esolver_inp.calculation == "socket"); | ||
| if (socket_mode) | ||
| { | ||
| socket_esolver_inp.calculation = "scf"; |
There was a problem hiding this comment.
Thanks for the PR, but here it seems not appropriate to set the calculation as 'socket' first and then change it to 'scf', it may better to design another variable other than calculation
| relax | ||
| OBJECT | ||
| relax_data.cpp | ||
| ipi_socket.cpp |
There was a problem hiding this comment.
seems better to name the file name as socket_ipi.cpp, consistent with the socket_driver.cpp
There was a problem hiding this comment.
could you provide some examples in the 'interface' directory to demonstrate that the function can run successfully?
| * relax: perform structure relaxation calculations, the relax_nmax parameter depicts the maximal number of ionic iterations | ||
| * cell-relax: perform cell relaxation calculations | ||
| * md: perform molecular dynamics simulations | ||
| * socket: run as a socket client for external drivers using the i-PI protocol |
There was a problem hiding this comment.
do you have an example to demonstrate how to use this feature?
Reminder
AGENTS.mdanddocs/developers_guide/agent_governance.md.source/changes.Linked Issue
No linked issue. This PR adds a new optional driver mode and does not change the default execution path.
Unit Tests and/or Case Tests for my changes
chg_extrap defaultwithcalculation socket, expectingfirst-order.SocketIOCalculatordriver:chg_extrap atomic,first-order, andsecond-orderin socket mode. The result is trajectory dependent, so this PR documents the default behavior but does not claim one extrapolation mode is universally fastest.Exact Verification Performed
Commands run:
Result summary:
develop.abacus_basic_gpu.abacus_basic_gpu -h calculationlistssocket.abacus_basic_gpu -h chg_extrapdocuments thatdefaultchoosesfirst-orderforrelax/cell-relax/socket,second-orderformd, andatomicfor other calculations.Checks not run, with reason:
FrechetCellFilterworkflows were not run because this PR intentionally supports fixed-cell energy/force requests only.What's changed?
This PR adds a fixed-cell i-PI-compatible socket driver mode for ABACUS.
Motivation:
SocketIOCalculatorand similar drivers while keeping the default ABACUS calculation modes unchanged.SocketIOCalculator, to keep one ABACUS process alive and request energy/forces for updated atomic positions.User-visible INPUT change:
Socket endpoint selection:
export ABACUS_IPI_ADDRESS=/tmp/ipi_abacus_test:UNIXThe value is an address string, not an installed dependency:
/tmp/ipi_abacus_testis the UNIX-domain socket path created by the external driver.:UNIXtells ABACUS to connect through a UNIX-domain socket instead of TCP.ABACUS_IPI_ADDRESS=localhost:31415is also supported./tmp/ipi_abacus_${SLURM_JOB_ID}:UNIX, to avoid collisions.No i-PI library is linked or required by ABACUS. The implementation speaks the subset of the i-PI socket protocol needed by ASE-style drivers using POSIX sockets. Users need an external socket server/driver, for example ASE, to create the socket and launch ABACUS as the client.
Implementation details:
driver_run()dispatchescalculation sockettoDriver::driver_ipi_run()before the ordinary calculation-mode dispatch.driver_ipi_run()initializes hardware and an ESolver once, then enters an i-PI message loop.STATUS,INIT,POSDATA, andGETFORCEmessages.POSDATA, ABACUS updates atomic positions in the existing fixed cell, runs the SCF runner, computes energy and forces, and stores them for the followingGETFORCEresponse.after_all_runners()is called only after at least one successful runner call.Example external-driver shape with ASE:
Example minimal INPUT fragment:
Compile/use notes:
source/CMakeLists.txt.SocketIOCalculator, to create the socket and launch/connect ABACUS.Governance Checklist
Driverintegration patterns and usesPARAM/GlobalVfor input, rank, logging, ESolver setup, JSON output, and hardware lifecycle.ipi_socket.hincludes standard library declarations needed for its public value types (std::string,std::vector,std::size_t).source/CMakeLists.txt.docs/parameters.yamlanddocs/advanced/input_files/input-main.md.@coderabbitai review.INPUT Parameter Changes
calculation: adds the new accepted valuesocket.cal_force: defaults to enabled forcalculation socket, consistent with socket energy/force use.chg_extrap: documents calculation-dependentdefaultrouting and routes socket mode tofirst-order.docs/parameters.yamlupdated: yes.docs/advanced/input_files/input-main.mdupdated: yes.Core Module Impact
Driver: adds a new socket driver dispatch path.ESolver: reused through the existing SCF runner path; no ESolver API change.UnitCell: positions are updated from incoming POSDATA under a fixed cell; variable-cell updates are rejected.source_io/module_parameter: adds INPUT metadata/default behavior for socket mode.calculation socket.PARAM/GlobalV, covered by the governance exception below.scf,relax,md,cell-relax, and post-processing modes should continue through the existing dispatch path.Governance Exception
GlobalV,GlobalC, orPARAMreferences.PARAM/GlobalVpatterns. The socket driver follows that integration style to keep the change localized and avoid broad core-interface churn.driver_run.cpp.Driver, ESolver setup, logging, hardware lifecycle, and JSON output interfaces, which is larger than this feature PR.