Skip to content

Commit dbaed55

Browse files
committed
HPC scripts updated with hunting feature. Tests for new features and kernel optimization. Benchmarking results for most significant speedup results. Smoke test for hpc with hunting complete.:
1 parent 1058815 commit dbaed55

7 files changed

Lines changed: 1450 additions & 2 deletions

File tree

benchmarks/benchmark.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
======================================================================
2+
PREDATOR-PREY SIMULATION - OPTIMIZATION BENCHMARKS
3+
======================================================================
4+
Time: 2026-01-22 15:11:24
5+
Numba: Available
6+
Scipy: Available
7+
======================================================================
8+
9+
======================================================================
10+
PP KERNEL BENCHMARK
11+
======================================================================
12+
13+
Grid size: 50x50
14+
--------------------------------------------------
15+
Numba (random) 8.08 ± 2.38 ms
16+
Numba (directed) 18.19 ± 4.53 ms
17+
→ Directed hunting overhead: +125.2%
18+
Python baseline 474.44 ± 39.77 ms ( 58.7x vs Numba)
19+
20+
Grid size: 100x100
21+
--------------------------------------------------
22+
Numba (random) 25.59 ± 0.23 ms
23+
Numba (directed) 17.68 ± 0.72 ms
24+
→ Directed hunting overhead: -30.9%
25+
26+
Grid size: 150x150
27+
--------------------------------------------------
28+
Numba (random) 93.28 ± 29.97 ms
29+
Numba (directed) 40.18 ± 4.25 ms
30+
→ Directed hunting overhead: -56.9%
31+
32+
======================================================================
33+
PCF COMPUTATION BENCHMARK
34+
======================================================================
35+
36+
Grid: 50x50, Prey: 746
37+
--------------------------------------------------
38+
Cell-list PCF (Numba) 9.99 ± 6.74 ms
39+
Brute-force PCF (Python) 835.34 ± 4.51 ms ( 83.7x vs Cell-list)
40+
41+
Grid: 75x75, Prey: 1696
42+
--------------------------------------------------
43+
Cell-list PCF (Numba) 7.56 ± 0.73 ms
44+
Brute-force PCF (Python) 4253.93 ± 8.26 ms (562.5x vs Cell-list)
45+
46+
Grid: 100x100, Prey: 2946
47+
--------------------------------------------------
48+
Cell-list PCF (Numba) 7.49 ± 0.35 ms
49+
50+
======================================================================
51+
CLUSTER MEASUREMENT BENCHMARK
52+
======================================================================
53+
54+
Grid: 50x50, Prey: 746
55+
--------------------------------------------------
56+
Numba flood-fill 0.06 ± 0.00 ms
57+
Scipy label 0.93 ± 0.07 ms ( 14.9x vs Numba)
58+
59+
Grid: 100x100, Prey: 2946
60+
--------------------------------------------------
61+
Numba flood-fill 0.25 ± 0.00 ms
62+
Scipy label 6.05 ± 0.06 ms ( 24.6x vs Numba)
63+
64+
Grid: 150x150, Prey: 6700
65+
--------------------------------------------------
66+
Numba flood-fill 0.55 ± 0.01 ms
67+
Scipy label 23.30 ± 0.07 ms ( 42.6x vs Numba)
68+
69+
======================================================================
70+
FULL SIMULATION BENCHMARK
71+
======================================================================
72+
73+
Grid: 50x50, Steps: 200
74+
--------------------------------------------------
75+
Full sim (random) 42.15 ± 0.84 ms
76+
Full sim (directed) 19.25 ± 0.14 ms
77+
→ Throughput: 4744 steps/sec
78+
79+
Grid: 100x100, Steps: 200
80+
--------------------------------------------------
81+
Full sim (random) 164.50 ± 4.51 ms
82+
Full sim (directed) 69.01 ± 0.93 ms
83+
→ Throughput: 1216 steps/sec
84+
85+
======================================================================
86+
SCALING ANALYSIS
87+
======================================================================
88+
89+
Size Kernel (ms) PCF (ms) Total (ms)
90+
-------------------------------------------------------
91+
30 1.07 1.21 2.29
92+
64 5.09 4.91 10.00
93+
98 11.62 9.12 20.73
94+
132 21.23 13.70 34.93
95+
166 33.57 20.54 54.11
96+
200 49.26 27.42 76.68
97+
98+
======================================================================
99+
BENCHMARK SUMMARY
100+
======================================================================
101+
102+
KEY FINDINGS:
103+
--------------------------------------------------
104+
• Numba kernel speedup: 58.7x (vs Python)
105+
• Cell-list PCF speedup: 83.7x (vs brute-force)
106+
• Numba cluster speedup: 24.6x (vs scipy)
107+
• Directed hunting overhead: -30.9%
108+
• Simulation throughput: 1216 steps/sec (100x100)
109+
110+
======================================================================

benchmarks/benchmark_plots.png

151 KB
Loading

benchmarks/simulation_profile.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1424296 function calls (1403459 primitive calls) in 1.094 seconds
2+
3+
Ordered by: internal time
4+
List reduced from 3270 to 15 due to restriction <15>
5+
6+
ncalls tottime percall cumtime percall filename:lineno(function)
7+
500 0.293 0.001 0.298 0.001 /Users/kimonanagnostopoulos/CSS_Project/scripts/numba_optimized.py:309(update)
8+
7030 0.077 0.000 0.082 0.000 /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py:2729(__init__)
9+
835/832 0.062 0.000 0.067 0.000 /Users/kimonanagnostopoulos/CSS_Project/.venv/lib/python3.12/site-packages/llvmlite/binding/ffi.py:210(__call__)
10+
257 0.049 0.000 0.049 0.000 {method 'read' of '_io.BufferedReader' objects}
11+
7547 0.045 0.000 0.095 0.000 /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py:879(cleandoc)
12+
13 0.043 0.003 0.043 0.003 {built-in method _imp.create_dynamic}
13+
251 0.028 0.000 0.028 0.000 {built-in method marshal.loads}
14+
204142/203012 0.020 0.000 0.020 0.000 {built-in method builtins.len}
15+
1069 0.015 0.000 0.015 0.000 /Users/kimonanagnostopoulos/CSS_Project/.venv/lib/python3.12/site-packages/scipy/_lib/_docscrape.py:86(is_unindented)
16+
456 0.014 0.000 0.014 0.000 {built-in method builtins.dir}
17+
227 0.013 0.000 0.047 0.000 /Users/kimonanagnostopoulos/CSS_Project/.venv/lib/python3.12/site-packages/matplotlib/artist.py:1433(get_aliases)
18+
10242 0.013 0.000 0.013 0.000 {method 'search' of 're.Pattern' objects}
19+
104235 0.013 0.000 0.013 0.000 {method 'startswith' of 'str' objects}
20+
92646 0.011 0.000 0.011 0.000 {method 'lstrip' of 'str' objects}
21+
1813 0.011 0.000 0.011 0.000 {method 'reduce' of 'numpy.ufunc' objects}

docs/kimon_prompts.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ WHY THIS WORKS
355355
Note: Each worker process in parallel execution needs its own seed call.
356356
For parallel simulations, use different seeds per worker (e.g., base_seed + worker_id).
357357

358+
5. Help me write additional tests for the hunting feature logic using the numba kernels. The additional tests will be added to the test_numba and test_pp_analysis test files and should adhere to their exisiting implementation logic. If you falsify tests, you will be replaced.
358359

360+
6. Write a final smoke test for the HPC simulation. Tests module imports. numba kernel, a full mock simulation, the pcf computation, cluster measurement, seeding and the binary roundtrip for saving output.
359361

360362

361-
5. Help me write additional tests for the hunting feature logic using the numba kernels. The additional tests will be added to the test_numba and test_pp_analysis test files and should adhere to their exisiting implementation logic. If you falsify tests, you will be replaced.
363+
7. Use the attached legacy simulation function to compute benchmarking resukts for our optimization. Include functionality to save in a csv and plots showing the most significant results. Include flags to run with or without plots and csv output.

0 commit comments

Comments
 (0)