Submit tips and tricks for coding with LLMs like snippets you like to include in prompts or features you find helpful.
Not a snippet, but on I’ve found it useful to use “plan mode” on Claude code to avoid wasting too many tokens. You can press shift+tab to cycle to plan mode
code reuse is paramount. whenever possible, locate high quality open source implementations for algorithms and use those instead of implementing something yourself. chances are someone has already solved the problem.
PyTorch does not manage devices for you. every time a new tensor is created, make sure it is instantiated on the correct device and with the correct dtype. ideally the correct device is inferred by looking at the device of an input tensor either explicitly or by using a method such as ones_like(...).
clamping tensors should only be used as a last resort. it’s much better to diagnose and remedy the numerical issue that would trigger the clamp.
I tried something similar to this. I found it useful to have a small dataset or code to generate a small dataset that Claude can use to run tests locally. You can have it try different model configurations to track gradients, encoder output stats, etc. to find the numerical issue, or unstable configurations.
– LuisAldamayou may use the reparameterization trick if the transform is linear or a simple, bijective function. otherwise, prefer implicit reparameterization gradients. the inverse CDF method for reparameterization gradients should only be used if there is no other viable option. it’s too numerically unstable for the sensitive work you’re doing.
plan mode is definitely helpful! i changed the post title to be more inclusive of these sorts of suggestions :)
– kmdalton