Server#
fmlip-relay-server is the Python side of the relay.
The Fortran client normally launches it via the command string given to mlip_init, but it is an ordinary command-line program and can be started by hand for testing.
python -m fmlip_relay is equivalent.
Server mode#
fmlip-relay-server --port 54321 --backend dummy
fmlip-relay-server --port 54321 --backend lj --lj-epsilon 0.0104 --lj-sigma 3.40 --lj-cutoff 8.50
fmlip-relay-server --port 54321 --backend mace --model /path/to/model.model --device cuda
fmlip-relay-server --port 54321 --backend uma --uma-task omol --device cuda
The server loads the backend, binds the port on 127.0.0.1, and prints READY <port> to standard output.
It then serves one client at a time until it receives QUIT.
Log messages go to standard error; the client scans standard output for the READY line only.
After that line the server redirects its standard output to standard error, so that a model library printing during the run cannot fill the unread pipe and stall the server.
The server only listens on the loopback interface and performs no authentication. Client and server must run on the same machine.
Automatic port selection#
With --port 0 the operating system picks a free port.
The actual number is part of the READY <port> line, which mlip_init parses, so nothing else has to be coordinated.
Client loss#
By default a server whose client disconnects goes back to waiting for a new connection.
With --exit-on-disconnect it shuts down instead, which keeps crashed Fortran jobs from leaving servers (and their GPU memory) behind.
Logging#
--loglevel DEBUG|INFO|WARNING|ERROR sets the verbosity of fmlip-relay’s own messages; third-party libraries stay at WARNING.
--log FILE writes the log to a file in addition to standard error, which is the easiest way to see why a server spawned from Fortran failed to start.
Single-point test mode#
--test GEOMETRY loads a structure, runs one evaluation through the selected backend, prints a summary, and exits.
No port and no Fortran code are involved, which makes it the quickest check that a model loads and gives sensible numbers.
$ fmlip-relay-server --backend lj --test ar3.xyz
────────────────────────────────────────────────────────
fmlip-relay single-point test
────────────────────────────────────────────────────────
File : ar3.xyz
Backend : lj(eps=0.0104 eV, sig=3.400 Å, rc=8.500 Å)
Atoms : 3
Charge : +0 (default)
Multiplicity : 1 (2S+1, default)
PBC : [False, False, False]
────────────────────────────────────────────────────────
Energy : -0.021279 eV (-0.007093 eV/atom)
|F| max : 0.001906 eV/Å
|F| mean : 0.001742 eV/Å
|F| rms : 0.001015 eV/Å
────────────────────────────────────────────────────────
Wall time : 1.8 ms
────────────────────────────────────────────────────────
# sym Fx Fy Fz |F| E_atom
1 Ar -0.001000 -0.001000 +0.000000 0.001414 -0.009663
2 Ar -0.000752 +0.001752 +0.000000 0.001906 -0.005808
3 Ar +0.001752 -0.000752 +0.000000 0.001906 -0.005808
The last column lists the per-atom energies in eV.
Geometries are read with ASE when it is installed (XYZ, extended XYZ, CIF, POSCAR, and so on).
Without ASE a built-in parser handles plain XYZ files, so the dummy and lj backends can be tested on a core install.
Adding --hessian also computes the Hessian and prints its lowest and highest eigenvalues, a quick check that the six (or five) translational and rotational modes are near zero at a stationary point.
--charge Q and --spin M set the total charge and the multiplicity 2S+1 for the evaluation.
If omitted, the values are taken from the geometry file when it carries them, and default to 0 and 1 otherwise.
Threads and CPU pinning#
By default a CPU server uses every core it can see, which is the wrong behaviour when several instances share a node.
--max-threads NCaps the thread pools of PyTorch, OpenMP, MKL, and OpenBLAS at
N.--cpu-affinity CPUSPins the server to a set of cores, given as a list such as
0-3,0,2,4, or0-3,8(Linux only). Unless--max-threadsis also given, the thread cap defaults to the number of pinned cores.
Four servers on a 16-core node would get --cpu-affinity 0-3, 4-7, 8-11, and 12-15.
Models in other units#
The wire protocol is fixed to Å and eV. For a model trained in other units, ASE-based backends accept two conversion factors:
--e-to-ev FeV per model energy unit.
--l-to-ang FÅ per model length unit.
Coordinates and cell are converted into model units before the call, and energy, forces, and stress are converted back afterwards.
A model trained in Hartree and Bohr would use --e-to-ev 27.211386 --l-to-ang 0.529177.
Option reference#
Generated from the argument parser.
usage: fmlip-relay-server [-h] [--port PORT] --backend BACKEND
[--exit-on-disconnect] [--test GEOMETRY]
[--charge Q] [--spin M] [--hessian] [--log LOG]
[--loglevel {DEBUG,INFO,WARNING,ERROR}]
[--model MODEL] [--device DEVICE] [--e-to-ev F]
[--l-to-ang F] [--max-threads N]
[--cpu-affinity CPUS] [--dtype {float32,float64}]
[--mace-model MODEL] [--dispersion]
[--uma-model MODEL] [--uma-task TASK]
[--lj-epsilon LJ_EPSILON] [--lj-sigma LJ_SIGMA]
[--lj-cutoff LJ_CUTOFF]
[--omm-source {AMBER,GROMACS,CHARMM,OPENCG}]
[--omm-coord OMM_COORD] [--omm-top OMM_TOP]
[--omm-param OMM_PARAM]
[--omm-include-dir OMM_INCLUDE_DIR]
[--omm-config OMM_CONFIG] [--omm-pbc {PBC,NOPBC}]
[--omm-prepare-only]
Named Arguments#
- --port
TCP port to listen on (loopback only). 0 lets the OS pick a free port, announced as ‘READY <port>’. Required unless –test is used.
- --backend
Backend name: mace | mace_mp | mace_off | uma | mace_polar | nequip | allegro | deepmd | schnet | openmm | custom | lj | dummy
- --exit-on-disconnect
Shut the server down when the client disconnects without QUIT (e.g. the Fortran parent crashed), instead of waiting for a new connection.
Default:
False- --log
Optional log file path (stderr is always used)
- --loglevel
Possible choices: DEBUG, INFO, WARNING, ERROR
Log verbosity
Default:
'INFO'
Single-point test options (–test)#
- --test
Run a single-point calculation on the given geometry file (XYZ / extended-XYZ), print a summary, and exit. –port is not required in this mode.
- --charge
Total charge for the –test evaluation. Default: value from the geometry file if present, else 0 (neutral). Used by charge-aware backends (e.g. UMA omol).
- --spin
Spin multiplicity 2S+1 for the –test evaluation. Default: value from the geometry file if present, else 1 (ground-state singlet). Used by spin-aware backends (e.g. UMA omol).
- --hessian
With –test: also compute the Hessian and print its lowest and highest eigenvalues.
Default:
False
Model file options (mace | mace_polar | nequip | allegro | deepmd | schnet | custom)#
- --model
Path to the model file (required for mace, mace_polar, nequip, allegro, deepmd, schnet). For custom: the script defining create_calculator(), default ./ase_custom.py
MACE-MP options (–backend mace_mp) — Materials Project, 89 elements#
- --mace-model
Foundation model variant. mace_mp default: ‘medium-mpa-0’, options: small, medium, large, small-0b, medium-0b, small-0b2, medium-0b2, medium-0b3, medium-mpa-0, large-0b2, medium-omat-0. mace_off default: ‘medium’, options: small, medium, large.
- --dispersion
Add D3 dispersion correction (mace_mp only; requires torch-dftd)
Default:
False
UMA options (–backend uma) — Meta FAIR universal model (fairchem)#
- --uma-model
UMA checkpoint. Default: ‘uma-s-1p2’, options: uma-s-1, uma-s-1p1, uma-s-1p2, uma-m-1.
- --uma-task
Possible choices: omol, omat, omc, oc20, odac
Task / domain head. Default: ‘omol’, options: omol, omat, omc, oc20, odac.
Lennard-Jones options (–backend lj)#
- --lj-epsilon
Well depth ε in eV
Default:
0.0104- --lj-sigma
Zero-crossing σ in Å
Default:
3.4- --lj-cutoff
Cutoff radius in Å
Default:
8.5
OpenMM options (–backend openmm) — classical force fields#
- --omm-source
Possible choices: AMBER, GROMACS, CHARMM, OPENCG
Force-field input format
- --omm-coord
Coordinate file (OPENCG: start/restart PDB)
- --omm-top
Topology file: prmtop, top or psf (OPENCG: fixed reference PDB)
- --omm-param
CHARMM parameter/topology/stream file (repeatable)
Default:
[]- --omm-include-dir
GROMACS include directory
- --omm-config
createSystem options, or the OpenCG model (.json/.yaml/.yml)
Default:
'NOCONFIG'- --omm-pbc
Possible choices: PBC, NOPBC
Periodicity for –omm-prepare-only
- --omm-prepare-only
Generate an OpenCG start PDB and exit
Default:
False