Repository: pykeen/pykeen
Issue: Runtime error upon using whitelist
Root cause: External Dependency Breakage

Hello!

I created a list of relations I needed yet when I tried to pass it as an argument to pipeline I got an unexpected error:
`RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.`

Setup

```tf = TriplesFactory.from_path('graph.tsv')
training, validation, testing = tf.split([.8, .1, .1])

complEx = pipeline(
    training=training,
    testing=testing,
    validation=validation,
    stopper='early',
    model_kwargs = dict(embedding_dim=256),
    training_kwargs = dict(num_epochs=10),
    negative_sampler = 'basic',
    evaluation_relation_whitelist=['what detail?', 'what work?'],
    device='gpu',
    model='ComplEx'
)
```

Traceback:

```
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_318/4226793396.py in <module>
     10     evaluation_relation_whitelist=['what detail?', 'what work?'],
     11     device='gpu',
---> 12     model='ComplEx'
     13 )

/home/user/conda/lib/python3.7/site-packages/pykeen/pipeline/api.py in pipeline(dataset, dataset_kwargs, training, testing, validation, evaluation_entity_whitelist, evaluation_relation_whitelist, model, model_kwargs, interaction, interaction_kwargs, dimensions, loss, loss_kwargs, regularizer, regularizer_kwargs, optimizer, optimizer_kwargs, clear_optimizer, lr_scheduler, lr_scheduler_kwargs, training_loop, training_loop_kwargs, negative_sampler, negative_sampler_kwargs, epochs, training_kwargs, stopper, stopper_kwargs, evaluator, evaluator_kwargs, evaluation_kwargs, result_tracker, result_tracker_kwargs, metadata, device, random_seed, use_testing_data, evaluation_fallback, filter_validation_when_testing, use_tqdm)
    891         testing = testing.new_with_restriction(
    892             entities=evaluation_entity_whitelist,
--> 893             relations=evaluation_relation_whitelist,
    894         )
    895         if validation is not None:

/home/user/conda/lib/python3.7/site-packages/pykeen/triples/triples_factory.py in new_with_restriction(self, entities, relations, invert_entity_selection, invert_relation_selection)
    974             relations=relations,
    975             invert_entity_selection=invert_entity_selection,
--> 976             invert_relation_selection=invert_relation_selection,
    977         ).with_labels(entity_to_id=self.entity_to_id, relation_to_id=self.relation_to_id)
    978 

/home/user/conda/lib/python3.7/site-packages/pykeen/triples/triples_factory.py in new_with_restriction(self, entities, relations, invert_entity_selection, invert_relation_selection)
    584 
    585         num_triples = keep_mask.sum()
--> 586         logger.info(f"keeping {format_relative_comparison(num_triples, self.num_triples)} triples.")
    587         return self.clone_and_exchange_triples(
    588             mapped_triples=self.mapped_triples[keep_mask],

/home/user/conda/lib/python3.7/site-packages/pykeen/utils.py in format_relative_comparison(part, total)
    476 ) -> str:
    477     """Format a relative comparison."""
--> 478     return f"{part}/{total} ({part / total:2.2%})"
    479 
    480 

RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future release div will perform true division as in Python 3. Use true_divide or floor_divide (// in Python) instead.

```

Pykeen.env()

```
Key	Value
OS	posix
Platform	Linux
Release	4.15.0-47-generic
Time	Thu Aug 19 15:26:43 2021
Python	3.7.10
PyKEEN	1.5.1-dev
PyKEEN Hash	UNHASHED
PyKEEN Branch	
PyTorch	1.6.0+cu101
CUDA Available?	true
CUDA Version	10.1
cuDNN Version	7603

```

Hi @tatiana-iazykova ,

do you get the same error when running this smaller snippet without custom data?

```python
from pykeen.pipeline import pipeline

result = pipeline(
    dataset="nations",
    model="complex",
    evaluation_relation_whitelist=['accusation', 'aidenemy'],
)
```

Yes, the issue is the same when running this snippet

Okay, on my local machine with the latest version of pykeen & torch this does not occur. I think the reason is that
https://github.com/pykeen/pykeen/blob/7a87578f9bdb8fef28307bac1c037e0c177eee7a/src/pykeen/triples/triples_factory.py#L585
is a tensor rather than a Python object, and fixed this in #575.

Could you try whether this fixes your problem?

To install pykeen with the code from this specific branch you can use:
```console
$ pip install git+https://github.com/pykeen/pykeen.git@fix-logging-tensors-in-split
```

upgrading torch alongside with installing this brach helped, thanks!

@mberr do we have a minimum supported pytorch at the moment?

> @mberr do we have a minimum supported pytorch at the moment?

no:
https://github.com/pykeen/pykeen/blob/fbd14135217c08f30bc121a3eca33e2c4d90b010/setup.cfg#L59

With #575 the problem should also be fixed for earlier Pytorch versions.