Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix devices_list type validation error in TrainerConfig #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
Copilot wants to merge 4 commits into main
base: main
Choose a base branch
Loading
from copilot/fix-123ed987-1fd8-4fa0-b9f0-6e6abcb6ff12

Conversation

Copy link

Copilot AI commented Oct 5, 2025
edited
Loading

Problem

When specifying devices_list in TrainerConfig, users encountered an OmegaConf validation error:

from pytorch_tabular.config import TrainerConfig
from omegaconf import OmegaConf
# This fails with ValidationError
trainer_config = TrainerConfig(devices_list=[1, 2, 3, 4])
config = OmegaConf.structured(trainer_config)

Error:

omegaconf.errors.ValidationError: Value '[1, 2, 3, 4]' of type 'list' could not be converted to Integer
 full_key: devices
 object_type=TrainerConfig

Root Cause

The devices field in TrainerConfig was typed as Optional[int], but the __post_init__ method assigns the devices_list (a list) to devices when provided. When OmegaConf wraps the config with OmegaConf.structured(), it validates types and rejects the list assignment.

Solution

Changed the type annotation of the devices field from Optional[int] to Any. This approach:

  • Allows both integer and list values, matching PyTorch Lightning's Trainer API which accepts both
  • Works correctly with OmegaConf (note: Union[int, List[int]] is not supported by OmegaConf for container types)
  • Maintains full backward compatibility with existing code

Changes

src/pytorch_tabular/config/config.py:

  • Changed devices field type from Optional[int] to Any
  • Updated docstring to indicate devices accepts Union[int, List[int]]

tests/test_config.py (new file):

  • Added comprehensive test coverage for devices/devices_list functionality
  • Tests cover the documented use case (devices_list=[0, 1])
  • Tests verify backward compatibility with integer devices values
  • Tests validate config merging scenarios as used in TabularModel

Testing

All scenarios now work correctly:

# Multiple GPUs (from the issue)
TrainerConfig(devices_list=[1, 2, 3, 4]) # ✅ Works
# Documented example
TrainerConfig(devices_list=[0, 1]) # ✅ Works
# Backward compatibility
TrainerConfig(devices=2) # ✅ Still works
TrainerConfig() # ✅ Default devices=-1 still works

Backward Compatibility

✅ Fully backward compatible - all existing code using devices=<int> continues to work unchanged.

Fixes #issue_number

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • archive.ics.uci.edu
    • Triggering command: python -m pytest tests/test_config.py -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>devices and devices_list type issues</issue_title>
<issue_description>https://github.com/manujosephv/pytorch_tabular/blob/023db2776f96a0f2854e837eef62840be1a12a5e/src/pytorch_tabular/config/config.py#L565C9-L566C45

When specifying a devices_list, this line of code causes

omegaconf.errors.ValidationError: Value '[1, 2, 3, 4]' of type 'list' could not be converted to Integer
 full_key: devices
 object_type=TrainerConfig
```</issue_description>
## Comments on the Issue (you are @copilot in this section)
<comments>
</comments>
Fixes #576

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits October 5, 2025 01:07
Co-authored-by: manujosephv <10508493+manujosephv@users.noreply.github.com>
Co-authored-by: manujosephv <10508493+manujosephv@users.noreply.github.com>
Co-authored-by: manujosephv <10508493+manujosephv@users.noreply.github.com>
Copilot AI changed the title (削除) [WIP] devices and devices_list type issues (削除ここまで) (追記) Fix devices_list type validation error in TrainerConfig (追記ここまで) Oct 5, 2025
Copilot AI requested a review from manujosephv October 5, 2025 01:16
Copilot finished work on behalf of manujosephv October 5, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@manujosephv manujosephv Awaiting requested review from manujosephv

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

devices and devices_list type issues

2 participants

AltStyle によって変換されたページ (->オリジナル) /