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

(not urgent) single parameter optimization with workers fails #244

Open
pavankum opened this issue Sep 28, 2021 · 1 comment
Open

(not urgent) single parameter optimization with workers fails #244

pavankum opened this issue Sep 28, 2021 · 1 comment

Comments

@pavankum
Copy link
Contributor

pavankum commented Sep 28, 2021

Hi, nothing urgent about this but I noticed that single parameter optimization runs with workers fail with this error even before sending work to the worker jobs

Traceback (most recent call last):
  File "/dfs6/pub/pbehara/bin/conda/fb_env/bin/ForceBalance.py", line 45, in Run_ForceBalance
    optimizer.Run()
  File "/dfs6/pub/pbehara/bin/conda/fb_env/lib/python3.9/site-packages/forcebalance/optimizer.py", line 319, in Run
    xk = self.OptTab[self.jobtype]()
  File "/dfs6/pub/pbehara/bin/conda/fb_env/lib/python3.9/site-packages/forcebalance/optimizer.py", line 943, in NewtonRaphson
    return self.MainOptimizer(b_BFGS=0)
  File "/dfs6/pub/pbehara/bin/conda/fb_env/lib/python3.9/site-packages/forcebalance/optimizer.py", line 493, in MainOptimizer
    data        = self.Objective.Full(xk,Ord,verbose=True)
  File "/dfs6/pub/pbehara/bin/conda/fb_env/lib/python3.9/site-packages/forcebalance/objective.py", line 313, in Full
    Objective = self.Target_Terms(vals, Order, verbose, customdir)
  File "/dfs6/pub/pbehara/bin/conda/fb_env/lib/python3.9/site-packages/forcebalance/objective.py", line 216, in Target_Terms
    Tgt.stage(mvals, AGrad = Order >= 1, AHess = Order >= 2, customdir=customdir)
  File "/dfs6/pub/pbehara/bin/conda/fb_env/lib/python3.9/site-packages/forcebalance/target.py", line 637, in stage
    self.submit_jobs(mvals, AGrad, AHess)
  File "/dfs6/pub/pbehara/bin/conda/fb_env/lib/python3.9/site-packages/forcebalance/target.py", line 789, in submit_jobs
    self.serialize_ff(mvals, outside="forcefield-remote")
  File "/dfs6/pub/pbehara/bin/conda/fb_env/lib/python3.9/site-packages/forcebalance/target.py", line 745, in serialize_ff
    if len(mvalsf) > 0 and np.max(np.abs(mvals - mvalsf)) != 0.0:
TypeError: len() of unsized object

the same input works fine when run directly without any worker jobs. Also, it works if I optimize two parameters instead of one. Attached a minimal example for testing. I tested this with 1.8.1, 1.9.0 and the latest release and it fails in all.
forcebalance.zip

@trevorgokey
Copy link

Just ran into this; the issue is that if there is only one value in the mvals.txt file, np.loadtxt will create an "array" that holds only a scalar, and has no shape or len. The fix is to change the line to np.loadtxt("mvals.txt", ndmin=1).

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

No branches or pull requests

2 participants