Skip to content

[SR-12175] Fix forward-mode class differentiation crash #54600

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

Closed
Tracked by #52130
dan-zheng opened this issue Feb 11, 2020 · 2 comments
Closed
Tracked by #52130

[SR-12175] Fix forward-mode class differentiation crash #54600

dan-zheng opened this issue Feb 11, 2020 · 2 comments
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software SILOptimizer Area → compiler: SIL optimization passes swift 5.2

Comments

@dan-zheng
Copy link
Contributor

dan-zheng commented Feb 11, 2020

Previous ID SR-12175
Radar rdar://problem/59496016
Original Reporter @dan-zheng
Type Sub-task
Additional Detail from JIRA
Votes 0
Component/s
Labels Sub-task
Assignee None
Priority Medium

md5: 93e14b077ba1c338e9439a8336b784bc

Parent-Task:

Issue Description:

class C: Differentiable {
  @differentiable
  var float: Float = 0.0
}
$ swift -enable-experimental-forward-mode-differentiation -Xllvm -debug-only=differentiation sr-12175.swift
...
[AD] Original bb0: To differentiate or not to differentiate?
[ ]   debug_value %0 : $C, let, name "self", argno 1  // id: %1
[x]   %2 = ref_element_addr %0 : $C, #C.float         // user: %3
[x]   %3 = begin_access [read] [dynamic] %2 : $*Float // users: %5, %4
[x]   %4 = load [trivial] %3 : $*Float                // user: %6
[x]   end_access %3 : $*Float                         // id: %5
[ ]   return %4 : $Float                              // id: %6
[AD] Adding tangent for %0 = argument of bb0 : $C                         // users: %2, %1
[AD] Assigned parameter %0 = argument of bb0 : $C.TangentVector
 as the tangent of original result %0 = argument of bb0 : $C                         // users: %2, %1
[AD] JVPEmitter visited:
[ORIG]  %2 = ref_element_addr %0 : $C, #C.float         // user: %3
[TAN] Emitted in differential:
[AD] JVPEmitter visited:
[ORIG]  %3 = begin_access [read] [dynamic] %2 : $*Float // users: %5, %4
Assertion failed: (!insertion.second && "tangent buffer should already exist"), function getTangentBuffer, file /Users/danielzheng/swift-dev/swift/lib/SILOptimizer/Utils/Differentiation/JVPEmitter.cpp, line 257.
Stack dump:
0.  Program arguments: /Users/danielzheng/swift-dev/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift -frontend -interpret sr-12175.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -enable-experimental-forward-mode-differentiation -Xllvm -debug-only=differentiation -module-name main
1.  Swift version 5.2-dev (Swift 9a55217738)
2.  While running pass #​507 SILModuleTransform "Differentiation".
3.  While processing // differentiability witness for C.float.getter
sil_differentiability_witness hidden [parameters 0] [results 0] @$s4main1CC5floatSfvg : $@convention(method) (@guaranteed C) -> Float {
}

 on SIL function "@$s4main1CC5floatSfvg".
 for getter for float (at sr-12175.swift:3:7)
4.  While generating JVP and differential for SIL function "@$s4main1CC5floatSfvg".
 for getter for float (at sr-12175.swift:3:7)
@beccadax
Copy link
Contributor

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@BradLarson
Copy link
Contributor

Class and forward-mode differentiation support still needs some work, but this particular crash no longer occurs, so I'm going to close this out.

@AnthonyLatsis AnthonyLatsis added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself AutoDiff swift 5.2 crash Bug: A crash, i.e., an abnormal termination of software SILOptimizer Area → compiler: SIL optimization passes labels May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software SILOptimizer Area → compiler: SIL optimization passes swift 5.2
Projects
None yet
Development

No branches or pull requests

4 participants