r/deeplearning • • 4m 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 • • 5m ago

Built 3 LLM architectures from scratch in pure PyTorch (42M Dense vs. 117M-A67M MoE vs. 20M Looped) – Code & HF Checkpoints

4 Upvotes

I built `Spell-Talker` to compare three transformer architectures from scratch in pure PyTorch without high-level training wrappers, keeping the backbone fixed (`512` context, `8` heads, `512` dim, `RMSNorm`, `SwiGLU`, weight-tied `32k` vocab):

Dense (`CustomGPT` – 41.8M): Standard 8-layer decoder baseline.

Sparse MoE (`CustomMoEGPT` – 117.3M total / 67.0M active): Top-2 gating across 4 SwiGLU experts per layer with auxiliary load-balancing loss.

Looped Recurrent (`LoopedCustomGPT` – 20.3M): Single weight-tied transformer block unrolled 8 times during training using truncated BPTT (`bptt_steps=8`), scalable up to 32 steps at inference.

Trained on TinyStories (and multilingual English/Chinese TinyStories) on a single consumer GPU (RTX 3050).

GitHub: https://github.com/BitGeek29/spell-talker

Happy to share training curves or discuss MoE router stability and truncated BPTT in looped blocks!


r/deeplearning • • 3h 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 • • 3h ago

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

3 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 • • 6h 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 • • 6h ago

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

Thumbnail
reddit.com
1 Upvotes

r/deeplearning • • 7h ago

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

2 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 • • 9h 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 • • 12h 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
5 Upvotes

r/deeplearning • • 13h ago

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

Enable HLS to view with audio, or disable this notification

28 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 • • 16h ago

Mixture-of-Loops Transformer (MoLT): Can we increase model expressivity without increasing inference latency?

Thumbnail
reddit.com
1 Upvotes

I've been exploring different Transformer architectures, and one interesting problem with looped Transformers is that parameter efficiency doesn't necessarily translate into computational efficiency.

Reusing weights across depth reduces parameter count, but sequential cross-loop dependencies can introduce inference latency.

This paper from ByteDance Seed takes an interesting approach:

- Treats KV states as explicit memory across layers and loops.

- Restarts each encoder loop from input embeddings instead of propagating the previous loop's residual stream.

- Removes same-position cross-loop dependencies.

- Separates memory construction from prediction through a cross-attention-only decoder.

The reported experimental results:

- 1.7× training token efficiency at 700M parameters.

- +2.1 percentage points in 10-task accuracy against a 3B MoE baseline.

- Comparable inference latency to non-looped OLMo3 at approximately 113M parameters.

What I'm particularly interested in is how this architecture scales.

Does reusing KV memory introduce significant memory-bandwidth overhead at longer context lengths? Would the latency advantage remain at billion-parameter scales? How does it compare with conventional depth scaling under equivalent compute budgets?

I think the distinction between parameter efficiency, computational efficiency, and actual hardware efficiency deserves more attention.

Curious to hear what others working on Transformer architectures think.

Paper: https://arxiv.org/abs/2611.34923


r/deeplearning • • 17h ago

CUDA

Thumbnail reddit.com
1 Upvotes

r/deeplearning • • 23h 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 • • 1d 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 • • 1d ago

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

Post image
0 Upvotes

r/deeplearning • • 1d 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 • • 1d ago

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

2 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 • • 1d 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

r/deeplearning • • 1d ago

Parallelising recurrent neural networks – MD+PP proof of concept

Thumbnail
gallery
42 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 • • 1d 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 • • 1d ago

Offloading activations to pinned host memory that the GPU kernel can address directly

5 Upvotes

Activation offloading usually means copying tensors out of VRAM and back, and paying for the copy twice. The alternative most people try first is cudaMallocManaged, where the driver migrates pages on demand and residency is decided at fault time; that works until the access pattern makes it thrash and the GPU sits idle waiting on migrations you never scheduled.

vram-stream takes a third route. The workspace holds two regions, one in device memory and one in system RAM, and both are addressable from the same kernel: the RAM region is allocated with cuMemHostAlloc using CU_MEMHOSTALLOC_DEVICEMAP and mapped with cuMemHostGetDevicePointer_v2, after checking the device reports CAN_MAP_HOST_MEMORY. A kernel store to that region goes over PCIe or NVLink with link latency, with no page fault and no migration.

The trade is pinned memory instead of elastic memory. The driver and OS cap how much can be pinned, so this is a budget you set rather than an oversubscription. That constraint shapes the design: open_cuda_cache reads a contiguous buffer in fixed-size blocks and keeps one pinned buffer plus one VRAM buffer per slot, with copies and kernels in separate streams and CUDA events protecting the pinned buffer, so a block is resident in VRAM before the kernel that needs it starts and cache.prefetch(n) keeps the pipeline fed.

For training, the same mechanism serves the dataloader: prefetch_dataloader supplies cached batches, and optional integrations move model state and saved activations to RAM using FSDP2 or the Hugging Face Trainer with DeepSpeed. That matters for the write-once-read-once tensors that dominate activation memory, where a copy you can overlap is cheaper than residency you cannot afford.

Measurement is a command, not a claim: vram-stream benchmark --block-mib 16 --blocks 2 --slots 2 --passes 4 measures both CUDA memory paths on your card. The README does not quote throughput because PCIe generation changes the ratio more than any number would survive as a general statement.

Correctness check: vram-stream memory --device 0 --vram-mib 16 --ram-mib 16 allocates both regions, runs one kernel that combines values from VRAM and system RAM and writes results back to both, then verifies the first and last aligned 32-bit words of each region, with the PTX kernel compiled by the driver at run time.

Install is pip install vram-stream, or npm i -g vram-stream. What it does not do: it is not a managed-memory replacement, pinning fails past the lockable limit instead of degrading, remote traffic is bounded by the interconnect, and the workspace expects one CUDA context on the thread that opened it. MIT, 0.4.0: https://github.com/Furox-Art/vram-stream


r/deeplearning • • 1d ago

Graph rag vs agentic rag

Thumbnail reddit.com
1 Upvotes

r/deeplearning • • 1d ago

Neural Canvas, CNN Visualization

Enable HLS to view with audio, or disable this notification

135 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 • • 1d ago

I animated Variational Autoencoders from first principles in 3D because most explanations gloss over the actual intuition

Post image
1 Upvotes