google / TensorNetwork

A library for easy and efficient manipulation of tensor networks.
Apache License 2.0
1.82k stars 359 forks source link

Autograph issues #137

Open chaserileyroberts opened 5 years ago

chaserileyroberts commented 5 years ago

When tf.function(autograph=True), the compile times for code that uses contract_between skyrockets. This is bad because autograph=True is the default for tensorflow>=1.14.0.

We need to figure out where the bug lies, either on our end or on the tensorflow end.

amilsted commented 5 years ago

The output suggests that autograph can't handle calls to contract_between: It throws a warning and falls back to non-autograph tracing.

WARNING: Entity <bound method TensorNetwork.contract_between of <tensornetwork.network.TensorNetwork object at 0x7f727b370898>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method TensorNetwork.contract_between of <tensornetwork.network.TensorNetwork object at 0x7f727b370898>>: AssertionError: Early stopping (e.g. break and/or return) should create state variables.

Possibly the error handling is causing overhead? Probably we can find out what's slow using cProfile.

PS: I think the default changed for tf.contrib.eager.defun(), but IIRC tf.function() also defaulted to autograph=True with 1.13.

chaserileyroberts commented 5 years ago

Is there a way to make this a failing test?

amilsted commented 5 years ago

Yes, we can test for these log messages: https://docs.pytest.org/en/latest/logging.html

tralfamadude commented 5 years ago

What is the impact of this bug? Is it harmless to correctness?