Questions about i-PI socket connect to multiple force engines and a GPR code.

49 views
Skip to first unread message

Chenghao Zhang

unread,
May 16, 2025, 8:23:47 PMMay 16
to ipi-users
Hi, there,
   I have a question about the i-PI socket and I am wondering if it's possible to have it interface with multiple force engines. I am trying to implement a new feature (Gaussian Process Regression) to make it work with i-PI. (See our recent work: https://chemrxiv.org/engage/chemrxiv/article-details/67f9c3fc81d2151a021107e1)

   I have recently developed a Gaussian Process Regression (GPR) code using Gpytorch (https://gpytorch.ai/), but currently, it's sitting inside the i-PI code. This code is not efficient because it has to be called from the i-PI, and i-PI is supposed to be a light-weight server. I am interested in extracting GPR code out and using the server-client socket interface to make the GPR code work with i-PI. This will make it possible to accelerate the GPR code with GPUs. 

    My plan is to have the i-PI connect to the ab-initio force field and the GPR code. To make this work, the code should be able to obtain ab-initio forces from the force engine and obtain ML force predictions from the GPR model. For example, the i-PI will call the ab initio force engine to get the force (which will be used to update the GPR surrogate surface) or call machine learning code (GPR) to get machine learned force for geometry optimization or NEB optimization.  I checked the documentation and my impression is that the i-PI code can only compute 1 total force for ring polymer beads, but I want to access separate force components from the ab-initio force field and GPR code.

My question is: is there any easy ways to get it from current version of i-PI or do I have to modify the code? Thanks.

Best,
Chenghao Zhang.

Michele Ceriotti

unread,
May 17, 2025, 9:33:11 AMMay 17
to ipi-users
Hello Chenghao. 

     It is actually extremely easy to have several engine -> i-PI communications, look into the examples/features folder.

For instance, you can do

```
  <ffsocket name='lmpserial1' mode='unix'>
    <address>h2o-pimd+rpc_short</address>
  </ffsocket>
  <ffsocket name='lmpserial2' mode='unix'>
    <address>h2o-pimd+rpc_long</address>
  </ffsocket>
  <system>
    <forces>
      <force nbeads='32' forcefield='lmpserial1'/>
      <force nbeads='5' forcefield='lmpserial2'/>
    </forces>
    [...]
</system>
```

to have two engines compte short and long-range forces to do ring polymer contraction. 

Also, if you want to implement an external force engine that is written in pytorch, look at the `ipi/pes` folder, that way you can use the external code with <ffdirect> and <ffsocket> + i-pi-py_driver.  `examples/client/metatensor` is a good example of how this can be used.

If you want DFT->i-PI->GPR (e.g. for active learning) this is not implemented, and would be non-trivial. 

Hope this helps
Michele

Chenghao Zhang

unread,
May 27, 2025, 11:53:44 AMMay 27
to ipi-users
Hi, Michele,
     Thanks for your quick response. The example folder looks useful and I will take a look. I agree the active learning protocol will be non-trivial since this may require rewriting the i-PI socket. Do you and other developers have the plan to include active learning in the i-PI or you think this will be too much work to do?  Thank you.

Best,
Chenghao.

Michele Ceriotti

unread,
May 27, 2025, 12:37:13 PMMay 27
to ipi-users
If I were to start, I would look into the scripting API we've been developing. 
It's much more flexible and I think it'd be quite easy to implement an on-the-fly mechanism by hijacking the MD step, similar to what we're doing here https://atomistic-cookbook.org/examples/flashmd/flashmd-demo.html
Cheers
Michele

Chenghao Zhang

unread,
Jun 5, 2025, 4:55:07 PMJun 5
to ipi-users
Hi, Michele,
     Thanks. The utils/scripting.py script is very helpful.  I can see how in principle we can use this file to do active learning by pausing the i-PI code and update the ML model. Thanks.

Best,
Chenghao.

Reply all
Reply to author
Forward
0 new messages