gtn-org / gtn

Automatic differentiation with weighted finite-state transducers.
MIT License
118 stars 12 forks source link

Python test failed #34

Open jasonppy opened 2 years ago

jasonppy commented 2 years ago

Hi,

Since I couldn't get gtn to compile with cuda (see our conversation in this issue), I turned off all CUDA related options. Specifically, I changed https://github.com/gtn-org/gtn/blob/master/CMakeLists.txt#L17 to OFF, and deleted https://github.com/gtn-org/gtn/blob/master/bindings/python/CMakeLists.txt#L28.

With the above changes, running

mkdir -p build && cd build
cmake ..
make -j $(nproc)

were successful

and running

cd bindings/python
conda install setuptools
python setup.py develop

were also successful,

However, when running

python -m unittest discover bindings/python/test

I also commented https://github.com/gtn-org/gtn/blob/master/bindings/python/gtn/init.py#L21, and delete ./bindings/python/test/test_cuda.py

I got output:

...F................................F...........
======================================================================
FAIL: test_forward_score_grad (test_autograd.AutogradTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pyp/gtn/bindings/python/test/test_autograd.py", line 261, in test_forward_score_grad
    self.assertTrue(math.isnan(grad_weights[0]))
AssertionError: False is not true

======================================================================
FAIL: test_forward (test_functions.FunctionsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pyp/gtn/bindings/python/test/test_functions.py", line 217, in test_forward
    self.assertRaises(ValueError, gtn.forward_score, g)
AssertionError: ValueError not raised by forward_score

----------------------------------------------------------------------
Ran 48 tests in 0.158s

FAILED (failures=2)

Thanks for your time!

j0ma commented 2 years ago

I'm seeing this as well. Just got the same error after building successfully with CUDA bindings:

(gtn-test) [user@host gtn]$ python -m unittest discover bindings/python/test
test_autograd (test_autograd.AutogradTestCase) ... ok
test_clone_project_grad (test_autograd.AutogradTestCase) ... ok
test_compose_grad (test_autograd.AutogradTestCase) ... ok
test_forward_score_grad (test_autograd.AutogradTestCase) ... FAIL
test_grad_available (test_autograd.AutogradTestCase) ... ok
test_sample_grad (test_autograd.AutogradTestCase) ... ok
test_scalar_ops_grad (test_autograd.AutogradTestCase) ... ok
test_viterbi_path_grad (test_autograd.AutogradTestCase) ... ok
test_viterbi_score_grad (test_autograd.AutogradTestCase) ... ok
test_calc_grad (test_bindings.AutogradTestCase) ... ok
test_input_grad (test_bindings.AutogradTestCase) ... ok
test_retain_graph (test_bindings.AutogradTestCase) ... ok
test_device (test_bindings.DeviceTesetCase) ... ok
test_scalar_ops (test_bindings.FunctionsTestCase) ... ok
test_comparisons (test_bindings.GraphTestCase) ... ok
test_graph_basic (test_bindings.GraphTestCase) ... ok
test_graph_weights_get (test_bindings.GraphTestCase) ... ok
test_graph_weights_set (test_bindings.GraphTestCase) ... ok
test_save_load (test_bindings.GraphTestCase) ... ok
test_scalar_graph (test_bindings.GraphTestCase) ... ok
test_backward_calls_once (test_bindings.ParallelTestCase) ... ok
test_default_args (test_bindings.ParallelTestCase) ... ok
test_parallel_backward (test_bindings.ParallelTestCase) ... ok
test_parallel_func (test_bindings.ParallelTestCase) ... ok
test_parallel_one_arg (test_bindings.ParallelTestCase) ... ok
test_parallel_two_arg (test_bindings.ParallelTestCase) ... ok
test_parallel_vector_arg (test_bindings.ParallelTestCase) ... ok
test_linear_creation (test_creations.CreationsTestCase) ... ok
test_scalar_creation (test_creations.CreationsTestCase) ... ok
test_asg_criterion (test_criterions.CriterionsTestCase) ... ok
test_asg_viterbi_path (test_criterions.CriterionsTestCase) ... ok
test_ctc_criterion (test_criterions.CriterionsTestCase) ... ok
test_cuda (test_cuda.CudaTestCase) ... ok
test_graph_cuda (test_cuda.CudaTestCase) ... ok
test_graph_nocuda (test_cuda.CudaTestCase) ... skipped 'CUDA available'
test_closure (test_functions.FunctionsTestCase) ... ok
test_composition (test_functions.FunctionsTestCase) ... ok
test_concat (test_functions.FunctionsTestCase) ... ok
test_epsilon_composition (test_functions.FunctionsTestCase) ... ok
test_forward (test_functions.FunctionsTestCase) ... FAIL
test_project_clone (test_functions.FunctionsTestCase) ... ok
test_remove (test_functions.FunctionsTestCase) ... ok
test_scalar_ops (test_functions.FunctionsTestCase) ... ok
test_sum (test_functions.FunctionsTestCase) ... ok
test_viterbi_path (test_functions.FunctionsTestCase) ... ok
test_viterbi_score (test_functions.FunctionsTestCase) ... ok
test_equality (test_utils.UtilsTestCase) ... ok
test_isomorphic (test_utils.UtilsTestCase) ... ok
test_loadsave (test_utils.UtilsTestCase) ... ok
test_loadtxt (test_utils.UtilsTestCase) ... ok
test_savetxt (test_utils.UtilsTestCase) ... ok

======================================================================
FAIL: test_forward_score_grad (test_autograd.AutogradTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home1/js_439/gtn/bindings/python/test/test_autograd.py", line 261, in test_forward_score_grad
    self.assertTrue(math.isnan(grad_weights[0]))
AssertionError: False is not true

======================================================================
FAIL: test_forward (test_functions.FunctionsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home1/js_439/gtn/bindings/python/test/test_functions.py", line 217, in test_forward
    self.assertRaises(ValueError, gtn.forward_score, g)
AssertionError: ValueError not raised by forward_score

----------------------------------------------------------------------
Ran 51 tests in 2.538s

FAILED (failures=2, skipped=1)
j0ma commented 2 years ago

@jasonppy Are you seeing any errors coming up as a result of these failing tests when using the library?

I just checked and the "simple example graph" example works as intended:

python bindings/python/examples/simple_graph.py