Training gives hundreds of UserWarning messages "deprecated torch.uint8"

When training KnowBert I get hundreds of warnings

/pytorch/aten/src/ATen/native/cuda/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.

I modified some files in KnowBert that were using torch.uint8 for the mask and replaced them with torch.bool, so now there is no explicit usage of torch.uint8, but I still get the user warning messages. Do you have any idea what could cause the errors?

My version of pytorch is 1.2.0, allennlp is 0.8.3-unreleased

I believe we fixed those warnings in our 0.9 release. Can you upgrade and see if the issue is still there? The main problem is that 0.8.3 is not compatible with pytorch 1.2.

I upgraded allennlp to version 0.9.0 as you suggested, but I still get the error messages. I am also using python 3.6.7

Do you have a way of tracking down what line in python code is causing the errors? Without that it’s pretty hard to know how to help, unfortunately.

Another avenue is to run our tests on a local checkout of allennlp and see if the warnings are thrown. If you can give a specific test where the warning appears, we’d have an easier time digging into what’s going on.

I ran the tests twice using allennlp version 0.9.0 and torch 1.2.0, and also with allennlp version 0.8.5 and torch 1.1.0 and I got the same warnings for the same test.
Here’s the warning traceback:

tests/test_knowbert.py::TestEntityDisambiguator::test_entity_disambiguator
tests/test_knowbert.py::TestEntityLinkingWithCandidateMentions::test_entity_linking
tests/test_knowbert.py::TestSolderedKG::test_soldered_kg
tests/test_knowbert.py::TestKnowBert::test_knowbert_el
tests/test_knowbert.py::TestKnowBert::test_knowbert_el
tests/test_knowbert.py::TestKnowBert::test_knowbert_el_pretrain
tests/test_knowbert.py::TestKnowBert::test_knowbert_el_pretrain
tests/test_knowbert.py::TestKnowBert::test_knowbert_simple
tests/test_knowbert.py::TestKnowBert::test_knowbert_simple
tests/test_knowbert.py::TestKnowBertWikiWordnet::test_knowbert_wiki_wordnet
tests/test_knowbert.py::TestKnowBertWikiWordnet::test_knowbert_wiki_wordnet
tests/test_knowbert.py::TestKnowBertWikiWordnet::test_knowbert_wiki_wordnet
tests/test_knowbert.py::TestKnowBertWikiWordnet::test_knowbert_wiki_wordnet
tests/evaluation/test_simple_classifier.py::TestSimpleClassifier::test_simple_classifier
tests/evaluation/test_simple_classifier.py::TestSimpleClassifier::test_simple_classifier
tests/evaluation/test_simple_classifier.py::TestSimpleClassifier::test_simple_classifier_bce_loss
tests/evaluation/test_simple_classifier.py::TestSimpleClassifier::test_simple_classifier_bce_loss
tests/evaluation/test_simple_classifier.py::TestSimpleClassifier::test_simple_classifier_with_concat_a_b
tests/evaluation/test_simple_classifier.py::TestSimpleClassifier::test_simple_classifier_with_concat_a_b
  /pytorch/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.

I ran our basic classifier tests on master in the main allennlp repo, and I did not see any such warnings. This looks like it’s something that’s specific to the knowbert repo, not allennlp; I’d suggest opening an issue on their github page.