sunode icon indicating copy to clipboard operation
sunode copied to clipboard

Getting test script to run

Open aarcher07 opened this issue 3 years ago • 7 comments

Hi,

I've been using sunode for over 2 months now. It's a great project and I've really benefited from the speed.

I'm interested in using sunode with pyMC4. I ran the test script in the readMe and recieved a strange error that I'm not sure how to fix.

Traceback (most recent call last):
    idata = pm.sample(tune=1000, draws=1000, chains=6, cores=6)
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/pymc/sampling.py", line 524, in sample
    step = assign_step_methods(model, step, methods=pm.STEP_METHODS, step_kwargs=kwargs)
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/pymc/sampling.py", line 215, in assign_step_methods
    tg.grad(model_logp, var)
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 635, in grad
    rval = _populate_grad_dict(var_to_app_to_idx, grad_dict, wrt, cost_name)
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1440, in _populate_grad_dict
    rval = [access_grad_cache(elem) for elem in wrt]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1440, in <listcomp>
    rval = [access_grad_cache(elem) for elem in wrt]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1393, in access_grad_cache
    term = access_term_cache(node)[idx]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1064, in access_term_cache
    output_grads = [access_grad_cache(var) for var in node.outputs]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1064, in <listcomp>
    output_grads = [access_grad_cache(var) for var in node.outputs]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1393, in access_grad_cache
    term = access_term_cache(node)[idx]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1064, in access_term_cache
    output_grads = [access_grad_cache(var) for var in node.outputs]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1064, in <listcomp>
    output_grads = [access_grad_cache(var) for var in node.outputs]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1393, in access_grad_cache
    term = access_term_cache(node)[idx]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1064, in access_term_cache
    output_grads = [access_grad_cache(var) for var in node.outputs]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1064, in <listcomp>
    output_grads = [access_grad_cache(var) for var in node.outputs]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1393, in access_grad_cache
    term = access_term_cache(node)[idx]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1064, in access_term_cache
    output_grads = [access_grad_cache(var) for var in node.outputs]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1064, in <listcomp>
    output_grads = [access_grad_cache(var) for var in node.outputs]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1393, in access_grad_cache
    term = access_term_cache(node)[idx]
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/gradient.py", line 1219, in access_term_cache
    input_grads = node.op.L_op(inputs, node.outputs, new_output_grads)
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/graph/op.py", line 371, in L_op
    return self.grad(inputs, output_grads)
  File "/home/aarcher/research/pdo_pathway_pymc/sunode/sunode/wrappers/as_aesara.py", line 261, in grad
    lamda, gradient = backward(y0, params, params_fixed, g)
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/graph/op.py", line 296, in __call__
    node = self.make_node(*inputs, **kwargs)
  File "/home/aarcher/anaconda3/envs/pymc_env/lib/python3.10/site-packages/aesara/graph/op.py", line 240, in make_node
    raise TypeError(
TypeError: Invalid input types for Op SolveODEAdjointBackward{_solver_id=140214287550256, _t0=1900, _tvals_id=140214298068912}:
Input 3/4: Expected TensorType(float64, (None,)), got TensorType(float64, (1,))

Your help would be much appreciated. Thank you in advance!

aarcher07 avatar Jun 23 '22 21:06 aarcher07

Can you share an example that produces this error? That would make it easier to debug.

aseyboldt avatar Jun 23 '22 21:06 aseyboldt

Oh, sorry you said it's the example from the readme, my mistake...

aseyboldt avatar Jun 23 '22 21:06 aseyboldt

Thank you for the report, I can reproduce this issue. I think this was introduced by a small change in the behavior of the Op.make_node function in aesara, I'll have to experiment a bit more for a fix though.

aseyboldt avatar Jun 23 '22 21:06 aseyboldt

Thank you for your quick response!

aarcher07 avatar Jun 24 '22 00:06 aarcher07

Should be fixed if https://github.com/aesara-devs/aesara/pull/1010 gets merged

aseyboldt avatar Jun 24 '22 08:06 aseyboldt

The PR in aesara is merged now, so if you use the development version this should work now. If you have any more trouble with this (or installing the dev version) just ping me again. I'll leave the issue open for now until the next release of aesara.

aseyboldt avatar Jun 26 '22 16:06 aseyboldt

Great. Thanks!

aarcher07 avatar Jun 27 '22 15:06 aarcher07