14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 2y ago · link · parent
That said, you can do machine learning in WebGPU, and, if your goal is to ship in a browser, it is viable.
I personally think the performance gap can be closed with some engineering effort, and that WebGPU has the potential to become a real contender, but it's too early to say for sure. Certainly CUDA has a major head-start.
comment 2y ago · link · parent
I'll give one example (as it's one I was personally invested in). Doing a barrier in non-uniform control flow is wildly unsafe undefined behavior (I've had it reboot my computer, and it's easy to believe it could be exploited by malicious actors). To make these barriers safe WebGPU does a "uniformity analysis." However, that in turn required adding uniform broadcast intrinsic to the shader language, otherwise a class of algorithms would be impossible to express.
As I say, it's plausible this kind of work could have been done as extensions to WebGL, but I think the end result would have been a lot less compelling than what we have now.
comment 2y ago · link · parent
184.
I want a good parallel computer [video](youtube.com ↗)
15 points · by raphlinus · 2y ago · discuss
comment 2y ago · link · parent
A really good place to read up on it is the documentation for Chebfun.
https://www.chebfun.org/docs/guide/guide04.html
Also: be on the lookout for a blog post on using Chebyshev polynomials to efficiently compute error metrics for curves.
comment 2y ago · link · parent
My main point is that I believe there are tons of excellent numerical techniques just waiting to be discovered. Lately I've been exploring a Chebyshev polynomial basis for the Whewell equation, and I think that'll bear fruit.
comment 2y ago · link · parent
I also think Pythagorean Hodograph curves are overrated. Euler spirals, on the other hand, are extremely easy to work with in an arc length parametrization, it's just that you need to compute a "special function" to get back to parametrized land. Fortunately, that's easy enough to compute very accurately using standard numerical techniques.
comment 2y ago · link · parent
Of course, it's not unusual that the many layers of abstraction in modern systems actively frustrate getting real performance data. But dealing with that is part of the requirements of doing real engineering.
comment 2y ago · link · parent
Obviously the happy case is when all the audio processing is done in a DSP where scheduling is deterministic, but it's rare to be able to count on that. Part of the problem is that modern computers are so fast that people expect them to handle audio tasks without breathing hard. But that speed is usually measured as throughput rather than worst-case latency.
The advice I'd give to anybody building audio today is to relentlessly measure all potential sources of scheduling jitter end-to-end. Once you know that, it becomes clearer how to address it.
comment 2y ago · link · parent
The general rule of thumb is that a GPU has about 10x the raw throughput per joule as a CPU (which, today, is basically the same metric as throughput per dollar). So if your GPU is only barely faster than the CPU because of overheads of the parallel algorithm, you might not win, but if it sails way past the CPU because it's work efficient and lean (as I believe this work is), you do win both on power and throughput (frames per second).
comment 2y ago · link · parent
But it does mean that for outline-to-outline applications running on the CPU, methods like Skia's are likely better (though ours is still faster than the Nehab implementation).
I'm working on a cubic-to-cubic version also, but it's requiring some pretty deep math. See the Zulip thread to follow that work in progress[1].
[1]: https://xi.zulipchat.com/#narrow/stream/260979-kurbo/topic/C...
comment 2y ago · link · parent
[1]: https://github.com/linebender/gpu-stroke-expansion-paper
comment 2y ago · link · parent
195.
GPU-Friendly Stroke Expansion(arxiv.org ↗)
180 points · by raphlinus · 2y ago · 39 comments
comment 2y ago · link · parent
[1]: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD04xx/E...
[2]: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD05xx/E...
comment 2y ago · link · parent
There seems to some more detail in a Bachelors thesis by Phillip Grote[2], with lots of measurements of different synchronization primitives, but it doesn't go too deep into the hardware.
[1]: https://arxiv.org/abs/2205.11659
[2]: https://www.clemenslutz.com/pdfs/bsc_thesis_phillip_grote.pd...
comment 2y ago · link · parent
comment 2y ago · link · parent
I disagree that SIMT is only for embarrassingly parallel problems. Both CUDA and compute shaders are now used for fairly sophisticated data structures (including trees) and algorithms (including sorting).
[1]: https://developer.nvidia.com/blog/inside-volta/#independent_...
comment 2y ago · link · parent
[1]: https://mastodon.online/@johncarlosbaez@mathstodon.xyz/11258...
comment 2y ago · link · parent
I personally found the writing style of the proposal to be clearer than the tutorial-flavor of the original blog post (I haven't watched the video). But that's probably because I have a programming language background and am intimately familiar with Rust.
[1]: https://github.com/modularml/mojo/blob/main/proposals/lifeti...
comment 2y ago · link · parent
1. You need to formalize the semantics of unsafe Rust. Ralf Jung's pioneering RustBelt[1] work was a huge step in that direction, but it is not yet complete. One element that's emerging as tricky is "pointer provenance."
2. Part of that is making a formal model of the borrow checker. Stacked borrows[2] was a good attempt, but has some flaws. Tree borrows[3] may correct those flaws, but it's possible something even more refined may emerge.
3. Another part of that is a formal memory model, which is mostly about the behavior of atomics and synchronization (thus, is critically important for standard library components such as Arc). It is widely understood that Rust's memory model should be similar to the C++ one (and that they should interoperate), but there are some remaining flaws in that, such as the "out of thin air" problem and also some missing functionality like seqlocks (part of why the Linux kernel still has its own).
4. You need a proof that the safety guarantees compose well; in particular if you have sound code written in unsafe Rust, composed with other code written in safe Rust, the safety guarantees still hold. There are good results so far but it needs to be proved over the entire system.
5. You do need to close all the remaining soundness bugs in Rust[1], for such a proof to hold for all code. Progress on this is slow, as many of these problems are theoretical, or are only really relevant for adversarial code[5].
When all this is done, you still only have a partial guarantee. Huge amounts of the surface area to interface with the system are based on unsafe code. If you're doing only pure computation, that's one thing, but if you're building, say, a graphical UI, there's a massive amount of stuff that can still go wrong.
Even so, there is a practical path forward, and that leads to a much better situation than the usual state of things today, which is of course systems riddled with vulnerabilities.
[1]: https://people.mpi-sws.org/~dreyer/papers/rustbelt/paper.pdf
[2]: https://plv.mpi-sws.org/rustbelt/stacked-borrows/
[3]: https://www.ralfj.de/blog/2023/06/02/tree-borrows.html
[4]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Ao...
comment 2y ago · link · parent
Second, there's all the log-aesthetic stuff from Japan, [2] has links to a lot of papers. Honestly, I find their claims of aesthetic beauty to be fluffy, not backed up by hard empirical evidence. I did do a small amount of human evaluation research in [3], which suggests that the log-aesthetic curves are visually pleasing, but the math for their use in an interpolating spline (which is the subject of TFA) is less stable than Hobby splines, Euler spiral splines, or Minimum Energy Curves (all of which are fairly similar).
I think there's more that could be done here. Thanks for your question.
[1]: Fred Attneave. Some informational aspects of visual perception. Psychological Review, 61(3):183–193, 1954.
[2]: https://www.yoshida-lab.net/english/research-e/log-aesthetic...
comment 2y ago · link · parent
comment 2y ago · link · parent
I personally find this a fascinating topic, so much so that I did a PhD on it. The most natural loss function to optimize for is minimizing bending energy, and there are solutions to that going back about 300 years. However, in practice that's unlikely to be what you want - the problem with it is that its scaling properties give an advantage to curves with a longer arclength even if they have more curvature variation. Intuitively, the smoothest curve through a set of co-circular points should be a circular arc, but that's not what you get from the minimum energy curve, at least unless you impose an additional arc length constraint.
The long story is of course much more complicated, but the short version is that the Euler spiral fixes these scaling issues and has some other really nice properties. If your problem is "what is the smoothest curve that goes through this sequence of points" then arguably the piecewise Euler spiral G2 continuous spline is the distinguished answer.
comment 2y ago · link · parent
I think there's even more to be done on this topic. In particular, I think the tension should increase as angles go up, which can solve the "flipping" behavior you see with both Hobby and Euler spiral splines. This is true for the Adobe κ-curves paper (which considerably overstates the extent to which it's the basis for the "curvature" tool in Adobe Illustrator; the latter has not to my knowledge been adequately documented).
comment 2y ago · link · parent
I've worked out why I don't get much value out of LLMs. The hardest and most time-consuming parts of my job involve distinguishing between ideas that are correct, and ideas that are plausible-sounding but wrong. Current AI is great at the latter type of ideas, and I don't need more of those.
[1]: https://bsky.app/profile/martin.kleppmann.com/post/3kquvol6s...
comment 2y ago · link · parent
What kurbo does is lower to quadratic Béziers[1], then the analytic solution to nearest for a quadratic Bézier is the solution to a cubic equation[2].
I'm not sure this is the best possible answer, but it's at least pretty good, and certainly better than flattening to lines.
And I'd like for people to get in the habit of checking kurbo; the intent is for it to always have the best in class algorithm.
[1]: https://docs.rs/kurbo/latest/src/kurbo/cubicbez.rs.html#647-...
[2]: https://docs.rs/kurbo/latest/src/kurbo/quadbez.rs.html#297-3...