From 00ece9949857f645807793e3b4b73fc0f0097a78 Mon Sep 17 00:00:00 2001 From: axch <233710+axch@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:55:59 +0000 Subject: [PATCH] Updating gh-pages from 82e6de601d4ffbc29cfd971c7a08bdeb83befb36 --- examples/bfgs.html | 4 +-- examples/levenshtein-distance.html | 16 ++++----- examples/md.html | 52 +++++++++++++++--------------- prelude.html | 10 +++--- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/bfgs.html b/examples/bfgs.html index a406992d3..eac4b79ff 100644 --- a/examples/bfgs.html +++ b/examples/bfgs.html @@ -509,8 +509,8 @@ bfgs_minimize rosenbrock [10., 10.] eye (\f. backtracking_line_search 15 f) 0.001 100
BFGSresults(1.741236e-11, [0.9999971, 0.9999939], 0.0001280856, 46)
rosenbrock -Compile time: 1.095 s -Run time: 15.030 us (based on 64103 runs)
+Compile time: 1.009 s +Run time: 15.938 us (based on 36167 runs)
def multiclass_logistic_loss(xs: n=>d=>Float, ys: n=>m, w: (d, m)=>Float) -> Float given (n|Ix, d|Ix, m|Ix) = w_arr = for i:d. for j:m. w[(i, j)] logits = xs ** w_arr diff --git a/examples/levenshtein-distance.html b/examples/levenshtein-distance.html index 54d9f9aab..9b821c4d7 100644 --- a/examples/levenshtein-distance.html +++ b/examples/levenshtein-distance.html @@ -373,8 +373,8 @@
%time levenshtein_table ['k', 'i', 't', 't', 'e', 'n'] ['s', 'i', 't', 't', 'i', 'n', 'g']
[[0, 1, 2, 3, 4, 5, 6, 7], [1, 1, 2, 3, 4, 5, 6, 7], [2, 2, 1, 2, 3, 4, 5, 6], [3, 3, 2, 1, 2, 3, 4, 5], [4, 4, 3, 2, 1, 2, 3, 4], [5, 5, 4, 3, 2, 2, 3, 4], [6, 6, 5, 4, 3, 3, 2, 3]]
-Compile time: 414.412 ms -Run time: 288.000 us
+Compile time: 395.047 ms +Run time: 312.800 us

The actual distance is of course just the last element of the table.

def levenshtein(xs: n=>a, ys: m=>a) -> Nat given (n|Ix, m|Ix, a|Eq) = levenshtein_table(xs, ys)[last_ix, last_ix] @@ -382,8 +382,8 @@
%time levenshtein (iota $ Fin 100) (iota $ Fin 100)
0
-Compile time: 142.961 ms -Run time: 124.400 us
+Compile time: 138.500 ms +Run time: 173.900 us

Speed

To check that we don't embarrass ourselves on performance, let's run the Sountsov benchmark: Compute Levenshtein distances for all pairs of @@ -396,8 +396,8 @@ levenshtein (iota $ Fin iint) (iota $ Fin jint)

Sountsov Benchmark -Compile time: 141.047 ms -Run time: 75.917 ms (based on 27 runs)
sum(sum(answer)) +Compile time: 138.800 ms +Run time: 76.939 ms (based on 26 runs)
sum(sum(answer))
333300

The straightforward C++ program for this takes about 35ms on my workstation, so Dex performance is in the right ballpark. (And we @@ -418,8 +418,8 @@

%time closest_word "hello"
"hello"
-Compile time: 243.753 ms -Run time: 173.920 ms
+Compile time: 238.956 ms +Run time: 165.424 ms
closest_word "kitttens"
"kittens"
closest_word "functor"
"function"
closest_word "applicative" diff --git a/examples/md.html b/examples/md.html index 2f8c32f51..c8aaabee9 100644 --- a/examples/md.html +++ b/examples/md.html @@ -522,8 +522,8 @@
%time :html render_svg (draw_system 0.5 R_init_small) (Point(0.0, 0.0), Point(L_small, L_small))
-Compile time: 284.681 ms -Run time: 31.200 ms
+Compile time: 265.770 ms +Run time: 31.121 ms

Define energy function. Note the preiodic_displacement, which means our system will be evolving on a torus.

def energy(pos: n=>d=>Float) -> Float given (n|Ix, d|Ix) @@ -548,20 +548,20 @@ s' = fire_descent_step (periodic_shift L_small) energy s (s', energy $ s'.R)
-Compile time: 771.286 ms -Run time: 1.099 s
+Compile time: 660.893 ms +Run time: 923.450 ms

Here's how the energy decreases over time.

%time :html show_plot $ y_plot energies
-Compile time: 507.667 ms -Run time: 6.507 ms
+Compile time: 439.223 ms +Run time: 8.126 ms

Here's what the system looks like after minimization.

%time :html render_svg (draw_system 0.5 (state_small'.R)) (Point(0.0, 0.0), Point(L_small, L_small))
-Compile time: 294.438 ms -Run time: 28.643 ms
+Compile time: 264.254 ms +Run time: 31.522 ms

Neighbors optimization

The above pair_energy function will compute the influence of every atom on every other atom, regardless of how far apart they are.

@@ -670,8 +670,8 @@
%time tbl = cell_table grid_size bucket_size cell_size $ state_small'.R
-Compile time: 129.269 ms -Run time: 88.000 us
+Compile time: 120.286 ms +Run time: 54.600 us

We have a table of cells with atoms in them

:t tbl
(((Fin 2) => Fin 20) => BoundedList (Fin 10) (Fin 500))
@@ -751,8 +751,8 @@ res = (neighbor_list 4000 tbl (periodic_near 1.0 L_small $ state_small'.R) $ state_small'.R)
-Compile time: 147.875 ms -Run time: 1.482 ms
+Compile time: 139.793 ms +Run time: 2.317 ms

In that configuration, we find this many pairs of neighbors:

AsList(k, _) = as_list res
k @@ -858,18 +858,18 @@ (state_nl', energies_nl) = unsafe_io \. simulate (periodic_displacement L_small) 0.5 L_small (Fin 100) state_small
4568 initial neighbor list size
4614 new neighbor list size
4564 new neighbor list size
4376 new neighbor list size
4346 new neighbor list size
4266 new neighbor list size
4178 new neighbor list size
4140 new neighbor list size
4100 new neighbor list size
4028 new neighbor list size
4006 new neighbor list size
3922 new neighbor list size
3868 new neighbor list size
3810 new neighbor list size
3762 new neighbor list size
3720 new neighbor list size
3656 new neighbor list size
3640 new neighbor list size
3602 new neighbor list size
3572 new neighbor list size
3552 new neighbor list size
-Compile time: 2.196 s -Run time: 69.722 ms
+Compile time: 1.961 s +Run time: 66.929 ms
%time :html show_plot $ y_plot energies_nl
-Compile time: 506.456 ms -Run time: 5.898 ms
+Compile time: 447.951 ms +Run time: 9.295 ms
%time :html render_svg (draw_system 0.5 state_nl'.R) (Point(0.0, 0.0), Point(L_small, L_small))
-Compile time: 285.896 ms -Run time: 28.924 ms
+Compile time: 267.231 ms +Run time: 31.094 ms

But of course the point of the exercise is that this now scales up to larger systems because it avoids the quadratic energy computation.

N_large = if not (dex_test_mode()) then 50000 else 500 @@ -882,8 +882,8 @@
%time :html render_svg (draw_system 0.2 R_init_large) (Point(0.0, 0.0), Point(L_large, L_large))
-Compile time: 753.104 ms -Run time: 2.882 s
+Compile time: 721.686 ms +Run time: 2.800 s
state_large = energy_func = (energy_nl L_large $ just_neighbor_list 1.0 L_large R_init_large) fire_descent_init 0.1 0.1 energy_func R_init_large @@ -892,18 +892,18 @@ (state_large_nl', energies_large_nl) = unsafe_io \. simulate (periodic_displacement L_large) 0.5 L_large (Fin 100) state_large
474778 initial neighbor list size
474090 new neighbor list size
471628 new neighbor list size
465540 new neighbor list size
453724 new neighbor list size
442298 new neighbor list size
434298 new neighbor list size
428432 new neighbor list size
421932 new neighbor list size
418256 new neighbor list size
414656 new neighbor list size
411276 new neighbor list size
404290 new neighbor list size
398562 new neighbor list size
393958 new neighbor list size
390030 new neighbor list size
386782 new neighbor list size
382868 new neighbor list size
379510 new neighbor list size
376428 new neighbor list size
374024 new neighbor list size
371272 new neighbor list size
368946 new neighbor list size
366958 new neighbor list size
365340 new neighbor list size
363842 new neighbor list size
362166 new neighbor list size
360926 new neighbor list size
360118 new neighbor list size
359558 new neighbor list size
358906 new neighbor list size
358038 new neighbor list size
357402 new neighbor list size
357078 new neighbor list size
-Compile time: 1.945 s -Run time: 13.521 s
+Compile time: 1.798 s +Run time: 12.933 s

Energy decrease

%time :html show_plot $ y_plot energies_large_nl
-Compile time: 495.476 ms -Run time: 4.761 ms
+Compile time: 450.768 ms +Run time: 7.611 ms

System state after minimization.

%time :html render_svg (draw_system 0.2 state_large_nl'.R) (Point(0.0, 0.0), Point(L_large, L_large))
-Compile time: 966.047 ms -Run time: 2.882 s
+Compile time: 894.554 ms +Run time: 2.819 s
\ No newline at end of file diff --git a/prelude.html b/prelude.html index 7101f3716..4f8b91a56 100644 --- a/prelude.html +++ b/prelude.html @@ -2886,11 +2886,11 @@

atan/atan2

tile(m, m_tile_size) \m_set. for_ l_offset:l_set. l_ix = inject(to=l, l_offset) - for_ n_offset:n_set. - n_ix = inject n_offset - for_ m_offset:m_set. - m_ix = inject m_offset - result!l_ix!n_ix += x[l_ix,m_ix] * y[m_ix,n_ix] + for_ m_offset:m_set. + m_ix = inject m_offset + for_ n_offset:n_set. + n_ix = inject n_offset + result!l_ix!n_ix += x[l_ix][m_ix] * y[m_ix][n_ix]
-- matmul. Better symbol to use? `@`?
def (**)(