Skip to content

[Feature]: scaledDotProductAttention backward β€” gradients currently stop at attentionΒ #1384

Open
0 of 4 issues completed

Description

@michalharakal

🧠 D: DOCUMENT β€” Problem & Opportunity

scaledDotProductAttentionBackward in skainet-compile/skainet-compile-dag/src/commonMain/kotlin/sk/ainet/lang/graph/DefaultExecutionTape.kt returns null for every input, so training any attention model silently produces no gradient for Q, K, V or anything upstream of them. It is now listed in stubbedBackwardOpNames and shows as ❌ stub in the Backward column of the coverage matrix.

Summary: implement the SDPA adjoint (dQ, dK, dV, honouring scale, causal and padding masks) so attention layers train.


πŸ” A: ASSESS β€” Feasibility & Impact


πŸ“š R: RESEARCH β€” What Must Be Understood First?

  • Derivation note covering every forward option (Lane 1)

πŸ› οΈ C: CODE β€” Implementation Plan

  • Implementation (Lane 2)
  • Gradient check (Lane 4)
  • Review (Lane 6)

Acceptance Criteria

  • Gradients match PyTorch autograd for torch.nn.functional.scaled_dot_product_attention on causal and non-causal cases
  • scaledDotProductAttention removed from stubbedBackwardOpNames; matrix Backward column shows βœ…

Lane breakdown

Lanes 0, 3 and 5 skipped.

New here? Read Getting started as a contributor and the Issue taxonomy. Lanes marked good first issue assume no prior SKaiNET codebase knowledge. The gap markers and the coverage matrix were introduced in #1370.

Metadata

Metadata

Assignees

No one assigned

    Labels

    darcFeature driven through the DARC workflow (Document / Assess / Research / Code)enhancementNew feature or requesttrackingParent/tracking issue with sub-issuestrainingTraining pipeline, optimizers, loss

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions