N3PDF / vegasflow

VegasFlow: accelerating Monte Carlo simulation across multiple hardware platforms
https://vegasflow.readthedocs.io
Apache License 2.0
34 stars 9 forks source link

Simplifying signature not working for PlainFlow #73

Closed c-rohrbach closed 3 years ago

c-rohrbach commented 3 years ago

Description

I'm trying to run an integration using PlainFlow on a function that only takes the data tensor as an argument. To achieve this, I'm passing the keyword simplify_signature=True to the constructor. However, this leads to an error about unexpected arguments, which is the same output as when the keyword is omitted.

I'm assuming this is a bug, since the docs mention the keyword explicitly (https://vegasflow.readthedocs.io/en/latest/intalg.html?highlight=simplify_signature#id2) and it works without issue for the VegasFlow constructor.

Code example

import tensorflow as tf
from vegasflow import PlainFlow

def integrand(x):
    return tf.reduce_prod(x, axis=1)

vegas_instance = PlainFlow(4, int(1e4), simplify_signature=True)
vegas_instance.compile(integrand)
vegas_instance.run_integration(5)

This produces the following error

TypeError: integrand(x) got unexpected keyword argument `n_dim`

Additional information

I'm running on CPU with the following versions Vegasflow: 1.2.0 Tensorflow: 2.5.0

scarlehoff commented 3 years ago

Thanks for the tip! It is a bug indeed.

In order to fix it I'm trying to add an autodiscover feature that should remove also the need for simplify_signature and it should be ready later this week. In the meantime you can add a **kwargs argument to the function.

The fixed version will probably release as 1.2.2.

Thanks for the report!