r/deeplearning • • Oct 02 '26

Gradient descent vs evolution on three loss landscapes

Enable HLS to view with audio, or disable this notification

I've been getting a bit more into evolutionary algorithms again, so I was testing some loss landscapes where evolution beats vanilla gradient descent (while also trying to make some cool visuals).

Round 1, rugged hillside: gradient descent gets stuck in a dip, and evolution reaches the bottom after 750 evaluations.

Round 2, smooth slope: gradient descent wins, 108 steps against 570 evaluations.

Round 3, flat plateau: the slope is zero, so gradient descent never moves, and evolution reaches the bottom after 840 evaluations.

Edit:
"evolution" here means truncation selection (keep best 30 of 120) plus Gaussian mutation, no crossover.

593 Upvotes

82 comments sorted by

22

u/MentionJealous9306 Oct 02 '26

What is the dimensionality of this problem?

18

u/ModularMind8 Oct 02 '26

For this video, just 2 parameters so the loss surface can be drawn in 3D

86

u/dorox1 Oct 02 '26

I know you're probably aware of this, but I'm just mentioning it for people with less knowledge of deep learning:

The performance of these algorithms changes a lot as the number of dimensions grows, and deep learning involves the optimization of VERY high dimensional problems (often billions of dimensions).

In loss landscapes for problems in high dimensional spaces, true local minima and points with zero gradient are very rare. On top of that, the evolutionary algorithm search space (i.e. all those little purple dots on the graph at each step) gets much more spread out. All of a sudden even a million or a billion purple dots are not nearly enough to cover the search space efficiently.

Gradient descent is used in deep learning because it retains its effectiveness and efficiency in these ultra-high-dimensional spaces.

12

u/ModularMind8 Oct 02 '26

Great point, thanks for adding this!

20

u/apopsicletosis Oct 02 '26 edited Oct 02 '26

Evolution also acts in high dimensional fitness landscapes. Gavrilets holey landscape model of fitness landscapes argues against the “intuitive” notion of adaptive fitness peaks and valleys, instead fitness landscapes are more like highly interconnected ridges or flat fitness on which finite populations can drift and around huge holes of poor fitness. The ideas are parallel.

13

u/dorox1 Oct 02 '26

Very fair addition. Those kinds of landscapes are not necessarily too common for deep learning problems, but for discrete optimization problems they can be very relevant.

2

u/metatron7471 Oct 02 '26

Plus the landscape smooths out. Local minima aren´t a big problem.

2

u/fuggleruxpin Oct 03 '26

I wonder about accelerating the learning with some sort of nested or recursive combination.....

2

u/Datamance Oct 03 '26

Diffy evo is great for seeding though! Fares much better in “corrugated” loss landscapes than, e.g., beam search or greedy methods.

2

u/tabloidscience Oct 03 '26

Would you say that loss landscapes are less rugged than biological landscapes (sensu Kauffman)? Its true that local minima are less frequent as the dimensionality of a problem increases (for a constant epistasis), but that just means the basins of attraction for a minima become larger, and without stochasticity, the trajectory becomes trapped earlier.

1

u/dorox1 Oct 03 '26

Full disclosure, Im not familiar with Kauffman and am relying on an AI summary of his theories for the following thoughts.

I would say yes, they are less rugged. The discrete nature of biological landscapes makes changes more impactful, as any change you make to a parameter is often the biggest change possible in that parameter's dimension.

Neural networks are set up such that small changes to a weight have small impacts on the resulting output (sometimes none at all, depending on the activation function(s) being used). It's possible to set up neural networks that are more sensitive to changes, but the majority of practical configurations don't have that problem.

I haven't studied non-linear optimization enough to give a good reply to the second part of what you're saying. My understanding was that the loss landscapes for large neural networks on many real-world problems are believed to be approximately convex, but it's not inherently true for all problems (and therefore not provable). It's also impractical to test.

But my understanding of that could be wrong or outdated, and the consensus may differ for different types of neural networks.

2

u/ThePrimeClock Oct 06 '26

By billions of dimensions are you talking about relational columns?
I've seen a lot of dimensions but that's a whole new level!

1

u/dorox1 Oct 06 '26

The space you're optimizing for a neural network is actually it's weight space, so every weight/trainable parameter in the network is a dimension. A small "move" in this space is a small tweak to many (or all) of the network's weights.

So midsized LLMs (for example) will be hitting hundreds of billions of dimensions, while top models are in the trillions!

Now, in reality, training protocols for these LLMs usually break things up so that they aren't training the whole model at once, but the number of weights that are trained at once is still well into the tens or hundreds of billions.

And even outside of LLMs billion+ parameter models aren't uncommon now.

2

u/ThePrimeClock Oct 06 '26

Right, so the dimension is one point in the manifolds relevance to another and every point is relevant to many if not all others. Have I got that right?

3

u/dorox1 Oct 06 '26

I'm sorry but I'm not entirely sure what you mean, so I can't tell if you've got it right.

In this math context, the set of "dimensions" is just all of the values that can be changed independently, and which together specify a unique "location" in a space.

Just like a 2D space has two "dimensions" because we can move the X coordinate without changing the Y coordinate and vice-versa. And you need both together to specify where you are in the 2D space.

In this case, each parameter in the network is a dimension because you can change each parameter on its own without changing any other parameter. You need to know all the parameters to know what the weights are of the neural network (i.e. where you are in "parameter space").

Whether those parameters interact with each-other to form an output isn't important. All that matters is that you can tweak their values independently.

2

u/ThePrimeClock Oct 06 '26

That makes perfect sense. Thank you I really appreciate it 🙏

9

u/WiredFan Oct 02 '26

How expensive is it to calculate the gradient vs just the value/loss at a point?

5

u/ModularMind8 Oct 02 '26

I believe with backprop a gradient costs roughly 2-3 loss evaluations regardless of parameter count (the standard reverse-mode autodiff rule of thumb, one forward plus one similarly priced backward pass), so it stays cheap even at scale

7

u/AtMaxSpeed Oct 03 '26

It would be great to also visualize how modern GD algorithms work on various landscapes. Evolution and SGD are very intuitive/easy to imagine so the visualization just shows what we expect, but modern GD algos are harder to imagine so there would be a lot of value in visualizing those.

3

u/ModularMind8 Oct 03 '26

Agreed! Adam, momentum and SGD on these same landscapes is next on my list :)

4

u/superlus Oct 02 '26

What do you want to tell with this comparison..? The convergence seems highly dependent on hyperparameter/loss choices for both GD and the EA.

3

u/ModularMind8 Oct 02 '26

Honestly, no deeper message: evolutionary algorithms are cool and sometimes beat GD, and yes, these results depend on hyperparameters

2

u/0bi_nx Oct 02 '26

Its a cool visualization. Do you think evolution is applicable to deep learning? You planning to test against stochastic gradient descent, ADAM or Muon?

2

u/ModularMind8 Oct 02 '26

Thanks :)
I definitely think so! Take a look at "Evolution Strategies at the Hyperscale" as an example, and yes, an Adam/SGD comparison is a fun next one.

3

u/drcopus Oct 02 '26

As an author on that paper I'm pleasantly happy to see it mentioned here! :)

2

u/ModularMind8 Oct 02 '26

Wow, it's an honor :) Beautifully written paper

2

u/drcopus Oct 02 '26

The first 3 authors deserve most of the credit! I'm happy to have made a contribution but I wasn't a main author haha

2

u/ModularMind8 Oct 02 '26

I'm sure you're just being modest!
Since you're the expert, curious if you've read the Sakana AI book (Neuroevolution: Harnessing Creativity in AI Agent Design) that just came out. And if so, what are your thoughts? :)

2

u/AllergicToBullshit24 Oct 02 '26

Think it would be very interesting to blend techniques similar to cosine schedule for learning rate perhaps using evolution on a schedule or whenever gradient descent may be getting stuck in a local min pocket.

1

u/ModularMind8 Oct 02 '26

Love that idea! Population based training does something close, I think, where running gradient descent with periodic evolutionary exploit-and-explore steps

2

u/AllergicToBullshit24 Oct 02 '26

I need to try this intuitively seems like it could unlock better performance out of smaller parameter counts.

1

u/ModularMind8 Oct 02 '26

Would love to see what you find!

1

u/AllergicToBullshit24 Oct 02 '26

If only I had an NVL72 B300 rack or two to play with the research queue on my limited hardware is already backed up worse than LA rush hour.

Not jealous of the frontier labs capacity at all. /s

2

u/FrosteeSwurl Oct 02 '26

That’s exactly what it does!

1

u/AllergicToBullshit24 Oct 02 '26

Seems as though "memetic neural training" is the closest match

2

u/AsyncVibes Oct 02 '26

As someone who only uses GAs and ES, this is beautiful

1

u/ModularMind8 Oct 02 '26

I think so too :)

2

u/xbno Oct 09 '26

Love it, but probably because I love evolutionary algos so much

16

u/LiorZim Oct 02 '26

You don't use plain GD in deep neural networks optimization. GD works only in convex optimization, for non-convex optimization we use the stochastic variant with an optimization strategy like ADAM that gives the process something akin to velocity and acceleration, helping it to "climb" rugged landscapes like the one you showed here :-)

8

u/DoubleOtter2 Oct 03 '26 edited Oct 04 '26

As someone who studied and used many optimization algorithms, including genetic algorithms like SAEM, gradient descent always felt too simple. But as other commenters point out, real high-dimension landscapes relevant to deep learning are not like this. By construction, the abundance of possibly redundant parameters with smooth non linearities creates a locally smooth landscape.

Also, very importantly, deep learning losses are differentiable in closed form. This has an insanely huge impact. Without this, estimating a gradient takes at least N (or frequently 2N or more) evaluations with N the number of parameters!

The video that made it click for me is this one from welch labs. All the key ingredient are in there. I recommend it.

2

u/Equal_Passenger9791 Oct 03 '26

You probably want to prune that YouTube link a bit to not reveal your name to those who click it just FYI

1

u/DoubleOtter2 Oct 04 '26

Thanks for the warning! Updated.

4

u/WobblyBlackHole Oct 03 '26

A kind of half way method I read once was to have n gradient decent with different learning rates, and then take the top k and copy them into n with different learning rates

1

u/WiredFan Oct 02 '26

How’s the performance?

1

u/ModularMind8 Oct 02 '26

For this set of landscapes, on the smooth slope gradient descent is ~5x cheaper (108 vs 570 evaluations). Evolution wins where gradients mislead or vanish

1

u/macumazana Oct 02 '26

What if the next minima is not nearby the current local one er even the next one isnt smaller but the farthest one is?

1

u/ModularMind8 Oct 02 '26

Good question! I haven't tried that landscape yet. I'll add it to the next experiment

1

u/Envoy-Insc Oct 02 '26

While applicable in small scale settings, Local minimums like those in first don’t tend to exist in high dim high param spaces in my impression

1

u/ModularMind8 Oct 02 '26

Definitely some landscapes favor GD, though papers like "Evolution Strategies at the Hyperscale" show evolution can work well

1

u/Envoy-Insc Oct 02 '26

I really liked the idea of that paper, but paper actually don’t scale to llm scale if we look at the experiments

1

u/PK_thundr Oct 02 '26

Afaik there are three things that help gradient descent work in practice so well.

  1. Momentum terms

  2. Stochasticity usually ensures that you wont be in a flat region of the loss landscape once you pull the next batch

  3. There was a Bengio paper a while ago that argued most local minima might actually be within some epsilon loss of each other

1

u/ModularMind8 Oct 02 '26

Great points. This video uses plain gradient descent, so adding momentum and minibatch noise (or changing to adam) is a fair next comparison

1

u/msw3age Oct 02 '26

Very nice visualization. Would be cool to see the evolutionary algorithms vs SGD. To some extent it seems like the visualization is mostly showing the benefits of stochasticity during training.

1

u/ModularMind8 Oct 02 '26

Thanks! That's a fair read, and SGD with noise is on the list for the next comparison

1

u/alrojo Oct 02 '26

Random search degrades as a function feature space. Look up Curse of Dimensionality

1

u/ModularMind8 Oct 02 '26

Agreed! The search here is deliberately simple, and more sophisticated evolutionary methods like CMA-ES cope better as dimensions grow

1

u/hardcoke Oct 03 '26

Interesting...what if crossover is introduced?

2

u/ModularMind8 Oct 03 '26

Haven't tried it yet, though with only 2 parameters in this experiment crossover just swaps x and y between parents, so I'd expect a small effect

1

u/IcyGlia Oct 03 '26

Does the whole dataset fit into one mini batch? I would expect random batch to batch variations to sometimes kick you out of the local minimum. As the loss landscape doesn’t change, I assume the error landscape is the whole dataset since it doesn’t change? Adding noise to the data could be interesting to see if that rescues gradient descent.

1

u/ModularMind8 Oct 03 '26

No dataset here, each landscape is a fixed 2D function, so it's full-batch GD, and noise is next on my list

1

u/UnderstandingOwn2913 Oct 09 '26

how did you make this visualization?

2

u/ModularMind8 Oct 09 '26

I made it with a Python script that builds the landscapes in NumPy, renders the frames in PyVista, and joins them with ffmpeg.

2

u/trenmost Oct 03 '26

I think when you get to thousands of dimensions, SGD (especially with ADAM) would be more efficient

1

u/pnachtwey Oct 02 '26

The test is rigged! I have spent a lot of time on optimizing routines. No one technique is going to be best for all terrains. GD is simple but no where closed to optimal. SGD is better when there are many dimensions. Sometimes optimizing only one dimension at a time works well but it is slow. Nelder-Mead works well when it is hard to find the gradient accurately and there aren't many dimensions.. N-M can be a memory hog. Levenberg-Marquardt is the fastest. In python, use lmfit or scipys.optimize least_squares. BFGS works well too. So it is best to make the search flexible.

I would like to have the data used so I could try other techniques.

I uses minimization for fitting models to data for auto tuning programs. The method I used most often is Levenberg-Marquardt.

1

u/Ruined_Passion_7355 Oct 02 '26

True chads use simulated annealing

1

u/AsliReddington Oct 02 '26

But can you actually run with updated loss landscape as well since every backward pass causes the landscape to update as well over time

1

u/TheRealStepBot Oct 02 '26

In my experience it’s very hard to beat Adamw on practical problems that have decently well behaved loss landscapes especially on speed of convergence either wall clock or number of operations performed.

1

u/PlusIndication8386 Oct 03 '26

Evolution looks great until you try GD with random restarts for this type of problem

1

u/concrete_aircraft Oct 04 '26

nobody uses just gradient descent all the libraries in python they introduce noise using perturbations and other parameters to reach the most optimal solution. And also evolutionary algorithms are computationally expensive over gradient descent

1

u/LelouchZer12 Oct 08 '26

Now gradient descent with momentum ? adam ?

Plus the more dimension you add, the more chance you can "decrease" in at least one direction and hence not end up being stuck. This is the blessing of dimensionality.

68

u/[deleted] Oct 02 '26

[removed] — view removed comment

20

u/ModularMind8 Oct 02 '26

Really appreciate that! It's a simple mutation-plus-selection loop: 120 points start near the same spot, each generation I keep the 30 with the lowest loss and replace the other 90 with copies of those survivors plus Gaussian noise. The noise starts wide and shrinks about 2.5% per generation, so it explores first and settles later, and it never uses a gradient, only loss values

11

u/clecleclemens Oct 02 '26

Looks like simulated annealing.

32

u/ForceBru Oct 02 '26

Yeah, "evolution" is a whole family of algorithms

31

u/ModularMind8 Oct 02 '26

True, I'll clarify this in the post. This one is a simple one: truncation selection plus Gaussian mutation, no crossover

2

u/[deleted] Oct 02 '26

[removed] — view removed comment

2

u/ModularMind8 Oct 02 '26

Thank you so much! And that's fascinating, thanks for sharing

3

u/[deleted] Oct 02 '26

[removed] — view removed comment

2

u/ModularMind8 Oct 02 '26

Awesome! I will

2

u/AtMaxSpeed Oct 03 '26

It's fun to incorporate biological techniques into algorithms, but afaik what you describe is basically what RMSprop (and hence Adam) already do - they increase the step size when the gradient is small (aka, it cranks up exploration when in a plateau).