Skip to content

Rust implementation: ~15x speedup in equivalent commands#5

Draft
Paladynee wants to merge 15 commits intoFlamethr0wer:mainfrom
Paladynee:feature/add-rust-and-reorg
Draft

Rust implementation: ~15x speedup in equivalent commands#5
Paladynee wants to merge 15 commits intoFlamethr0wer:mainfrom
Paladynee:feature/add-rust-and-reorg

Conversation

@Paladynee
Copy link
Copy Markdown

@Paladynee Paladynee commented Apr 26, 2026

I added a translation of the program in Rust, which provided a notable speedup.

note: i took permission from the author before making this PR. this is not an AI spam PR.

Screenshot image

Disclaimer:

im not a math guy. for the math heavy sections, i had to resort to text generation. im just a guy who knows a bunch of optimization patterns. i've been testing the end to end results between the two programs to make sure they align. i do not believe in the faithfulness of the translation or the correctness of it in the slightest. if anybody could verify the correctness of it, i'd be very glad.

@Paladynee Paladynee changed the title Rust implementation: 1000 atempts in 37~ seconds Rust implementation: ~15x speedup in equivalent commands Apr 26, 2026
@EfficiencySimplicity
Copy link
Copy Markdown

Augh, someone beat me to it. Nice job, though!

@fennelpage
Copy link
Copy Markdown

hey i saw your project is implemented in Python. i have opened a pull request in your repository containing a different implementation in Rust. i AI-generated it. i have no faith that it is correct in the slightest. if somebody could do all the work of testing it for me in the already opened pull request that would be great. thank you.

@Paladynee
Copy link
Copy Markdown
Author

Paladynee commented Apr 26, 2026

hey i saw your project is implemented in Python. i have opened a pull request in your repository containing a different implementation in Rust. i AI-generated it. i have no faith that it is correct in the slightest. if somebody could do all the work of testing it for me in the already opened pull request that would be great. thank you.

At least I don't try shoving it down their throats, nor am I doing any unsupervised vibe coding, and I'm transparent about it. They reserve all the rights to just outright close this PR, and I'd respect that.

@Paladynee Paladynee marked this pull request as draft April 26, 2026 14:42
@fennelpage
Copy link
Copy Markdown

lol changed it to a draft

@Paladynee
Copy link
Copy Markdown
Author

are you going to contribute anything or are you just here to shame the ai usage?

@fennelpage
Copy link
Copy Markdown

that is my contribution ❤️

@Paladynee
Copy link
Copy Markdown
Author

message received.

@Paladynee
Copy link
Copy Markdown
Author

Paladynee commented Apr 26, 2026

i've been getting rotationally-symmetrical same outputs with the python version since the complete rewrite (modulo the nondeterminism by the rng), albeit dramatically faster. this is the packing of 7 pentagons into a pentagon container, with --attempts=10 calculated in 1.5 seconds in Rust: (side length: 3.0792087849226246)
7_5_in_5

this is the reference python implementation, with the same exact parameters, calculated in 17 seconds.
7_5_in_5

It's not like I am completely oblivious as to what is going on in the code, I just don't understand all the terminology around the operations that are being made here.

@fennelpage
Copy link
Copy Markdown

fennelpage commented Apr 26, 2026

why are you so caught up on the AI mention? i was talking about you using AI for a grand total of 4 words in a 62 word comment.

@Paladynee
Copy link
Copy Markdown
Author

let it go already bro

@fennelpage
Copy link
Copy Markdown

let what go

@Paladynee
Copy link
Copy Markdown
Author

are you going to focus on the PR itself or are we going to continue this?

@Paladynee
Copy link
Copy Markdown
Author

i've been doing nothing but document my progress on the thing other than my interaction with you

@Paladynee
Copy link
Copy Markdown
Author

Paladynee commented Apr 26, 2026

i'm currently triyng to fix a problem within the algorithm, when i run it with --attempts=100 7 5 5 or similar, the verification step reports overlapping and out of bounds polygons.

i don't really know whether this is expected or not, because there is no verification step in the original python script.

@Flamethr0wer
Copy link
Copy Markdown
Owner

Okay guys stop arguing! Poor triangles are getting stressed.
Thank you @Paladynee for the translation, the results seem promising! I noticed your implementation gave a slightly bigger container size than the original program. Does this happen consistently for different parameters?
I also wouldn't recommend adding verification as the program optimizes more mathematically than physically. What I mean is, it works with a penalty, so rather than physically impeding any possibility for overlap, it penalizes it (with a weight set by the penalty tolerance; the lower, the more precise but less exploratory), so a teeny tiny overlap is always expected even though the actual arrangement will match the optimum.
I've never used Rust, so it might take a while before I can actually get to verifying the math. That said, if anyone knows Rust, any help is appreciated!

@MightyPancake
Copy link
Copy Markdown

I just randomly got a YouTube video about this on my feed and oh my god this is hilarious.
Let me start by stating the obvious; rewriting X in Rust is not a contribution!
The original project is written in Python, it's a rewrite. Go create your fork that no one is going to care about to add your crab emoji.
It would be hilarious even without the use of AI, but it is honestly 15x better this way.
@fennelpage is absolutely right. There's not a single soul that asked for this, nor does it help to maintain this project in any way. I don't see the point.

@BowLuckie
Copy link
Copy Markdown

I just randomly got a YouTube video about this on my feed and oh my god this is hilarious. Let me start by stating the obvious; rewriting X in Rust is not a contribution! The original project is written in Python, it's a rewrite. Go create your fork that no one is going to care about to add your crab emoji. It would be hilarious even without the use of AI, but it is honestly 15x better this way. @fennelpage is absolutely right. There's not a single soul that asked for this, nor does it help to maintain this project in any way. I don't see the point.

you've honestly lost the plot

@MightyPancake
Copy link
Copy Markdown

hey i saw your project is implemented in Python. i have opened a pull request in your repository containing a different implementation in Rust. i AI-generated it. i have no faith that it is correct in the slightest. if somebody could do all the work of testing it for me in the already opened pull request that would be great. thank you.

At least I don't try shoving it down their throats, nor am I doing any unsupervised vibe coding, and I'm transparent about it. They reserve all the rights to just outright close this PR, and I'd respect that.

There's nothing to "respect" here. It's not your repo to begin with. So far you've done almost anything to "shove it down their throats".

@MightyPancake
Copy link
Copy Markdown

I just randomly got a YouTube video about this on my feed and oh my god this is hilarious. Let me start by stating the obvious; rewriting X in Rust is not a contribution! The original project is written in Python, it's a rewrite. Go create your fork that no one is going to care about to add your crab emoji. It would be hilarious even without the use of AI, but it is honestly 15x better this way. @fennelpage is absolutely right. There's not a single soul that asked for this, nor does it help to maintain this project in any way. I don't see the point.

you've honestly lost the plot

I don't think I have. There's no plot to begin with. Just an AI Andy trying to prompt their way in. It would maybe be acceptable if he had at least checked the code himself, but it's literally just unchecked vibe session.
It's not like this type of thing is new, you can smell such behav from mile away by these types of PRs.

@BowLuckie
Copy link
Copy Markdown

I don't think I have. There's no plot to begin with. Just an AI Andy trying to prompt their way in. It would maybe be acceptable if he had at least checked the code himself, but it's literally just unchecked vibe session. It's not like this type of thing is new, you can smell such behav from mile away by these types of PRs.

you think the rust re-write is vibe coded? I really don't see how, and if it is then I'm sorry

@MightyPancake
Copy link
Copy Markdown

I don't think I have. There's no plot to begin with. Just an AI Andy trying to prompt their way in. It would maybe be acceptable if he had at least checked the code himself, but it's literally just unchecked vibe session. It's not like this type of thing is new, you can smell such behav from mile away by these types of PRs.

you think the rust re-write is vibe coded? I really don't see how, and if it is then I'm sorry

Dude, did you even read the PR messages or are you just blindly white knighting this guy? He basically admitted himself. Come on.
Besides, read Cargo.toml. It's kinda obvious...

@BowLuckie
Copy link
Copy Markdown

you think the rust re-write is vibe coded? I really don't see how, and if it is then I'm sorry

Dude, did you even read the PR messages or are you just blindly white knighting this guy? He basically admitted himself. Come on. Besides, read Cargo.toml. It's kinda obvious...

well yes the commit messages are clearly AI, but that could be githubs little commit message generator thing, and i use claude to make me .toml files all the time, the code looks clean enough to me.

@MightyPancake
Copy link
Copy Markdown

MightyPancake commented Apr 27, 2026

...i do not believe in the faithfulness of the translation or the correctness of it in the slightest.

I'm losing faith in humanity, really.

well yes the commit messages are clearly AI...

It's not about the commit message. Come on.

@EfficiencySimplicity
Copy link
Copy Markdown

To those who it may concern:

I know a bit about Rust, and may have some free time to make a cleaner, from-scratch rewrite of the system (the tricky part will be finding a scipy-adjacent Rust library, but there are probably a few good ones)

@fennelpage
Copy link
Copy Markdown

fennelpage commented Apr 27, 2026

He basically admitted himself.

I mean, it's written in plain text in the initial message within the first two sentences:

for the math heavy sections, i had to resort to text generation.

And like, this is entirely math. The whole program is a math heavy section.

@BowLuckie
Copy link
Copy Markdown

And like, this is entirely math. The whole program is a math heavy section.

thats actually really funny

@Paladynee
Copy link
Copy Markdown
Author

Paladynee commented Apr 29, 2026

I don't think I have. There's no plot to begin with. Just an AI Andy trying to prompt their way in. It would maybe be acceptable if he had at least checked the code himself, but it's literally just unchecked vibe session. It's not like this type of thing is new, you can smell such behav from mile away by these types of PRs.

you think the rust re-write is vibe coded? I really don't see how, and if it is then I'm sorry

Dude, did you even read the PR messages or are you just blindly white knighting this guy? He basically admitted himself. Come on. Besides, read Cargo.toml. It's kinda obvious...

yeah as if an AI would manually write that on their own. i wrote all of those sentences myself to make it easier for the author to know what they do. besides, i emailed the author to let them know beforehand that if i could make a PR, and when they said yes did i ever make PR from my fork. there's more to this PR than you guys can see by clicking on the pr itself.

I believe we have castrated being orderly, predictable and descriptive in the name of "avoiding looking ai-like". I threw in the word AI in there and everyone started to pattern match AI-speak on my commit messages, my Cargo.toml file, even my commit messages. This is how I programmed even before AI. Because of people like you I started to stray away from good looking markdown, omitting punctuation and casing.

I don't believe anybody has even gone and read what the main.rs file looks like; but rather read some of the commit messages and conclude "yep, this is completely AI." In any case, I do not care what anybody other than the author thinks, because I don't own this repo, neither do you. So let's stop the criticism when I already have explicit permission from the author himself.

image

@Paladynee
Copy link
Copy Markdown
Author

Paladynee commented Apr 29, 2026

Okay guys stop arguing! Poor triangles are getting stressed. Thank you @Paladynee for the translation, the results seem promising! I noticed your implementation gave a slightly bigger container size than the original program. Does this happen consistently for different parameters? I also wouldn't recommend adding verification as the program optimizes more mathematically than physically. What I mean is, it works with a penalty, so rather than physically impeding any possibility for overlap, it penalizes it (with a weight set by the penalty tolerance; the lower, the more precise but less exploratory), so a teeny tiny overlap is always expected even though the actual arrangement will match the optimum. I've never used Rust, so it might take a while before I can actually get to verifying the math. That said, if anyone knows Rust, any help is appreciated!

after rewatching your video the overlaps started to make sense, i'll remove it in the next commit.

the current differences between the Rust version and the python version are

  • the rng implementation. python might be using the mersenne twister, i switched to my own rust translation of the PCG family of generators., because it was faster in my experience.
  • the Lbfgs instead of Lbfgs-b. ai says i dont have an alternative to that, and keeps warning me that the search selection may be slightly different, but the underlying algorithm is the same.
  • it warns about something about the gradient, not sure what that is about

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants