Skip to content

Duplicate and incomplete definitions of _graph_nodes and grad_check #8

Description

@github-actions

File: leanpass/tensor.py

The file defines _graph_nodes and grad_check twice. The second definitions overwrite the first ones, but the second grad_check is truncated (numeric[node] = ) and contains several bugs (calls node.zero_grad_all(), uses undefined self.zero_grad_all(), mismatched return types). This makes the gradient‑checking utility unusable and may silently break other code that expects the original implementation.

Fix: Remove the duplicated definitions. Keep a single, correct implementation of _graph_nodes (the first one is fine) and a complete, tested grad_check that:

  • Uses self.zero_grad_all() to clear grads.
  • Computes numerical gradients correctly (e.g., using np.sum(plus) - np.sum(minus) for scalar outputs).
  • Returns a list of error tuples as documented.

File: leanpass/tensor.py

Filed automatically by ai-issue-scan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions