Skip to content

Add device movement tests for all tab_network modules#276

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/add-simple-tests-tab-network
Closed

Add device movement tests for all tab_network modules#276
Copilot wants to merge 2 commits intomainfrom
copilot/add-simple-tests-tab-network

Conversation

Copy link
Contributor

Copilot AI commented Nov 2, 2025

Following the pattern in test_tabnet_encoder.py:273-294, adds device movement tests for each nn.Module in tab_network to verify correct behavior when models are moved to different devices (CPU, CUDA, MPS).

Changes

Added test_*_device_movement() functions to 10 test files:

  • test_attentive_transformer.py
  • test_embedding_generator.py
  • test_feat_transformer.py
  • test_gbn.py
  • test_glu.py (covers both GLU_Layer and GLU_Block)
  • test_random_obfuscator.py
  • test_tabnet.py
  • test_tabnet_decoder.py
  • test_tabnet_noembeddings.py
  • test_tabnet_pretraining.py

Each test instantiates the module, moves it and input tensors to an available device, and executes a forward pass:

def test_tabnet_device_movement():
    """Test that TabNet moves to the correct device with the model."""
    tabnet = TabNet(input_dim=16, output_dim=8, n_d=8, n_a=8, n_steps=3, ...)
    
    device = torch.device("cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu")
    tabnet = tabnet.to(device)
    x = torch.rand((2, 16)).to(device)
    
    out, M_loss = tabnet.forward(x)
    assert out.shape == (2, 8)

Coverage

11 new tests added (13 total device tests including existing ones in test_tabnet_encoder.py).

Original prompt

On test_tabnet_encoder.py:273-294, this test, test model device switch (if avalable) converted correctly. create similar simple test for each of the modues in tab_network


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com>
Copilot AI changed the title [WIP] Add simple tests for tab network modules Add device movement tests for all tab_network modules Nov 2, 2025
Copilot AI requested a review from DanielAvdar November 2, 2025 13:32
@DanielAvdar DanielAvdar closed this Nov 2, 2025
@DanielAvdar DanielAvdar deleted the copilot/add-simple-tests-tab-network branch November 2, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments