Skip to content

Fix #10627: post_step clamping process doesn't preserve training labe...#10656

Open
JiwaniZakir wants to merge 2 commits into
pyg-team:masterfrom
JiwaniZakir:fix/10627-post-step-clamping-process-doesn-t-prese
Open

Fix #10627: post_step clamping process doesn't preserve training labe...#10656
JiwaniZakir wants to merge 2 commits into
pyg-team:masterfrom
JiwaniZakir:fix/10627-post-step-clamping-process-doesn-t-prese

Conversation

@JiwaniZakir
Copy link
Copy Markdown
Contributor

Closes #10627

The default post_step in LabelPropagation.forward (torch_geometric/nn/models/label_prop.py) clamped propagated values to [0, 1] but did not restore labeled node values afterward, causing training labels to be overwritten and collapsing class evidence at high-degree nodes. After the out.clamp_(0., 1.) call, labeled node outputs are now reset to their original one-hot values via out[mask] = y[mask] when mask is not None.

  • torch_geometric/nn/models/label_prop.pyLabelPropagation.forward: added two lines after the default clamp to restore out[mask] from y[mask]
  • test/nn/models/test_label_prop.pytest_label_prop: added a regression case using a star graph with 6 class-0 and 2 class-1 labeled neighbors aggregating into a single unlabeled hub node, asserting torch.allclose(out2[mask2], y2_oh[mask2].float())

The fix is verified by the new test, which previously failed because the labeled nodes' outputs diverged from their one-hot targets after clamping.


This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 3, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10656      +/-   ##
==========================================
- Coverage   86.11%   83.94%   -2.17%     
==========================================
  Files         496      510      +14     
  Lines       33655    36024    +2369     
==========================================
+ Hits        28981    30240    +1259     
- Misses       4674     5784    +1110     

☔ 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.

post_step clamping process doesn't preserve training labels in LabelPropagation

1 participant