Skip to content

Conversation

@drivanov
Copy link
Contributor

@drivanov drivanov commented Nov 15, 2025

The test_to_hetero_lazy_cuda occasionally triggers the following warning:

  /usr/local/lib/python3.12/dist-packages/torch_geometric/nn/to_hetero_transformer.py:151: UserWarning: There exist 
node types ({'v0'}) whose representations do not get updated during message passing as they do not occur as destination 
type in any edge type. This may lead to unexpected behavior.

This warning can nondeterministically escalate into an AttributeError, causing the test to fail:

====================== FAILURES ======================
________________ test_to_hetero_lazy_cuda _________________

    @onlyCUDA
    def test_to_hetero_lazy_cuda():
        class Model(torch.nn.Module):
            def __init__(self):
                super().__init__()
                self.conv = GATv2Conv(
                    (-1, -1),
                    out_channels=2,
                    add_self_loops=False,
                    edge_dim=-1,
                    heads=1,
                ).to('cuda')
    
            def forward(self, x, edge_index, edge_attr):
                return self.conv(x, edge_index, edge_attr)
    
        data = FakeHeteroDataset(edge_dim=10)[0].to('cuda')
        model = to_hetero(Model(), data.metadata())
        out_dict = model(data.x_dict, data.edge_index_dict, data.edge_attr_dict)
        assert len(out_dict) == len(data.node_types)
        for out in out_dict.values():
>           assert out.is_cuda
E           AttributeError: 'NoneType' object has no attribute 'is_cuda'

test/nn/test_to_hetero_transformer.py:564: AttributeError

The root cause is that the synthetic FakeHeteroDataset includes a node type (v0) that never appears as a destination in any edge type, so its representation is never updated. This fix ensures that all node types participate as destinations (via self-loop edges), preventing the warning and stabilizing the test.

Solution originated from ChatGPT guidance.

@codecov
Copy link

codecov bot commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.08%. Comparing base (c211214) to head (c3355aa).
⚠️ Report is 137 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10531      +/-   ##
==========================================
- Coverage   86.11%   85.08%   -1.03%     
==========================================
  Files         496      510      +14     
  Lines       33655    35962    +2307     
==========================================
+ Hits        28981    30600    +1619     
- Misses       4674     5362     +688     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant