News for hackers. Stuff that matters.
Re:Neural programmer better than Quicksort by ghj on Friday July 10, 2020 @02:41AM (#23788829)
It's really hard to write correct code.

Sorting was broken in java and nobody noticed for a long time: http://envisage-project.eu/wp-content/uploads/2015/02/sortin...

The same was true for java's binary search: https://ai.googleblog.com/2006/06/extra-extra-read-all-about...

So I am not sure I will ever trust an ML algorithm trained on inputs/outputs only (which is what I think "neural program induction" means). The above bugs are only hit because the programmers who wrote it didn't think about overflow. What is this "neural programmer" assuming about their inputs? We'll never know.

OTOH the standard library sort can be improved if you know the distribution of the numbers you're sorting (e.g., small numbers can bucket sort, small lists can use a sorting network, etc). If this thing can efficiently almost-correctly-sort because it's better at these types of pattern matching, we can just run a final pass of insertion sort to make it useful!

Re:Neural programmer better than Quicksort by malisper on Friday July 10, 2020 @03:23AM (#23789043)
> OTOH the standard library sort can be improved if you know the distribution of the numbers you're sorting (e.g., small numbers can bucket sort, small lists can use a sorting network, etc). If this thing can efficiently almost-correctly-sort because it's better at these types of pattern matching, we can just run a final pass of insertion sort to make it useful!

I haven't read this paper, but that strategy was exactly the strategy behind "The Case for Learned Index Structures"[0]. The idea was you could train a model to predict the location of a row based on a primary key. After computing the model, you could then go through every row and compute a bound on how far off the model is from the actual row. To perform a lookup, you start off at the model's guess, then look around based on the bound on the model for a row with the given primary key.

[0] https://arxiv.org/abs/1712.01208

Re:Neural programmer better than Quicksort by eru on Friday July 10, 2020 @09:37AM (#23791325)
> If this thing can efficiently almost-correctly-sort because it's better at these types of pattern matching, we can just run a final pass of insertion sort to make it useful!

Depends on what kinds of mistakes the almost-correct approach makes. If it just puts elements in the wrong order, your suggestion works. But if it makes mistakes like duplicating elements, or dropping them, or completely making up new entries, no post-processing will help.

> OTOH the standard library sort can be improved if you know the distribution of the numbers you're sorting (e.g., small numbers can bucket sort, small lists can use a sorting network, etc).

Even better: the standard library sort usually assumes only comparison. For special cases like sorting on integer keys you can conceivably do better.

Re:Neural programmer better than Quicksort by ogogmad on Friday July 10, 2020 @11:25AM (#23792447)
> Depends on what kinds of mistakes the almost-correct approach makes. If it just puts elements in the wrong order, your suggestion works. But if it makes mistakes like duplicating elements, or dropping them, or completely making up new entries, no post-processing will help.

The algorithm modifies the original list only by swapping entries. As such, it's guaranteed to result in a permutation.

Re:Neural programmer better than Quicksort by eru on Saturday July 11, 2020 @01:00AM (#23799641)
Yes, in that case the post-processing would work.

But it also limits their system to in-place algorithms only.

Re:Neural programmer better than Quicksort by gryz on Sunday July 12, 2020 @07:01AM (#23810472)
Why is this limitation? Do you think the algorithm can be improved if it was doing a copy to a new location?
Re:Neural programmer better than Quicksort by im3w1l-alt on Friday July 10, 2020 @10:58AM (#23792122)
If you let the number of objects to sort go to infinity while keeping size of objects in bits capped, then they will behave like integers.
Re:Neural programmer better than Quicksort by eru on Friday July 10, 2020 @11:03AM (#23792188)
I thought more of being able to do bit manipulation or hashing etc on your keys. Those things don't necessarily require a fixed key length. (And in some languages, even integers don't have a fixed length.)

You are right in some sense, but you'd still have trouble implementing something like bucket sort in your setting, if all you have are comparisons.

Re:Neural programmer better than Quicksort by mpfundstein on Friday July 10, 2020 @03:07AM (#23788963)
IMO its not about replacing deterministic algorithms used in van Neuman machines (even though that would be a nice side effect).

I feel that if we ever want to build an intelligent problem solver machine, we need some facility for abstract reasoning and work like this papet is a major contributor towards that goal. (if its reproducible and valid ofc...)

Re:Neural programmer better than Quicksort by pansa2 on Friday July 10, 2020 @04:12AM (#23789289)
> I am not sure I will ever trust an ML algorithm trained on inputs/outputs only

It’s doing TDD!

Re:Neural programmer better than Quicksort by jtms on Friday July 10, 2020 @11:06AM (#23792219)
Imagine a world where all programmers do is write the tests and the generalized learning algos write all the implementations.
Re:Neural programmer better than Quicksort by GedByrne on Saturday July 11, 2020 @05:29AM (#23800745)
No need to imagine. That would just be Declarative Programming going mainstream?

Its just that algorithms like the Prolog’s WAM or the reet used in rules are replaced with neural nets and the like.

Rules use the same When Then format acting on a Given fact base. Prologs Horn Clauses can easily be translated into that form.

BDD writes all tests in the format Given When Then.

It’s already here.

Re:Neural programmer better than Quicksort by makapuf on Friday July 10, 2020 @03:52PM (#23795633)
Welcome to my company a few years ago. Except they were not programmers but PM and architects, and algos were subcontractors. Now we have real developers (I'm in one of those teams)
Re:Neural programmer better than Quicksort by klyrs on Friday July 10, 2020 @09:26PM (#23798576)
That's such a big pile of yikes, I'm morbidly drawn to see that codebase.
Re:Neural programmer better than Quicksort by vertbhrtn on Sunday July 12, 2020 @04:34AM (#23809868)
I'm pretty sure the generated code will be an incomprehensible mess that passes precisely those tests and nothing more, e.g. it would correctly sort arrays [1,3,2] and [3,2,1], but not [2,1,3]; and obviously not [1,4,2], because the specs didn't mention number 4.
Re:Neural programmer better than Quicksort by nardi on Friday July 10, 2020 @02:55AM (#23788903)
Next step is to prove the ML-produced algorithm is correct. I can see a world where we generate algorithms and then automatically prove they're correct based on a formal description of the problem being solved.
Re:Neural programmer better than Quicksort by bufferoverflow on Friday July 10, 2020 @07:20AM (#23790342)
It doesn't need to be 100% correct. There's a place for fast sorting algorithms which are correct most of the time - basically anything non-critical, like sorting comments by upvotes.

According to the article, they couldn't find a case where it wasn't correct.

Re:Neural programmer better than Quicksort by jcelerier on Friday July 10, 2020 @10:54AM (#23792067)
> There's a place for fast sorting algorithms which are correct most of the time - basically anything non-critical, like sorting comments by upvotes.

Nothing saddens me more than this trend of the modern web where everything works semi-probabilistically (even if it's likely for "good" technical reasons, such as, "we wrote our server backend in Ruby which is slow as molasses so now we need 230 CDN and 800 databases instances around the whole world and transformed our simple centralized problem into an horrendous decentralized one).

The central reason for me to use computers is that they are (or at least were) deterministic to a much higher degree that normal life, and so many things in the 10 last years becoming much more non-deterministic in particular on social websites is something that frustrates me every single day as it just makes the whole experience and process of using computers & the web very unreliable compared to what it used to be.

Re:Neural programmer better than Quicksort by gdoptimizer on Friday July 10, 2020 @11:30AM (#23792515)
Jim Keller once said randomness was baked in the modern computer chip design. The execution routes were almost always different even if you ran the same deterministic code for multiple times. But in the end you got the same result almost every single time (“almost” has many 9s after the decimal point). But this layer of operations has been abstracted away from most of us. So don’t feel too sad... maybe the world has been like this for a long time
Re:Neural programmer better than Quicksort by diegoperini on Friday July 10, 2020 @11:05AM (#23792195)
Today's perfections are yesterday's "good enoughs". Don't be sad for the trend. In 10 years, you will have new perfections to enjoy.
Re:Neural programmer better than Quicksort by UncleOxidant on Friday July 10, 2020 @01:20PM (#23793866)
Like the probabilistic bank account balance. "You have between $10 and $1000 with the greatest likelihood being $537 (52% chance)."
Re:Neural programmer better than Quicksort by FabHK on Friday July 10, 2020 @02:55PM (#23794965)
There was this thread a while ago with HSBC switching to MongoDB... so, yeah, distinct possibility :-)

https://news.ycombinator.com/item?id=23507197

(The article was very light on details though, and it was probably just one team that consolidated to MongoDB, not the accounts itself... one hopes.)

Re:Neural programmer better than Quicksort by adonese on Saturday July 11, 2020 @02:50AM (#23800141)
A friend of mine went to a doctor, and after the medical lab the doctor told him you either have malaria or typhoid.

This trend seems to be everwhere

Re:Neural programmer better than Quicksort by ojbyrne on Friday July 10, 2020 @11:36AM (#23792591)
I think the good technical reasons are quite often the CAP theorem.
Re:Neural programmer better than Quicksort by jcelerier on Friday July 10, 2020 @01:00PM (#23793589)
I know, but my argument is that a lot of time (not always, of course) the "distributed" issues could just be solved by not building a distributed system in the first place and just having more efficient tech stacks & a few big servers.

Stackoverflow was just using 4 db servers in 2016 (https://nickcraver.com/blog/2016/02/17/stack-overflow-the-ar...)

Re:Neural programmer better than Quicksort by adrianN on Friday July 10, 2020 @03:20AM (#23789022)
We suck really hard at proving code correct that was written explicitly with the goal in mind to be formally verified. The techniques there are still quite immature. I wonder how long it will take until we have a reasonably working pipeline of ML+formal verification. Maybe it's just easier to generate correct code from the spec than to learn it from examples and then verifying it with the specification?
Re:Neural programmer better than Quicksort by hutzlibu on Friday July 10, 2020 @04:34AM (#23789400)
"We suck really hard at proving code correct that was written explicitly with the goal in mind to be formally verified."

That is why I am not a huge fan of proving code in the first place. If you have a really complicated proof of formal correctness, then who guarantees you, there is no misstake in the proof itself? At least this is what I have seen in university, lots of complicated stuff on the whiteboard, with a result. And then someone figured out, it was wrong.

So I rather do lots of testing, for all known test cases.

Re:Neural programmer better than Quicksort by adrianN on Friday July 10, 2020 @04:59AM (#23789523)
Your automatic proof checker guarantees that there is no mistake in the proof. That's the easy part! The real question is who guarantees that your specification is what you actually want?
Re:Neural programmer better than Quicksort by infinity0 on Friday July 10, 2020 @05:48AM (#23789752)
Automatic proof checkers still have bugs in them. However, one nice characteristic is that, since its algorithms are so general, i.e. about the language rather than about the problem you're solving (e.g. sorting), any bugs in the checker are either so common they hit every problem solution and are easily discovered and fixed, or so rare that it affects no real-world problem solutions.
Re:Neural programmer better than Quicksort by adrianN on Friday July 10, 2020 @05:53AM (#23789776)
The kernel of an automatic proof checker is much easier to test and verify than the programs you verify using a proof checker though.
Re:Neural programmer better than Quicksort by chrisandchips on Friday July 10, 2020 @06:49AM (#23790125)
+1 verification tends to be the easy part.
Re:Neural programmer better than Quicksort by infinity0 on Friday July 10, 2020 @10:29AM (#23791776)
Sure, not all bugs are kernel bugs though.
Re:Neural programmer better than Quicksort by louthy on Friday July 10, 2020 @06:07AM (#23789857)
> So I rather do lots of testing, for all known test cases.

How is this any different? You can still make mistakes in your test code, test data, omit cases that would fail, etc. I think I'd be less confident in a set of unit tests than I would with an automated proof checker.

Re:Neural programmer better than Quicksort by hutzlibu on Friday July 10, 2020 @06:29AM (#23789983)
Tests are simple to unterstand.

Complicated proofs I do not understand, without much effort.

And I surely know that you can make mistakes with test cases as well. So I surely do not claim my way to be superior. But it works way better for me.

Re:Neural programmer better than Quicksort by eru on Friday July 10, 2020 @09:39AM (#23791346)
Test cases are not necessarily simple to understand.

Especially the test cases needed to trigger some deep bug.

Re:Neural programmer better than Quicksort by gnufx on Friday July 10, 2020 @04:13PM (#23795900)
And so aphyr gets paid, for instance. You may not even be able realistically to run a test case. The laws of life say your 10000 core compute job will fail non-deterministically only after a day or so. It would clearly be helpful to have at least some formal guarantees, such as liveness at some level.
Re:Neural programmer better than Quicksort by rusticpenn on Friday July 10, 2020 @03:02AM (#23788937)
Well designed ML techniques are always correct 99% of the time. Its the 1% that is the problem.
Re:Neural programmer better than Quicksort by ukj on Friday July 10, 2020 @03:04AM (#23788947)
99% of the time it works all of the time.

Like humans.

How do we deal with problematic humans?

Retraining or replacement.

Re:Neural programmer better than Quicksort by adrianN on Friday July 10, 2020 @03:22AM (#23789035)
No, we deal with 99% accuracy in humans by designing all our human-based algorithms to be resilient against mistake (and still mistakes in the end result happen very frequently). This is completely different from the way we have designed our computer systems, because it's way easier to do this with flexible agents like humans than with inflexible agents like computers.
Re:Neural programmer better than Quicksort by ukj on Saturday July 11, 2020 @04:23AM (#23800504)
So, the mistakes algorithms make are different to the mistakes humans make?

That’s... equivocation.

Both humans and ML algorithms are flexible. That is the point of “learning”.

Adaptation.

Re:Neural programmer better than Quicksort by Random_ernest on Friday July 10, 2020 @03:22AM (#23789039)
But the problems where we apply human labour are vastly different from the ones where we apply machine labour. In (most) tasks where we apply human labour a few errors are tolerated.
Re:Neural programmer better than Quicksort by ukj on Saturday July 11, 2020 @04:32AM (#23800537)
This seems irrelevant.

Neither humans nor ML make zero errors.

Ceteris paribus, if an ML algorithm makes fewer errors at a task which with low error tolerance - you would use the algorithm instead of the human, no?

Re:Neural programmer better than Quicksort by mtrower on Sunday July 12, 2020 @12:38AM (#23808863)
I would expect that might depend on what sort of errors each make, no?
Re:Neural programmer better than Quicksort by rusticpenn on Friday July 10, 2020 @07:47AM (#23790534)
That is not practical when you expect the system to be correct 100% of the time and make decisions based on that. There are many situations where this is critical. You would never want your car's safety system to be correct only 99% of the time.
Re:Neural programmer better than Quicksort by ukj on Saturday July 11, 2020 @04:33AM (#23800540)
If you expect 100% correctness you are not a very practical man.

Perfect is the enemy of good enough.

Re:Neural programmer better than Quicksort by mtrower on Sunday July 12, 2020 @12:39AM (#23808867)
And good enough is the enemy of perfection.

I suppose it depends on your end goals.

Re:Neural programmer better than Quicksort by ukj on Sunday July 12, 2020 @04:17PM (#23814419)
Over-achievement of my goals is not my goal.
Re:Neural programmer better than Quicksort by fiblye on Friday July 10, 2020 @04:01AM (#23789226)
With humans, we can ask what went wrong and fix the problem.

With black box algorithms, we throw in some new training data and just hope it's enough.

Re:Neural programmer better than Quicksort by andybak on Friday July 10, 2020 @04:25AM (#23789356)
> With humans, we can ask what went wrong and just hope we've fixed the problem.

> With black box algorithms, we throw in some new training data and just hope it's enough.

A small wording change and they're equivalent again.

To some extent human beings are also a black box - with some very peculiar failure conditions and side-channel weaknesses.

Re:Neural programmer better than Quicksort by bufferoverflow on Friday July 10, 2020 @07:25AM (#23790375)
No, we don't do anything against the humans who are 99% correct. 99% is good enough in most real world cases.
Re:Neural programmer better than Quicksort by bryanrasmussen on Friday July 10, 2020 @03:44AM (#23789135)
what's the promote option in this analogy?
Re:Neural programmer better than Quicksort by ukj on Saturday July 11, 2020 @04:36AM (#23800551)
ML took your job.
Re:Neural programmer better than Quicksort by Cthulhu_ on Friday July 10, 2020 @03:51AM (#23789175)
Call me naive but, wouldn't feeding it random input and expected output sorted by existing and proven (but slower) sorting algorithms do the trick?
Re:Neural programmer better than Quicksort by Scea91 on Friday July 10, 2020 @04:09AM (#23789273)
For an exact proof of correctness no, because that would only show the algorithm is correct for a selected set of input-output pairs.

However, it is true that validating it for a very large number of inputs and outputs has value. This is not uncommon even in mathematics. For example, Goldbach's Conjecture (https://www.wikiwand.com/en/Goldbach%27s_conjecture) has not been proven but has been shown to hold for all integers less than 4 × 10^18

Re:Neural programmer better than Quicksort by exdsq on Friday July 10, 2020 @04:26AM (#23789362)
This is done! The existing correct algorithm is called the oracle and it’s used to validate the generated algorithm.

There’s some cool work on using neural program induction in compilers to try generate faster implementations based off the ‘oracle’ program that’s being compiled.

Re:Neural programmer better than Quicksort by algo_trader on Friday July 10, 2020 @08:02AM (#23790635)
> neural program induction in compilers to try generate faster implementations

Can u provide more details?

I am familiar with garden-variety ML-optimization-of-combinatorical-space in compilers.

How would u even "measure" the expected performance unless these are gradual greedy changes

Re:Neural programmer better than Quicksort by Shorel on Friday July 10, 2020 @11:16AM (#23792340)
It would be funny if a two phase approach to sorting would result in increased average performance.

First sort using the ML algorithm. Then sort the almost sorted result with a traditional algorithm optimized for almost sorted results.

In fact, I think my own brain does the two phase approach to many problems.

Re:Neural programmer better than Quicksort by _puk on Friday July 10, 2020 @04:34PM (#23796125)
Could you train the ML algorithm to select the best traditional algorithm based on the distribution of the items being sorted?!
Re:Neural programmer better than Quicksort by User23 on Friday July 10, 2020 @12:54PM (#23793523)
> The same was true for java's binary search

I used to ask "implement binary search" as an interview question and gave up on using it because not a single candidate could do it correctly in 45 minutes. This was at a FAANG.

Re:Neural programmer better than Quicksort by vertbhrtn on Sunday July 12, 2020 @04:56AM (#23809963)
Ha, I can get an offer from any of the FAANG without even trying and can comfortably say that not only I failed the binary search question in past when interviews were 1 hour long, I would still fail it now.
Re:Neural programmer better than Quicksort by Der_Einzige on Friday July 10, 2020 @01:05PM (#23793649)
I don't believe you. Surely, after a few hints, the FAANG canidates must have been able to figure out the classic gotcha of this question (why does this sometimes overflow and how do you fix {high + low / 2})

If they didn't, than I believe you did a poor job of guiding them. I refuse to believe that this is some esoteric, tough question. If you can solve dynamic programming problems, you can easily solve this one.

Re:Neural programmer better than Quicksort by nardi on Friday July 10, 2020 @01:16PM (#23793800)
I interview tons of candidates at a FAANG company, and I can tell you for sure binary search is way too hard to get right on a whiteboard. Even in a proper coding environment I wouldn't ask it. There are lots of better questions with fewer sharp edges.
Re:Neural programmer better than Quicksort by Der_Einzige on Friday July 10, 2020 @02:24PM (#23794631)
What else is hard besides converting

(high + low) / 2

To

Low + (high - low) / 2

What else about this problem is a "sharp edge"?

Re:Neural programmer better than Quicksort by nardi on Friday July 10, 2020 @02:38PM (#23794797)
I may have been a little too harsh. Binary search is close to being a good interview question, especially since the algorithm does, rarely, come up in real code. But I prefer questions that are more like what people will be doing in their day-to-day job, and binary search is just a little too fiddly.
Re:Neural programmer better than Quicksort by CamperBob2 on Friday July 10, 2020 @04:07PM (#23795815)
Me: "Show me a binary search in C on the whiteboard."

Candidate: bsearch(key, base, num, size, compare_fn);

Me: "Your offer should arrive within one to two weeks. Need any help with relocation expenses?"

Re:Neural programmer better than Quicksort by nardi on Friday July 10, 2020 @04:21PM (#23795992)
100% this. Maybe not everyone knows the specific function you’re looking for, but for the ones that know standard library APIs really well, that’s your hire.
Re:Neural programmer better than Quicksort by User23 on Friday July 10, 2020 @06:17PM (#23797222)
I wouldn’t say so. In theory you’d expect a FAANG engineer to be able to construct a correctly terminating loop by reasoning about the loop invariant, but in practice every single candidate gets lost in guesswork and messing up the edge cases and termination condition.
Re:Neural programmer better than Quicksort by DaiPlusPlus on Friday July 10, 2020 @03:27PM (#23795340)
Apparently modern GPUs have sorting-networks implemented in hardware (giving you effectively constant-time sorting for fixed-size input) - which may be preferable for use if you’re processing hostile input which may be contrived to hit QuickSort’s worst-case and the cost of hitting the PCI Express bus is less than the cost of randomizing the input to mitigate QuickSort attacks.

But yes - I agree it’s weird that many standard-libraries (looking at you, .NET!) have only a single `Sort` method oh their vector-types with the details of the implementation buried in the documentation instead of shipping with a first-class sorting-algorithms library.

Re:Neural programmer better than Quicksort by david-gpu on Friday July 10, 2020 @05:28PM (#23796706)
GPUs having hardware explicitly for sorting sounds a bit odd, when you can efficiently implement sorting networks in software on the same GPU.

If you have a source, I would like to learn more.

Re:Neural programmer better than Quicksort by KajMagnus on Friday July 10, 2020 @04:43AM (#23789451)
> "just run a final pass of insertion sort to make it useful!"

(And if this insertion sort won't complete in O(n), say <= 3n, then, fallback to Quicksort, so won't turn into O(n^2) just because the ML alg hit a corner case)

Re:Neural programmer better than Quicksort by mkl on Friday July 10, 2020 @06:34AM (#23790018)
Possibly better would be Timsort (used in Python, Java, V8, etc.), as it's "designed to take advantage of runs of consecutive ordered elements that already exist": https://en.wikipedia.org/wiki/Timsort
Re:Neural programmer better than Quicksort by eru on Friday July 10, 2020 @09:41AM (#23791365)
Haskell's standard library sort, a variant of merge sort, also makes use of runs.

It runs in O(n log (number of runs)). It's quite a lot simpler than Timsort.

Re:Neural programmer better than Quicksort by YeGoblynQueenne on Friday July 10, 2020 @12:20PM (#23793102)
>> So I am not sure I will ever trust an ML algorithm trained on inputs/outputs only (which is what I think "neural program induction" means).

According to the authors, the proposed approach is notable for training not only on input/output pairs but also on program traces. In addition, reinforcement learning is used to train e.g. sorting agents on the behaviour of "teacher agents" that comprise hand-crafted implementations of well-known sorting algorithms (bubble- insertion- and quick-sort).

Re:Neural programmer better than Quicksort by eli_gottlieb on Friday July 10, 2020 @02:11PM (#23794494)
>So I am not sure I will ever trust an ML algorithm trained on inputs/outputs only (which is what I think "neural program induction" means).

Pfffft, just wait until they get it writing code with its own proofs of correctness in dependent type theory. It'll be correct and twice as unreadable as incorrect human-written code!

Re:Neural programmer better than Quicksort by riedel on Friday July 10, 2020 @03:43AM (#23789127)
Why not check in $n$ on a sorted if the postcondition holds or raise an exception otherwise. You can even generate a nearly sorted list and run a verified bubblesort. Don't see big problems if ML is used carefully.
Re:Neural programmer better than Quicksort by fdupress on Friday July 10, 2020 @05:06AM (#23789556)
Checking that the output is sorted is the easy part.

Checking that the output is a (optionally stable) permutation of the input is the hard part. You can't do that dynamically if you have, for example, overwritten your input by sorting in place. And making a copy of your input is only going to be affordable in very specific and small instances on which you might as well just run a well-understood algorithm.

Re:Neural programmer better than Quicksort by ogogmad on Friday July 10, 2020 @05:53AM (#23789769)
It looks like their algorithm can only modify the input list by swapping elements. This is guaranteed to result in a permutation.