MIND-Lab / OCTIS

OCTIS: Comparing Topic Models is Simple! A python package to optimize and evaluate topic models (accepted at EACL2021 demo track)
MIT License
718 stars 102 forks source link

Improvements to Null Checks and Device Assignment in LSI and ETM Models #126

Open XavierSpycy opened 3 months ago

XavierSpycy commented 3 months ago

Description

This pull request addresses two main issues found in the models.LSI and models.ETM modules.

Changes Made

  1. Improved Null Checks in models.LSI:

    • Updated comparisons from == None to is None in two locations within the models.LSI module. This change ensures a more reliable and Pythonic way of handling null checks.
  2. Refined Device Assignment in models.ETM:

    • Addressed three specific device assignment issues:
      • CPU Use on CUDA-capable Devices: Even when the device parameter was explicitly set to 'cpu' on CUDA-capable devices, the model was still being assigned to a GPU. This has been corrected to respect the user's device preference.
      • GPU Selection on Multi-GPU Systems: Previously, specifying a particular GPU (e.g., 'cuda:1') on systems with multiple GPUs incorrectly defaulted to the first GPU due to automatic checks and assignments. This update ensures that the specified GPU is used as intended.
      • MPS Acceleration on Apple Devices: On Apple machines supporting 'mps', attempting to use MPS acceleration would default to 'cpu' when 'cuda' was unavailable. This behavior has been adjusted to properly recognize and utilize 'mps' if specified.

Rationale

These updates enhanced the usability and functionality of the affected models. By ensuring that null checks are more robust and device assignments adhere to user specifications, we can provide a more predictable and efficient user experience.