Skip to content
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

[Bug] Sparse example graph_transformer.py crashed #6423

Closed
chang-l opened this issue Oct 10, 2023 · 0 comments
Closed

[Bug] Sparse example graph_transformer.py crashed #6423

chang-l opened this issue Oct 10, 2023 · 0 comments
Assignees

Comments

@chang-l
Copy link
Collaborator

chang-l commented Oct 10, 2023

🐛 Bug

Hi, I found one of the SparseAPI -related example crashed due to this function:

def lap_pe(g, k, padding=False, return_eigval=False):
.

Details attached below...

To Reproduce

Steps to reproduce the behavior:

python examples/sparse/graph_transformer.py 

Output error:

Traceback (most recent call last):
  File "/workspace/examples/SparseAPI/graph_transformer.py", line 184, in <module>
    g.ndata["PE"] = dgl.lap_pe(g, k=pos_enc_size, padding=True)
  File "/usr/local/lib/python3.10/dist-packages/dgl/transforms/functional.py", line 3703, in lap_pe
    eigvals = F.tensor(topk_EigVal, dtype=F.float32)
UnboundLocalError: local variable 'topk_EigVal' referenced before assignment

Environment

  • DGL Version (e.g., 1.0): 1.1
  • Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3): PyTorch
  • OS (e.g., Linux): Ubuntu 22.04
  • How you installed DGL (conda, pip, source): source
  • GPU models and configuration (e.g. V100): A5000

Additional context

This may be due to missing to define topk_EigVal in the following conditional block:

if k + 1 < n - 1:
# Use scipy if k + 1 < n - 1 for memory efficiency.
EigVal, EigVec = scipy.sparse.linalg.eigs(
L, k=k + 1, which="SR", tol=1e-2
)
topk_indices = EigVal.argsort()[1:]
# Since scipy may return complex value, to avoid crashing in NN code,
# convert them to real number.
topk_eigvals = EigVal[topk_indices].real
topk_EigVec = EigVec[:, topk_indices].real

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants