Closed bdrelling closed 1 year ago
@bdrelling
Should be fixed now: 0e52adc4aedfdaa30952db3dafc883382c644f5f
Make sure to update the spm package from the master
branch in order to get the change.
@ggerganov thanks so much for the quick reply!
Unfortunately, as mentioned above I am not sure that this solution will work. I think it will make your package invalid entirely, per Apple's documentation here:
https://developer.apple.com/documentation/packagedescription/csetting/unsafeflags(_:_:)
As some build flags can be exploited for unsupported or malicious behavior, the use of unsafe flags makes the products containing this target ineligible for use by other packages.
That said, while this didn't work for me on Friday, I'll still give this another try to be sure!
Well, it does work with swift test -c debug
when pulled into another package (see my WhisperTesting example), but the output of swift test -c release
now has a ton of warnings:
swift test -c release
Updating https://github.com/ggerganov/whisper.spm
Updated https://github.com/ggerganov/whisper.spm (1.29s)
Working copy of https://github.com/ggerganov/whisper.spm resolved at master
Building for production...
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:2651:71: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
struct ggml_tensor * result = ggml_new_tensor(ctx, GGML_TYPE_F32, MIN(a->n_dims, b->n_dims), ne);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:4208:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:4482:25: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ic1 = MIN(ic0 + dc, ne);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:4507:25: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:4546:25: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ic1 = MIN(ic0 + dc, nc);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:4778:25: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ic1 = MIN(ic0 + dc, ne);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:4808:25: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:4849:25: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ic1 = MIN(ic0 + dc, nc);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:4953:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:5199:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:5212:19: warning: ambiguous expansion of macro 'MAX' [-Wambiguous-macro]
max = MAX(max, p[i]);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:218:9: note: expanding this definition of 'MAX'
#define MAX(a, b) (((a)>(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:91:9: note: other definition of 'MAX'
#define MAX(a, b) ((a) > (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:5449:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:5569:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:5715:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:5835:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:5977:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:6021:23: warning: ambiguous expansion of macro 'MAX' [-Wambiguous-macro]
max = MAX(max, S[i]);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:218:9: note: expanding this definition of 'MAX'
#define MAX(a, b) (((a)>(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:91:9: note: other definition of 'MAX'
#define MAX(a, b) ((a) > (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:6158:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:6202:23: warning: ambiguous expansion of macro 'MAX' [-Wambiguous-macro]
max = MAX(max, S[i]);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:218:9: note: expanding this definition of 'MAX'
#define MAX(a, b) (((a)>(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:91:9: note: other definition of 'MAX'
#define MAX(a, b) ((a) > (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:6397:21: warning: ambiguous expansion of macro 'MIN' [-Wambiguous-macro]
const int ir1 = MIN(ir0 + dr, nr);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:215:9: note: expanding this definition of 'MIN'
#define MIN(a, b) (((a)<(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:92:9: note: other definition of 'MIN'
#define MIN(a, b) ((a) < (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:7244:37: warning: ambiguous expansion of macro 'MAX' [-Wambiguous-macro]
work_size = MAX(work_size, cur);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:218:9: note: expanding this definition of 'MAX'
#define MAX(a, b) (((a)>(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:91:9: note: other definition of 'MAX'
#define MAX(a, b) ((a) > (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:7296:37: warning: ambiguous expansion of macro 'MAX' [-Wambiguous-macro]
work_size = MAX(work_size, cur);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:218:9: note: expanding this definition of 'MAX'
#define MAX(a, b) (((a)>(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:91:9: note: other definition of 'MAX'
#define MAX(a, b) ((a) > (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:7314:37: warning: ambiguous expansion of macro 'MAX' [-Wambiguous-macro]
work_size = MAX(work_size, cur);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:218:9: note: expanding this definition of 'MAX'
#define MAX(a, b) (((a)>(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:91:9: note: other definition of 'MAX'
#define MAX(a, b) ((a) > (b) ? (a) : (b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:7332:37: warning: ambiguous expansion of macro 'MAX' [-Wambiguous-macro]
work_size = MAX(work_size, cur);
^
/Applications/Xcode 14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include/sys/param.h:218:9: note: expanding this definition of 'MAX'
#define MAX(a, b) (((a)>(b))?(a):(b))
^
/Users/**/WhisperTesting/.build/checkouts/whisper.spm/Sources/whisper/ggml.c:91:9: note: other definition of 'MAX'
#define MAX(a, b) ((a) > (b) ? (a) : (b))
^
24 warnings generated.
/Users/**/WhisperTesting/Tests/WhisperTests/WhisperTests.swift:23:9: warning: variable 'pcmf32' was never mutated; consider changing to 'let' constant
var pcmf32 = [Float](repeating: 0, count: Int(n_samples))
~~~ ^
let
[4/4] Linking WhisperTestingPackageTests
Build complete! (6.79s)
Test Suite 'All tests' started at 2023-01-03 13:01:32.432
Test Suite 'WhisperTestingPackageTests.xctest' started at 2023-01-03 13:01:32.433
Test Suite 'WhisperBridgeTests' started at 2023-01-03 13:01:32.433
Test Case '-[WhisperTests.WhisperBridgeTests testWhisperSPM]' started.
whisper_model_load: loading model from '/Users/**/WhisperTesting/.build/arm64-apple-macosx/release/WhisperTesting_WhisperTests.bundle/models/for-tests-ggml-base.en.bin'
whisper_model_load: n_vocab = 51864
whisper_model_load: n_audio_ctx = 1500
whisper_model_load: n_audio_state = 512
whisper_model_load: n_audio_head = 8
whisper_model_load: n_audio_layer = 6
whisper_model_load: n_text_ctx = 448
whisper_model_load: n_text_state = 512
whisper_model_load: n_text_head = 8
whisper_model_load: n_text_layer = 6
whisper_model_load: n_mels = 80
whisper_model_load: f16 = 1
whisper_model_load: type = 2
whisper_model_load: adding 1607 extra tokens
whisper_model_load: mem_required = 506.00 MB
whisper_model_load: ggml ctx size = 140.60 MB
whisper_model_load: memory size = 22.83 MB
whisper_model_load: model size = 0.00 MB
whisper_model_load: WARN no tensors loaded from model file - assuming empty model for testing
whisper_print_timings: load time = 59.52 ms
whisper_print_timings: mel time = 1.68 ms
whisper_print_timings: sample time = 0.00 ms
whisper_print_timings: encode time = 0.00 ms / 0.00 ms per layer
whisper_print_timings: decode time = 0.00 ms / 0.00 ms per layer
whisper_print_timings: total time = 61.32 ms
Test Case '-[WhisperTests.WhisperBridgeTests testWhisperSPM]' passed (0.072 seconds).
Test Suite 'WhisperBridgeTests' passed at 2023-01-03 13:01:32.505.
Executed 1 test, with 0 failures (0 unexpected) in 0.072 (0.072) seconds
Test Suite 'WhisperTestingPackageTests.xctest' passed at 2023-01-03 13:01:32.505.
Executed 1 test, with 0 failures (0 unexpected) in 0.072 (0.072) seconds
Test Suite 'All tests' passed at 2023-01-03 13:01:32.505.
Executed 1 test, with 0 failures (0 unexpected) in 0.072 (0.073) seconds
If it helps, I'm just realizing that these are the same warnings as when we integrate directly with whisper.cpp
:
The warnings should be resolved now.
Regarding the incompatibility with other packages:
As some build flags can be exploited for unsupported or malicious behavior, the use of unsafe flags makes the products containing this target ineligible for use by other packages.
Not sure if this is a problem for now.
If we get requests for being able to include whisper.spm
in other SPM packages, we can figure out a solution, but for now I think we can proceed with this.
I was just coming back here to confirm it's working just fine, and our deployments are find and everything is great. Just another false alarm from the Apple documentation?
Thanks for all of your help! I think this issue can be closed. 😄
We have an Xcode project and Swift package. Currently,
whisper.cpp
is implemented directly into the Xcode project, but we are trying to abstract this into our Swift package viawhisper.spm
. However, we're noticing thatwhisper.spm
is about 40x slower indebug
configuration than inrelease
. We can verify on this repo by runningswift run test-swift -c debug
andswift run test-swift -c release
.The difference in speed is absolutely understandable between configurations, but unfortunately, SPM does not allow us to override the default compilation mode for an individual module. Adding something like
cSettings: [.unsafeFlags["-O3"]]
to the package definition makes no impact on third-party dependencies. Similarly, from the Xcode project, we don't seem to have the option for explicit, configuration-based overrides to our dependencies.The use case here is that we want
whisper
to run in theRelease
configuration 99% of the time.Do you have any ideas on how
whisper.spm
could support this such that we don't have to pursue some option like a wrapper project or pre-compiling the library?Thanks in advance for your help, and for your support with
whisper
!Sample Outputs
Debug
swift test -c debug
Release
swift test -c release
And just to clarify: When running in
Release
configuration, I'm noticing NO performance issues. I repeated a number of performance tests onwhisper.cpp
incorporated directly andwhisper.spm
via SPM, and when inRelease
configuration, they line up 1:1 over thejfk.wav
sample perfectly.