-
-
Notifications
You must be signed in to change notification settings - Fork 778
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
Add symiirorder1 to cupyx.scipy.signal #7511
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pull request is now in conflicts. Could you fix it @andfoy? 🙏 |
andfoy
force-pushed
the
add_symiirorder1
branch
from
April 10, 2023 16:15
fa491a5
to
4c36e51
Compare
/test mini |
takagi
reviewed
Apr 11, 2023
This pull request is now in conflicts. Could you fix it @andfoy? 🙏 |
andfoy
force-pushed
the
add_symiirorder1
branch
from
April 11, 2023 23:32
f6712fa
to
3ecc86f
Compare
andfoy
force-pushed
the
add_symiirorder1
branch
from
April 12, 2023 21:37
46f31bc
to
85fcbe4
Compare
/test mini |
I merge this as the CI failures are not related. Thanks, @andfoy! |
These are the benchmark results for For larger input sizes, the GPU implementation achieves a ~3X improvement over SciPy. Benchmark scriptfrom itertools import product
import cupy as cp
import numpy as np
from cupy import testing
from cupyx.profiler import benchmark
from cupyx.scipy.signal import symiirorder1 as symiir1_gpu
from scipy.signal import symiirorder1 as symiir1_cpu
from tqdm import tqdm
input_sizes = [5, 10, 100, 1000, 5000, 10000, 50000, 100000, 200000, 500000,
700000, 1_000_000, 2_000_000, 10_000_000]
modules = [(cp, symiir1_gpu, 'CuPy'), (np, symiir1_cpu, 'SciPy')]
# kwargs = [('order', [1, 2, 4, 6, 10])]
kwargs = [('precision', [1])]
# kwargs = [('extrapolate', [True])]
kwargs = list(product(*[list(product([x[0]], x[1])) for x in kwargs]))
measurement = {}
def gather_time(prof):
cpu_time = prof.cpu_times.mean() * 1000
gpu_time = prof.gpu_times.mean() * 1000
return max(cpu_time, gpu_time)
def input_creation(xp, fn, size, precision=-1, **kwargs):
size = size[0]
x = testing.shaped_random((size,), xp, dtype=xp.float32)
c0 = xp.asarray([2.0], dtype=xp.float32)
z1 = xp.asarray([0.5], dtype=xp.float32)
sig = (x, c0, z1, precision)
return fn, sig
def closure(fn, sig):
# try:
return fn(*sig)
# except ValueError:
# pass
for kwarg_comb in kwargs:
kwarg_measurement = measurement.get(kwarg_comb, {})
measurement[kwarg_comb] = kwarg_measurement
kwarg_comb = dict(kwarg_comb)
for size in tqdm(input_sizes):
size_measurement = kwarg_measurement.get(size, {})
kwarg_measurement[size] = size_measurement
for xp, cls, _id in modules:
b, x = input_creation(xp, cls, (size,), **kwarg_comb)
prof = benchmark(closure, (b, x), n_repeat=100)
size_measurement[_id] = gather_time(prof)
lines = []
for kwarg_comb in kwargs:
kwarg_line = ', '.join([f'{x}={y}' for x, y in kwarg_comb])
lines.append(f'### `{kwarg_line}`\n')
lines.append('| Size | CuPy (ms) | SciPy (ms) | Speedup |')
lines.append('|:----:|:---------:|:----------:|:-------:|')
kwarg_measurement = measurement[kwarg_comb]
for size in input_sizes:
comp = f'{size}'
size_measurement = kwarg_measurement[size]
times = []
for _, _, _id in modules:
time = size_measurement[_id]
times.append(time)
time_info = f'{time:3f}'
comp = f'{comp} | {time_info}'
speedup = times[1] / times[0]
comp = f'{comp} | {speedup:3f}'
lines.append(f'| {comp} |')
lines.append('\n')
print('\n'.join(lines))
|
Size | CuPy (ms) | SciPy (ms) | Speedup |
---|---|---|---|
5 | 2.344661 | 0.002708 | 0.001155 |
10 | 2.356515 | 0.002852 | 0.001210 |
100 | 2.360504 | 0.004143 | 0.001755 |
1000 | 2.421581 | 0.012302 | 0.005080 |
5000 | 2.387976 | 0.042065 | 0.017615 |
10000 | 2.418097 | 0.078274 | 0.032370 |
50000 | 2.394409 | 0.369082 | 0.154143 |
100000 | 2.417459 | 0.731418 | 0.302557 |
200000 | 2.501704 | 1.468732 | 0.587093 |
500000 | 2.781974 | 3.646715 | 1.310837 |
700000 | 2.806415 | 5.084350 | 1.811688 |
1000000 | 3.172863 | 7.267981 | 2.290670 |
2000000 | 5.308269 | 14.556299 | 2.742193 |
10000000 | 24.033003 | 85.798085 | 3.570011 |
Thanks, it's fine! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #7403