Readit News logoReadit News
mmorse1217 commented on 1.5 TB of VRAM on Mac Studio – RDMA over Thunderbolt 5   jeffgeerling.com/blog/202... · Posted by u/rbanffy
mmorse1217 · 2 days ago
Hey Jeff, wherever you are: this is awesome work! I’ve wanted to try something like this for a while and was very excited for the RDMA over thunderbolt news.

But I mostly want to say thanks for everything you do. Your good vibes are deeply appreciated and you are an inspiration.

mmorse1217 commented on Fast calculation of the distance to cubic Bezier curves on the GPU   blog.pkh.me/p/46-fast-cal... · Posted by u/ux
GistNoesis · 2 months ago
Thanks, that the same approach I was suggesting in my other comment in this thread https://news.ycombinator.com/item?id=45628245 . But couldn't find literature specific to the Bezier curves to help break the communication gap, and my specific knowledge of Bezier Curve isn't deep enough.

I am happy to see other people use the approach I consider more natural.

It's a generic global optimization approach and geometry is always full of pathological edge cases, so it's hard to tell if you miss any. Getting to work in the average case is usually easy, but to be sure it always work is much harder.

mmorse1217 · 2 months ago
Your comment motivated me to also comment :) I agree: Bézier curves and b-splines have a lot of rich geometry baked it, so it makes sense to use it, especially if you can avoid second derivatives. I think I misunderstood your comment about the extra control point work to find an initial guess. It looks like we’re saying something pretty close though: you can split the curve smartly to remove the single crossing in this case, which skips all the recursion that I’m suggesting, which is probably better.

Yes the real trouble is true optimality guarantees. I remember that there were edge cases of the above approach needed that a lot of subdivision steps to succeed for general degree curves, so it might end up worse than a more rigorously justified approach in these cases.

mmorse1217 commented on Fast calculation of the distance to cubic Bezier curves on the GPU   blog.pkh.me/p/46-fast-cal... · Posted by u/ux
raphlinus · 2 months ago
I'm extremely curious what those basic methods are. We're in the process of replacing the higher order rootfinding in kurbo with a new solver based on Yuksel's method[1]. If you know of simpler, faster techniques that would be quite interesting.

[1]: https://crates.io/crates/polycool

mmorse1217 · 2 months ago
This is a pretty good foundational reference for Bézier curves and b-splines https://www.sciencedirect.com/book/9780122490521/curves-and-...
mmorse1217 commented on Fast calculation of the distance to cubic Bezier curves on the GPU   blog.pkh.me/p/46-fast-cal... · Posted by u/ux
ux · 2 months ago
Thank you! Do we have a guarantee that these subcurves are solvable with Newton's method? The approach with derivatives has this because we know there is one crossing, and also clipping them to the zero-derivatives makes sure there won't be multiple curve "pits".
mmorse1217 · 2 months ago
The trick is that you only solve Newton on a single subcurve: you recursively find the closest control point on all subcurves, split that subcurve and repeat until the closest control point doesn’t move much, or just however many subdivision steps work in practice. So the last curve that you apply Newton to should be smooth enough to succeed. I think there are edge cases with cusps, but I can’t exactly remember the theoretical guarantees anymore.

I think this is the main reference for this algorithm (should be able to search for the pdf): https://www.sciencedirect.com/science/article/abs/pii/S01678...

mmorse1217 commented on Fast calculation of the distance to cubic Bezier curves on the GPU   blog.pkh.me/p/46-fast-cal... · Posted by u/ux
mmorse1217 · 2 months ago
Hey, thanks for the nice post. I really enjoyed reading it; it’s good see this kind of thing on the front page.

Since you’re interested in doing this on GPU, an approach that might be interesting to you (although not necessarily more efficient) would be to leverage the intrinsic properties of Bezier curves to feed a near-optimal initial guess to Newton. Some useful facts about Bezier curves: i) Bezier control points form a convex hull of the curve they define ii) Bezier curves defined on [0,1] can be split into two bezier curves, each defined on [0,t] and [t,1] that define the same curve, with a tighter control polygon. iii) This Bezier curve splitting can be done using repeated linear combinations of Bezier control points, so you can skip evaluating Bernstein polynomials directly. iv) there is a mapping from Bezier control points to their corresponding value in the [0,1] parameter space (the term for this for B-Splines is greville abcissae, I’m not sure that there is an explicit name for the equivalent for Bezier curves, but basically the preimage of control point b_i of a degree d curve is i/d, i=0,…,d+1).

These things together sort of imply an algorithm: 1. Subdivide the Bezier curve c into 2 or 3 curves c_1, c_2, c_3 2. Find the closest control point b_j to the target point x 3. Choose the curve c_i corresponding to b_j: this subcurve contains the closest point to x 4. Go to step 1 and repeat this loop several times with c = c_i 5. Then, compute the preimage of the closest control point b_j to x on c (j/d plus some shift and rescaling). This value, t’, will be the initial guess to Newton’s method. 6. Solve for the closest point on the selected subcurve c to x with Newton’s method; this should converge in very few steps because your initial guess is so good, quadratic convergence, blah, blah blah.

The break-even point for this kind of algorithm vs. a derivative based algorithm is very unclear on CPU. But, for GPU, I think the computation can be structured in an architecture friendly way; since computing the euclidean distance between x with all control points and the bezier curve splitting can written in a vectorizable manner, you will probably see a decent speed up. I’ve only really worked with CUDA though, so I’m not sure if this idea maps very cleanly to GLSL.

Here’s an example of the algorithm above for CPU if you are interested: https://github.com/qnzhou/nanospline/commit/5ac97722414dbc75...

mmorse1217 commented on Show HN: We made our own inference engine for Apple Silicon   github.com/trymirai/uzu... · Posted by u/darkolorin
J_Shelby_J · 5 months ago
VLMs = very large models?
mmorse1217 · 5 months ago
Probably vision language models.
mmorse1217 commented on You can choose tools that make you happy   borretti.me/article/you-c... · Posted by u/zdw
mmorse1217 · 7 months ago
“There are no facts, only interpretations.” - Nietzsche
mmorse1217 commented on Derivation and Intuition behind Poisson distribution   antaripasaha.notion.site/... · Posted by u/sebg
mmorse1217 · 8 months ago
This site is pretty helpful for me with this sort of thing. The style is more technical though.

https://www.acsu.buffalo.edu/~adamcunn/probability/probabili...

mmorse1217 commented on Higher potassium intake at dinner linked to fewer sleep disturbances – study   nutraingredients-asia.com... · Posted by u/hilux
Nemi · a year ago
Sorry, you asked about ‘possible upstream causes of electrolyte deficiency’.

In my case I believe it is caused by an undiagnosed kidney problem loosely called ‘salt-wasting syndrome’. There are many types, but they all revolve around a genetic disorder where the tubules in your kidneys that are responsible for removing different electrolytes from the urine and retaining them are malformed and are not able to keep the electrolytes like a normal kidney does. Here are a few I found in my research:

-Bartters Syndrome- https://rarediseases.org/rare-diseases/bartters-syndrome/

Many different variants, so this is a possibility. Type 5?

-------------------------

-Gitelman syndrome- https://rarediseases.info.nih.gov/diseases/8547/gitelman-syn... Symptoms include tingling of face

————————

Fanconi Syndrome https://www.merckmanuals.com/home/kidney-and-urinary-tract-d...

I my particular case, I believe I have a type that does not impact sodium, but does potassium. When I eat a high sodium meal it causes me to pee a lot to try to get the my sodium levels back to normal. However, my body can’t retain potassium when it does this (and since I was eating much more sodium and much less potassium than my body required) I end up with normal sodium levels but low potassium levels. Taking potassium a few hours after a meal “fixed” this.

Short of genetic issue like this I am not sure what could cause it. I think this can be an early symptom of Diabetes, but don’t know much about that. What I am talking about here has got to be rare, so it may not be applicable to you.

Just another anecdote – when reading some of these links it made me remember another interesting symptom I used to have that I did not know was related: I would get “facial numbness”. Specifically, my lips and the immediate surrounding area would feel slightly numb. Usually in the morning after a poor night of sleep. I would remember feeling this on the way to work in the car. It would contribute to that dazed feeling I felt like I would swimming through a mental fog.

Oh, and one more! I also don’t get nearly so hung over from drinking! This was a surprise for me. I have always drank a lot of water while drinking alcohol, but I would always have the worst drained feeling the next day with such a headache. The headache would last all day. However, if I now take some potassium while drinking and throughout the night (depending on how much I drink), I often don’t have much of a hangover. This amazes me! I am 57 and used to drink a lot when I was in my 20’s. I had some friends that could be normal the next day and it always blew my mind. Now I think I know why. They have normal kidneys!

mmorse1217 · a year ago
Thanks for these references; I've been going down the research rabbit hole :)

I check my A1C every six months and I'm ok. I'm in decent shape also: regularly powerlifting, running, etc. I have a suspicion that there is a genetic component for me; there are some autoimmune issues in my family that haven't been attributed to a particular disorder and there is a chance of an underlying condition causing these autoimmune-like symptoms.

I don't think I've noticed facial numbness, but my limbs fall asleep quickly and my hands fall asleep if I am reading my phone/book while lying on my back after a couple minutes. I also drink a TON of water when drinking alcohol and am hungover for days afterwards. Since my electrolyte revelation, I started knocking back pedialyte before sleeping which helped a ton.

mmorse1217 commented on Higher potassium intake at dinner linked to fewer sleep disturbances – study   nutraingredients-asia.com... · Posted by u/hilux
Nemi · a year ago
I hear you, I was in the same boat. I had been to the doctor many times without much luck. I am outwardly healthy looking. Thin, fit with no other problems. I had a good doctor, but doctors are used to dealing with acute problems in people that are simply unhealthy. When they see me they are often dismissive that I have any real problems. I had a pretty good rapport with my doctor so he would do tests and we would have some good dialog, but he retired and, honestly, it is just too frickin difficult to go through the process of bringing a doctor up to speed on what my history is.

Fortunately for me I was able to retire at 50 and I am an avid consumer of information, so I spent an inordinate amount of time educating myself. I went down many wrong paths (as another commenter pointed out, diabetes can cause a lot of these symptoms). I wish I could say I brute forced my solution, but it was some innocuous comment on HN about potassium deficiency that made me look into it, and the rest is history. It was my “break through”, so to speak.

I take anywhere from 600mg to 800mg most days spread throughout the day depending on meals and activity level, but as much as 1000mg some days. Never all at once.

On a related note, here is the thing about measuring electrolytes – your body goes through great efforts to make sure your electrolyte levels in your blood are in balance. But here is the kicker, only sodium ‘primarily’ resides in your blood. The other electrolytes primarily reside in your other tissues. For example, potassium is mostly held inside your cells like muscle tissue. As a matter of fact, this is how muscles contract. When muscles contract, potassium temporarily moves out of the cell and sodium moves in. Then in a minute potassium and sodium reverse back to normal. This is one reason your muscles fatigue and then become usable again a short time later. When your cells are short potassium then your muscles fatigue quickly and don’t bounce back.

You can’t measure this level of potassium. Your blood levels might be just fine, but your cells may be deficient and you will never know. It is the same with calcium and magnesium (bone). If you ever get a blood test and your electrolytes are off, you probably need to be in the hospital. It means shit is so bad that your body has lost its ability to compensate. But it also means that if you go to the doctor and get your electrolytes tested, they will likely be in the normal range, but that does not mean you aren’t deficient.

mmorse1217 · a year ago
Sorry for the late reply, I pick up 99mg potassium + 200mg magnesium and had an unbelievable night's sleep and many symptoms improved dramatically. The second night was confounded by an evening workout, which can mess with electrolyte levels, but you have given me hope again. I just want to thank you again for continuing the tradition of changing someone's life with an innocuous HN comment :)

I see what you mean regarding the electrolyte measurements. After reading a bit about the disorders that you mentioned, it seems like they test for serum and excreted electrolyte levels to make a diagnosis. But based on your point above, these tests can be inconclusive. Were there certain diagnostic tests that were helpful to you in coming to your conclusion, or was it largely trial and error based on symptom management?

u/mmorse1217

KarmaCake day54January 21, 2022View Original