Skip to content

mindtorch_v2: unify 43 backward ops to device-agnostic redispatch#2760

Merged
lvyufeng merged 1 commit into
candle-org:masterfrom
lvyufeng:worktree-npu-backward-large-kernels
Mar 8, 2026
Merged

mindtorch_v2: unify 43 backward ops to device-agnostic redispatch#2760
lvyufeng merged 1 commit into
candle-org:masterfrom
lvyufeng:worktree-npu-backward-large-kernels

Conversation

@lvyufeng

@lvyufeng lvyufeng commented Mar 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Eliminate 43 device.type == "npu" guards from backward functions in autograd.py, converting to device-agnostic redispatch composites
  • 22 A-YES ops (relu, sigmoid, softmax, etc.): delete ACLNN guard, keep existing redispatch code
  • 21 B ops (diagonal, tensordot, cdist, etc.): delete ACLNN guard and numpy fallback, keep only redispatch composite
  • Follows PyTorch architecture: backward formulas route through dispatch system automatically — no manual device branching
  • Fix CPU reshape to support -1 dimension inference (matching PyTorch behavior)
  • Fix 6 redispatch("to", ...) calls missing required device positional argument
  • Net reduction of ~675 lines (deleted 1095, added 420)
  • Remaining 20 device guards are Phase 2 (conv, pool2d/3d, upsample, grid_sample — need ACLNN large kernels)

Test plan

  • pylint-check passes
  • mindtorch-v2-test passes

🤖 Generated with Claude Code

…ase 1)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lvyufeng lvyufeng force-pushed the worktree-npu-backward-large-kernels branch from b4ea999 to 4234085 Compare March 8, 2026 08:45
@lvyufeng lvyufeng merged commit 7dd3e35 into candle-org:master Mar 8, 2026
3 checks passed
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