Better HN
topnewbestaskshowjobs
Log inSign up

LightMachine

2,083 karma · joined Sep 27, 2015 (11y ago) · 346 submissions

Submissions

comment 3y ago · link · parent

> If you are falling into despair then it's going to be superdeterminism for you.

If you don't believe in fairy tales nor assume the existence of a magic mysterious force named "free will" *

comment 3y ago · link · parent

I mean that interpretations have practical implications because they're the only way to find the true laws of physics, which in turn has obviously applications. For example, if you believe in superdeterminism, and you obviously should, then that will save a lot of work researching dead ends (like multiverse stuff), which will make us find the correct algorithms faster.

comment 3y ago · link · parent

Wait isn't that the common assumption? That the universe is just an algorithm and we're trying to figure which is it?

comment 3y ago · link · parent

And it is absurd to say it has no direct practical implications. We still don't know all of physics, and part of the reason is precisely because we're stuck in the wrong mindset regarding how nature works. Only a better insight on the true nature of the universe can give us the correct mathematical models.

215.

HVM, the parallel runtime: a summary of its history and next steps(twitter.com ↗)

6 points · by LightMachine · 4y ago · discuss

comment 4y ago · link · parent

So Reddit mods shadow-banned me on /r/cryptocurrency for posting a technology? I wonder why they'd do that.

comment 4y ago · link · parent

Well, I didn't think about that possibility. Perhaps that's what happened, yes. But why not just remove the post and let me know the reason? This is really sketchy to me. It feels like manipulation, but perhaps I'm being unfair.

comment 4y ago · link · parent

Kindelia is a p2p decentralized computer I'm building. It is essentially a massively distilled version of Ethereum. It is massively simpler (<10k LOC), more efficient (up to 867x more SSTORE/second under the same usage level), and secure (since it supports Agda, Lean, Kind and other proof languages natively). It is completely decentralized, there is no pre-mine (in fact, there isn't even a currency). My post was 100% respectful and fair, I was just explaining the tech, no ads, no sales. I was banned because I posted a new tech.

This has to be exposed. If people can't create and propose new projects, then it has became a rigged game that only the elite can win. How is that better than fiat?

219.

/r/cryptocurrency mods shadow-banned me for posting Kindelia's whitepaper(old.reddit.com ↗)

10 points · by LightMachine · 4y ago · 8 comments

comment 4y ago · link · parent

You can have virtual game worlds (like a MMORPG) that can't ever be turned off, by nobody. That means your items will last forever. 50 years from now, your sword will still be on your backpack. Can't say that for company-hosted MMORPGs like World of Warcraft, because these companies might go bankrupt, close servers, update items, etc. Not a cure-the-cancer colonize-mars hype level, of course, but it is still an interesting neat thing you can do with blockchains.

comment 4y ago · link · parent

> Whenever Ruby throws, it allocates 10k of memory and fills it with all sorts of information for debugging - including a full stack trace. And it was doing this work in the background every time someone iterated through an array.

Jesus

comment 4y ago · link · parent

They're inexcusably awful. I still don't know why it is like that. Haskell gets hard things right and easy things terribly wrong.

comment 4y ago · link · parent

Looks good. I'll keep that in mind and let you know if we write such a benchmark. Opening an issue would be helpful to remind us!

comment 4y ago · link · parent

It does that! There are no GC pauses on HVM's model. Compiling Haskell to it would be neat.

comment 4y ago · link · parent

That isn't how it works. HVM threads work transparently, you don't need to think about them. The same data structure *can* be visible to multiple threads under some conditions, through cloning; for example, consider the following program:

    (Sum Nil        )  = 0
    (Sum (Cons x xs))  = (+ x (Sum xs))
    (Head (Cons x xs)) = x

    (Main x) =
      let xs = (Cons 1 (Cons 2 (Cons 3 Nil)))
      (Pair (Sum xs) (Head xs))
The result of this program is `(Pair 6 1)`. Since `Pair` is the topmost (root) node of the normal form, each of its elements will be computed in a separate thread. Because of that, the same `[1,2,3]` list will be accessed by each thread. But that's not actually a shared reference, because values only exist in one place; instead, the lazy cloner makes copies of the list, layer-by-layer, and sends these copies to the thread that will handle them.

Note that if the same expression was written in a deeper position of the normal form, it would be evaluated sequentially. This is what avoids the fine-grained parallelism issue. It also means that in many cases HVM will not be as parallel as it could, though! But when the parallelism kicks in, it is always productive.

comment 4y ago · link · parent

> That is not always true. There’s some overhead to introducing parallelization so it’s not always worth it unless you have a big enough chunk of work.

This isn't fine-grained parallelism though! As I said, HVM spawns threads on to-be-evaluated redexes closes to the root of the program's normal form. So, either there is a significant speedup, or the program is sequential (or too small), and there is no speedup, but the overhead is minuscule, since a bounded, small amount of spawn() occurs. To be clear: there is no situation where HVM's parallelism will make the program significantly slower, which *does* happen if you use too many sparks on Haskell. That will never happen on HVM.

> But the other reason fine grained parallelism isn’t often worth it even if it can provide a speedup for a single computation:

Yep that's definitely a good reason. Thanks for sharing. (You can just run HVM in a single thread, though.)

> It’s very cool in a “wow that’s neat” kind of way, but, well we already have machine ints that are even faster

I couldn't disagree more. Just because I used integers as an example, which happens to be optimized, it means an entire optimization technique isn't interesting? This applies to every data structure that can be defined algebraically.

> My other question - it seems like this approach requires giving up on separate compilation?

Compiling a function in isolation is fine, why wouldn't it be? Not sure I get it.

comment 4y ago · link · parent

I don't think the authors are focused on engineering matters; they're researchers after all. But that's just my guess. Also, there is an obsession with covering the full λ-calculus, which the abstract algorithm doesn't. A lot of energy has been put in that. I think this is just wrong. Rust has severe limitations on how you can write lambdas. HVM has some, which seldom occur in practice.

Regardless, some people did try implementing this in practice, dozens of times, including myself. It just wasn't that fast except for these cases where the asymptotics are superior. A naive implementation just stores graphs/edges on memory, but most of these edges are redundant. For example, a lambda doesn't need to point to its parent. By trying to turn the graph in a tree, I've ended up with SIC [0], which, once implemented efficiently, cut down memory and computation costs significantly. Doing so was tricky, specially because 1. the missing edges complicated the transversal; 2. some upward edges can't disappear (variables); 3. DUP nodes aren't part of expressions, they just "float", which was counter intuitive to get right. Finally, I learned to appreciate the fact that global rewrite rules are better than case-trees for recursive functions, since they greatly reduce the total rewrite count.

So, in short, my journey was:

1. Learn the abstract algorithm

2. Implement it naively as a graph

3. Optimize it by making trees whenever possible

4. Favor rewrite equations over case-trees

These steps lead to the design of HVM, which does fairly well in practice.

[0] https://github.com/VictorTaelin/Symmetric-Interaction-Calcul...

comment 4y ago · link · parent

`dup a b = {x0 x1}` will just substitute `a` by `x0` and `b` by `x1`, no matter where `a` and `b` are. So, if you apply that, verbatin, to:

    (Pair λx0(λy0(Pair a c)) λx1(λy1(Pair b d)))
You get:

    (Pair λx0(λy0(Pair x0 c)) λx1(λy1(Pair x1 d)))
Does that make sense?

comment 4y ago · link · parent

There aren't. Kind is more stable, is more JS-looking and less Haskell-looking, which makes it more practical IMO, has a super fast JS compiler and you can write React-like apps on it easily, but some work is needed to improve the type-checker performance when certain syntax sugars are used. The core's performance is superb, though.

Idris2, I can't comment much. All I know is that I envy its unification algorithm and synthesis features. Its syntax is more haskellish, if you like that. It seems less mature in some aspects, though. Very promising language overall.

comment 4y ago · link · parent

Thank you!

comment 4y ago · link · parent

I know it needs improvements, there is even a disclaimer in the top of HOW.md. I'll go over it and improve sentences like that in a future.

comment 4y ago · link · parent

I do disagree with SPJ here, though. On HVM, you can have complete control over how the resources (both space and time) are used in your programs and algorithms. That is why it outputs the memory (space) and rewrites (time) cost of each program you run, and it is so precise you can even make formulas of how much memory and how many rewrites your functions will demand. You can absolutely have tight memory control in HVM, just like in C. Being lazy, high-level, etc. is NOT incompatible with that, I'd argue.

comment 4y ago · link · parent

Andrea Asperti's only mistake was thinking he was wrong.

comment 4y ago · link · parent

This is MIT licensed, so feel free to fork, use, edit and sell it without even notifying me. Now go ahead and get rich!

comment 4y ago · link · parent

You mean, the whole project? Or just the runtime? The runtime has recently been ported to go by Caue F. He posted it in our Telegram: https://pastebin.com/0X0bbW8b

Perhaps you could team up?

comment 4y ago · link · parent

I didn't want to be misleading, sorry. My reasoning was to just benchmark identical programs.

I personally think Haskell's approach to parallelism is wrong, though, since it demands in-code annotations to work. The problem is that the decision on whether an expression should be parallelized doesn't depend on the code itself, but on where the expression is used. For example, if `fib(42)` is the topmost node of your program's normal form, you always want to parallelize its branches (`fib(41)` and `fib(40)`), but if it is called in a deeply nested list node, you don't. That information isn't available on the code of `fib`, so placing "spark" annotations seems conceptually wrong.

HVM parallelizes by distributing to-be-evaluated redexes of the normal form among available cores, prioritizing these close to root. Here is an animation: https://imgur.com/a/8NtnEa3. That always seems like the right choice to me. After all, it just returns the same result, faster. I could be wrong, though. In which case you think parallelism isn't the correct choice? Is it because you don't always want to use the entire CPU? Would love to hear your reasoning.

> Like I get that it helps a lot if you’re doing multiplication with Church numerals…

This isn't about multiplication with Church numerals. Don't you find it compelling to write binary addition as "increment N times" and have it be as efficient as the add-with-carry operation? Making mathematically elegant code fast matters, and HVM does that. See the overview [0] for instance. Also, this allows us to have all the "deforestation" optimizations that Haskell applies on List with hardcoded #rewrite pragmas, for any user-defined datatype, which is also quite useful. There are certainly many uses that I'm not creative enough to think of.

[0] https://github.com/Kindelia/HVM/blob/master/HOW.md#bonus-abu...

comment 4y ago · link · parent

That is really not true, but I do agree Haskell passes that impression, for the wrong reasons. I'm working hard to fix these misconceptions on HVM, Kind-Lang and related projects!

comment 4y ago · link · parent

Since HVM is linear, adding some mutability would be completely fine and would NOT break referential transparency (because values only exist in one place!). So, we could actually have "pure mutable arrays". In order to make that mix up well with lazy cloning, though, we'd need to limit the size of array to about 16. But larger arrays could be made as trees of mutable 16-tuples. There was a post about it, but I can't find it right now.

comment 4y ago · link · parent

> On a quick scan, it seems to be some more things than just `let`. One example would be `(Main n) = (Sum (Gen n))` should be closer to `(define Main (n) (Sum (Gen n)))` or similar.

Good point.

> Could even get rid of the parenthesis for arguments (`(n)` => `n`) and treating forms inside `define` the same as `let`.

No, because non-curried functions are a feature. If we did that, every function would be curried. Which is nice, but non-curried functions are faster (lots of lambdas and wasteful copies are avoided using the equational rewrite notation), so they should be definitely accessible.

comment 4y ago · link · parent

I fixed the link. This is all part of the system described on the book, HVM is merely a very fast practical implementation. The additions (thinks like machine integers and constructors) don't affect the core.
1
789
12