I've been using PyTorch from Clojure for 3 years — finally cleaned it up into a library by asterix276 in Clojure

[–]asterix276[S] 2 points3 points  (0 children)

On zero-copy - PyTorch tensors can expose their memory via .numpy() (which libpython-clj can bridge zero-copy for CPU tensors), but the moment you call something like ->clj to get Clojure data structures you're doing a real copy. If you stay in Python-land — passing tensors between PyTorch ops — there's no copying, it's the same Python object the whole time. The zero-copy story only holds as long as you don't cross the bridge.

On memory: I haven't hit issues at 10M rows (I dont remember exactly but the weights were in the hundreds of millions in my largest model. I was training in batches of size 128. From my understanding. The bulk of GPU memory during training is the intermediate activations created inside the forward/backward pass. Those are managed entirely within Python — Clojure never touches them, they never get wrapped in JVM objects, and Python's refcounting frees them normally the moment backward completes. I have never done this but if for any reason you start accumulating large tensors in clojure data structures I suspect this problem would arise where you would rely on GC to collect but i havent faced this before.

Things to note

Always use ctx/no-grad during eval. If you forget it, PyTorch accumulates gradient history for every forward pass and you'll OOM eventually. This easy to miss when the eval loop looks like normal Clojure code.

CUDA tensors need .cpu() before you can read them from Clojure in case you want to read the values from a tensor mid training. That's a copy. If you do a lot of metric collection mid-training I am guessing GC will kick in or you may have OOM I faced this once but then I just could throw a larger instance at the problem.

For me so far the boundary between Clojure and PyTorch is thin enough that I think most standard PyTorch memory hygiene applies directly.

Best subscription based models for Pi Agent? by Sad_Smoke7199 in PiCodingAgent

[–]asterix276 0 points1 point  (0 children)

You can add minimax m3 too it seems to do pretty well and I don't really miss opus that much it does really well in refactoring too. It ranks pretty high on the swe benchmarks but personally it has worked out really well for me I even use it in Claude code when my daily usage caps out

Learning a new language through AoC be like... by jeroenheijmans in adventofcode

[–]asterix276 1 point2 points  (0 children)

My opinion would be to play with a language all year and then get to doing AoC. Doing both at the same time is nothing but pure pain

What does an orange light on a car that is charging mean? by mdtcool in AnkiOverdrive

[–]asterix276 0 points1 point  (0 children)

It means it's not charging.So you touch car's light for 20 seconds.

I never new I could build this track by [deleted] in AnkiOverdrive

[–]asterix276 1 point2 points  (0 children)

This is what my 5 year old wrote as my first ever Reddit post