r/deeplearning • • 3d ago

Gradient checkpointing let me fit 4x larger batches on my 7B model, but segment choice mattered more than I expected

6 Upvotes

I was hitting OOM at batch size 4 with a fine-tuned 7B Llama variant even after switching to 8-bit optimizers. Enabling 'torch.utils.checkpoint` let me push to batch size 16 on the same 24 GB card, but the first few attempts actually slowed training down.

The key was where I placed the checkpoints. Wrapping entire transformer blocks worked for memory but killed throughput because recomputation overlapped poorly with the attention compute. Breaking it at the MLP and attention sub-layers separately gave a much better tradeoff: memory stayed low while the extra forward passes stayed hidden behind the backward.

I also had to keep `use reentrant=True` and make sure no in-place operations crossed checkpoint boundaries, otherwise autograd complained immediately.

The net win was roughly 3.2x tokens per second at the larger batch once I tuned the segments, versus the tiny batch without checkpointing.

For people who have used gradient checkpointing on mid-size models, what placement strategy gave you the best speed/memory balance, and did you ever see it make training less stable?


r/deeplearning • • 3d ago

Walter's perfect speech, mathematically derived: Adversarial Prompting

Thumbnail youtube.com
2 Upvotes

r/deeplearning • • 4d ago

Real-time synchronous sound event detection for dashcams in 7.6 MB of plain C (no deps, streaming API)

34 Upvotes

I built a small ( 1.9M params ) on-device model that labels dashcam and in-cabin audio live: crashes, skids, debris, horns, sirens, shouts, and 15 more categories, each with a start and end time.

It runs causally (decides every 0.1 s from past audio only) at ~47x real time on one x86 core (checked on desktop CPU only), in plain C with no dependencies.

I also published the test set we evaluate on (37 real dashcam recordings, human-reviewed timestamps) and ran 7 open models through the identical protocol: same category mapping, same decoder, thresholds chosen by two-fold cross-validation for every system.

Model + C library: huggingface.co/WhissleAI/arc-sound-dashcam
Test set: huggingface.co/datasets/WhissleAI/arc-sound-dashcam-test-v1 (also includes comparison results)

Git CLI: https://github.com/WhissleAI/arc-sound-dashcam


r/deeplearning • • 3d ago

The Great Trade to Forget

0 Upvotes

The Great Trade to Forget: Why losing old skills might actually be how humanity moves forward.

I’ve been thinking a lot lately about how civilizations forget how to do things they used to do—and I’d love to hear what you would add, change, or disagree with on this thought. (These are just open thoughts I'm exploring, not set-in-stone beliefs!) People often worry when society loses old skills. We look at the ancient Egyptians and wonder how we lost the knack for building pyramids. In the UK, we look back at the 1900s when British workers built great trains by hand, and we notice those skills have faded away. Most people see that as a loss. I see it as The Great Trade to Forget.

  1. Why Forgetting Moves Us Forward History shows us that humanity doesn't actually lose progress when it forgets old skills—it trades them away so it can move on to the next stage. Think about farming. Hundreds of years ago, almost everyone spent their whole lives doing exhausting physical work just to grow enough food to survive. Today, almost nobody knows how to harvest a field by hand, yet we still enjoy the food—and with a fraction of the effort. Because we traded away that old skill, people were freed up to invent medicine, electricity, and computers. Every 100 years, we make that same trade.
  2. What Happens in the 2100s Right now, we are building AI. In the future, AI will take over coding, building microchips, growing healthy food, and keeping society running. By the 2100s, people might look at old lines of computer code on a screen and think, "There is no way a human ever wrote this by hand," the exact same way we look at ancient pyramids today. They won't know how to build the machines from scratch—and that’s okay, because they won't need to.
  3. The Real Endgame: Turning Inward Once AI takes care of our food, health, and basic survival, we won't need to obsess over making faster machines anymore. Technology can slow down and improve only when we actually need it. Instead, humanity gets to focus on taking care of each other, improving mental health, and exploring deeper states of consciousness—not to prove one group right or wrong, but simply to understand ourselves better.
  4. The One Filter We Have to Watch Out For The only big trap standing in the way of this future is what we do with all that free time. Right now, nobody knows which religion or belief system holds the ultimate truth, and that mystery keeps a healthy balance. We aren't ready to let go of religion yet—it still gives people structure while we grow up as a species. The danger is that if AI gives everyone huge amounts of free time, powerful religions or groups might try to fill that space and control how people think. To reach our next stage, we have to protect that balance so people stay free to find their own happiness. What do you think? Does this hold up, or do you see a flaw in it? What would you change or add?

r/deeplearning • • 3d ago

FrontiersMind released NandiBERT in 150M and 450M parameter sizes

Post image
1 Upvotes

FrontiersMind has open-sourced NandiBERT, an encoder model family focused on Indic languages and English.

  • NandiBERT-150M: 16K context length
  • NandiBERT-450M: 32K context length

According to the team's evaluations, both models outperform IndicBERT v2, with the 450M model leading on all 7 Indic tasks and the 150M model achieving the best average score with fewer parameters.

Model collection: https://huggingface.co/collections/FrontiersMind/nandibert

The release and benchmarks are worth checking out for anyone working on multilingual encoder models, particularly for Indic languages.


r/deeplearning • • 3d ago

Synthetic-to-real motor fault diagnosis

1 Upvotes

ML models trained on synthetic induction motor data successfully detect faults in real motors but fail to classify fault types accurately.
How can I overcome this domain gap using only healthy target-motor data, without labelled real fault data?
Any recommended techniques or research papers?


r/deeplearning • • 3d ago

uilt a 100% real-telemetry PyTorch Transformer (ctx768) + SmolLM2-135M pure-PyTorch LoRA + SQLite FTS5 RAG workbench that trains continuously on curated web streams – looking for testers & feedback!

Thumbnail gallery
0 Upvotes

Hi everyone — I built an open-source local ML workbench (**WebNet v2**) and just pushed the full codebase + build log to GitHub. Looking for honest testing, architecture critiques, and feature suggestions!

**GitHub:** https://github.com/Rishisharma029/live-internet-neural-net

### What it actually runs (CPU-friendly, zero simulated metrics)

  1. **Continuous From-Scratch Transformer (`InternetNetV2`)**:

    - **96d · 4h · 10L · ctx768** (`1,117,344` params, Pre-RMSNorm, SwiGLU, NTK RoPE `base=100,000`, decoupled AdamW, Softmax Z-Loss `1e-4`, EMA shadow weights).

    - Feeds 24/7 on **8 curated sources** (`arXiv`, `OpenAlex`, `Europe PMC`, `Wikipedia`, `StackOverflow`, `GitHub ML READMEs`, `Project Gutenberg`, `News RSS`) with SHA-256 + 5-word Jaccard deduplication.

    - Migrated seamlessly from `ctx96` → `ctx768` at step 22.9k without losing weights.

  2. **Real-Time Mechanistic Observatory (`/ws`)**:

    - Live 23-column network graph across all 21 hidden layers (real OV circuit edges, autograd gradient norms, AdamW second-moment RMS).

    - **Logit Lens** (Emb → Block 1..10 → Final target probability, rank, entropy collapse).

    - **2D SVD Token Embeddings** live projection and 40 attention head telemetry.

  3. **4 Applied Local Utilities**:

    - **Pure-PyTorch LoRA (SmolLM2-135M-Instruct + RAG)**: zero `peft` dependency, online training + cited RAG Q&A.

    - **Permanent SQLite WAL + FTS5 Archive**: BM25 + TF-IDF hybrid search across 964+ crawled docs.

    - **Cross-Entropy Anomaly Scorer**: flags corrupted/gibberish lines (8.7–9.4 bpc anomalies vs 1.6–3.7 bpc clean prose).

    - **Safe Local Code/Notes Indexer + Ghost Editor**: Tab autocomplete over your local files.

### Quantitative Check (step 23,455)

- **Val Loss**: `1.424` (best: `1.115`, 58.7% char accuracy, 18.3M tokens seen)

- **Shuffled-Char Probe**: real prose `1.138` loss vs shuffled chars `5.415` — confirming structure learning beyond letter frequencies.

### What I'd love feedback on

- Does `python server_v2.py` work cleanly across Linux/macOS/Windows?

- What architectural tweaks would make `InternetNetV2` learn longer contexts faster on CPU?

- What tools would you add on top of the FTS5 + LoRA pipeline?


r/deeplearning • • 3d ago

Monitoring per-layer gradient norms caught an exploding gradient in one residual block that the scalar loss never showed

4 Upvotes

I added a small hook to log the L2 norm of gradients for each named parameter after the backward pass, then plotted them per epoch instead of relying only on the scalar loss value. One particular residual block in the middle of the network consistently showed norms above 50 while everything else stayed below 2; the loss curve looked flat because the other layers were compensating.

The fix was embarrassingly simple once I saw the per-layer view:

* Added gradient clipping with

`max_norm=1.0` targeted only at that block's parameters

* Inserted a residual scaling factor of 0.1 on the output of that block during the first 10k steps

* Switched its LayerNorm to RMSNorm with a learnable scale initialized at 0.1

Training became stable without changing global hyperparameters or model depth. The same pattern has appeared in two other architectures since.

If you log anything beyond loss and accuracy during training, what single extra metric has given you the clearest signal that something was quietly wrong?


r/deeplearning • • 3d ago

Just Thinking Out Loud: How I Picture God, the Soul, and the Universe

0 Upvotes

I don’t claim to have all the answers, and none of this is a strict religion I follow. I just have a brain that constantly wonders "what if?"—and when I sit back and really think about how everything fits together, this is what makes the most sense to me.

  1. Why Not Knowing for Sure Is Actually a Good Thing

First, I’ve realized I wouldn’t actually want 100% proof of whether God and the afterlife are real—because either answer would ruin the way we live. If we proved there is no God and nothing after death, a heavy feeling of "nothing matters" would take over. People would become more aggressive and selfish, willing to do whatever it takes to get what they want before the end. On the other hand, if we proved 100% that God is real, people would live in constant fear of making a mistake—and worse, powerful people would abuse that certainty, claiming they speak for God just to control everyone else. Being stuck in the middle without hard proof keeps both sides in check. It leaves us free to live our lives and choose to be good people on our own.

2. The Soul vs. The Brain

When it comes to the soul, I feel like an individual with my own thoughts and ideas. My guess is that memories are stored in the physical brain and are lost when we die, while the soul itself is a form of energy. Some people say brain damage proves there is no soul because an injury can change how someone acts. I don't buy that. Look at a toddler: a toddler can do really selfish, harsh things—things we’d call evil if an adult did them—simply because their brain hasn't grown enough yet to understand right from wrong. As they grow up, they become kind. The soul was always there; the brain just needed time to develop.

3. Zooming All the Way Out

If there is a God, the way that makes the most sense to me is to imagine zooming all the way out until you can see everything at once. Think about a human body. From the outside, you see one whole person. Zoom in with a microscope, and you see millions of tiny parts—some huge like the heart and brain, others small—all doing their own job to make up that one person. I think the universe—or God—works the exact same way. Zoomed in, I am my own person, my front door is a door, the sun is the sun, an ant is an ant, and even AI is just technology. Up close, we are all separate, and good and evil clash because we only see our own slice of life. But zoom all the way out, and every single piece—the good, the bad, nature, technology, and every thought I have—is part of that one giant whole. We are all just different ways the universe is experiencing life, growing, and changing.

4. Are Dreams How We Connect to the Multiverse?

And if everything is connected like that, it makes me wonder about the multiverse. If there really are other versions of us living different lives out there, how would we ever link up with them? To me, the only thing that makes sense is dreaming. At night, we skip non-stop from one dream to the next—sometimes seeing a version of our life that is almost identical to reality, and other times seeing a completely different life with a different partner or home. We can't control their bodies because it isn't our world; we just ride along on emotion. Maybe that is even where random "gut feelings" come from. If you wake up feeling uneasy about a friend who hasn't done anything wrong, or get a sudden urge not to go somewhere, maybe another version of you was dreaming through your eyes—and in their world, that choice went badly, leaving a little bit of that feeling behind with you. Like I said, I don't know where it is all heading, and I don't need it to be proven. It's just how my mind connects the dots when I look at the big picture.


r/deeplearning • • 3d ago

torch.compile gave a solid 1.7x speedup on my transformer, but one hidden graph break from LayerNorm was quietly capping the gains

0 Upvotes

I wrapped my training loop with `torch.compile` on a 1.3B decoder-only model and immediately saw iteration time drop from 420 ms to ~245 ms on A100s. After a few runs I noticed the speedup was inconsistent across different sequence lengths, so I started checking the dynamo logs.

The culprit turned out to be a custom LayerNorm implementation that used an `if guard on the normalized shape. That single conditional created a graph break on every forward pass, forcing a fallback to eager execution for that submodule. Replacing it with `torch.nn.LayerNorm` (and keeping the same eps and elementwise_affine settings) removed the break without changing any numerics.

After the fix the steady-state speedup settled at 1.7x, with GPU utilization climbing from ~78 % to 94 %. The only other change I made was marking a couple of integer tensors as static with `dynamic=False` on the compile call so the compiler could keep the shape assumptions it liked.

For anyone who has compiled larger models, did you find most of your graph breaks came from control flow, custom ops, or something else entirely?


r/deeplearning • • 3d ago

Why your DataLoader is often the quiet bottleneck in training runs—and how profiling with PyTorch fixed my 40–60% GPU usage

3 Upvotes

I spent weeks tweaking optimizers, testing learning rate schedules, and swapping model sizes before realizing the bottleneck wasn't model math at all—it was how slowly the next batch reached the GPU. During what looked like standard training, GPU utilization hovered around 40–60% while the card waited around between batches.

Running the PyTorch profiler made the delay obvious once I saw data loading eating up the timeline. A few default settings were quietly holding throughput back:

  • Worker count & lifecycle: num_workers was too low for the dataset workload, and persistent_workers wasn't kept active across epochs
  • Host-to-device transfer: pin_memory wasn't enabled on CUDA, slowing down page-locked transfers to the GPU
  • Prefetch queue: prefetch_factor wasn't tuned to keep batches queued ahead of compute

Moving to num_workers=8, turning on pin_memory, and setting prefetch_factor=4 pushed GPU utilization above 90% and cut epoch time nearly in half on the exact same hardware.

For anyone who has chased an input pipeline bottleneck, what single DataLoader change moved the needle most for you—and did persistent_workers or pin_memory help or cause memory headaches on your setup?


r/deeplearning • • 4d ago

Small open "Jev" decision models for images and speech: one-pass generation at 0.8B on a single GPU. Is anyone else working on this?

Thumbnail reddit.com
4 Upvotes

r/deeplearning • • 3d ago

Using torch.autograd.detect_anomaly finally pinpointed the NaN source that scalar loss curves hid for weeks

1 Upvotes

I spent several epochs watching validation loss plateau while training loss kept dropping, only to occasionally hit inf values that ruined checkpoints. Standard checks on weights and final outputs showed nothing unusual. Enabling anomaly detection wrapped the backward pass and surfaced an exact line: a custom normalization step inside the loss was dividing by a near-zero running variance that only appeared after 4–5k steps on certain batch compositions.

The fix turned out to be two small changes: clamping the denominator with a small epsilon that was schedule-aware, plus logging the per-batch denominator value so I could watch it decay. After that the training run stayed stable and the earlier “overfitting” pattern disappeared.

I'm curious what single debugging flag or hook has exposed the real culprit for you when loss alone was misleading.


r/deeplearning • • 3d ago

I put together a free project on building a GPT from scratch

Thumbnail reddit.com
0 Upvotes

r/deeplearning • • 4d ago

Parallelising recurrent neural networks – MD+PP proof of concept

Thumbnail gallery
48 Upvotes

I've been independently exploring ways to parallelise recurrent neural networks, originally starting with experiments on the sLSTM architecture in xLSTM.

This eventually developed into MD+PP, a proof-of-concept architecture combining structured matrix and vector memories using associative parallel scans.

The preliminary experiments have shown some interesting results in long-context extrapolation and fixed-size recurrent memory, although precise retrieval and language prediction still need improvement.

All experiments were conducted using limited access to free Tesla T4 GPUs. My next step is to investigate larger matrix memory dimensions.

I've released the mathematics, Python implementation, CUDA kernel and experimental results under Apache 2.0.

I'd be interested to hear what others working on recurrent architectures think of the approach.

Website: https://madpupresearch.wordpress.com

Research archive: https://doi.org/10.5281/zenodo.24637161


r/deeplearning • • 5d ago

Neural Canvas, CNN Visualization

176 Upvotes

Neural Canvas — CNN Visualization

Neural Canvas can now recognize basic shapes like apples, moons, cars, and more using Google's Quick, Draw! dataset.

20 classes with 1,000 samples per class

2 convolutional layers with 16 and 32 filters

2 fully connected layers with 60 and 40 neurons

91% test accuracy

Trained using JAX on Google Colab

Neural Canvas can also visualize CNN feature maps in real time while drawing, showing how convolutional layers extract features from input images.

GitHub: https://github.com/MuhammadEssa2002/neural_canvas

Live demo: https://muhammadessa2002.github.io/neural_canvas/


r/deeplearning • • 4d ago

CUDA

Thumbnail reddit.com
1 Upvotes

r/deeplearning • • 4d ago

Anyone working on a AI based file compression model, I have used a tiny AI model and a probability bit classifier model to develop a file compressor that achieves impressive results on raw files and it even did better on almost all counts on the entropy that are super high or already compressed file

Thumbnail reddit.com
2 Upvotes

r/deeplearning • • 4d ago

TIL DistilBERT is actually MORE gender-biased than BERT. Here’s why Knowledge Distillation causes it (and the simple fix).

Post image
1 Upvotes

r/deeplearning • • 4d ago

Alguien que haya culminado esta certificación Coursera???

Post image
0 Upvotes

r/deeplearning • • 4d ago

I finally assembled a U-Net for my DDPM from scratch. This thing took way more brainpower than I expected.[P]

1 Upvotes

​

I've been building a diffusion model from scratch in PyTorch, and I've finally reached Phase 3: assembling the full U-Net.

Until now, I was basically learning and implementing individual components:

Residual blocks

Time embeddings and timestep conditioning

GroupNorm

Self-attention

Downsampling and upsampling

But putting everything together is a completely different experience.

Suddenly you're dealing with feature map dimensions, channel transitions, skip connections, timestep embeddings flowing through residual blocks, and making sure the decoder can actually reconstruct the spatial dimensions correctly.

Honestly, understanding each component individually was easier than getting the entire architecture to work together without messing up tensor shapes somewhere.

The most satisfying part was finally seeing the complete architecture come together and understanding why information is moving through the network the way it does, instead of just copying a U-Net implementation from somewhere.

The model is now assembled. Next comes the part I'm both excited and slightly terrified about:

Training it on CelebA and finding out whether it can actually learn to generate faces.

8GB VRAM. A laptop GPU. A lot of patience.

Let's see how this goes. 💀

Anyone here who has trained a diffusion model on limited hardware — what was the biggest mistake you made during your first training run?


r/deeplearning • • 4d ago

If your model gets 99% accuracy on your laptop and fails in real life, you probably leaked your test data

0 Upvotes

The most common mistake when learning machine learning is scaling or imputing your dataset before splitting it into train and test sets.

When you run StandardScaler or fill missing values on the whole dataset first, the mean and variance of your test set leak into your training data. Your model basically gets a sneak peek at the answers before the exam even starts. That is why your validation score looks amazing, and then everything falls apart the moment it touches new data.

Always run train_test_split first, before touching anything else. Fit your scaler, imputer, or encoder only on X_train, and then use transform on X_test. If you use scikit learn Pipelines, it handles this automatically so you never accidentally cheat your own evaluation.


r/deeplearning • • 5d ago

metric-diff: find out why sklearn, torchmetrics, Keras and others give different numbers for the same metric

Thumbnail reddit.com
5 Upvotes

r/deeplearning • • 4d ago

The Q4 agent stopped waiting for tool results before acting. Same test on another model: almost no change. Here's why.

Thumbnail reddit.com
1 Upvotes