# How to improve my tokens per second?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-improve-my-tokens-per-second%2F190270%3E%5C
**Category:** Research\
**Created:** [October 10, 2026, 2:09am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-improve-my-tokens-per-second%2F190270 "2026-10-10T02:09:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Digilidaahz](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@Digilidaahz](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FDigilidaahz)%5C
**Post date:** [October 10, 2026, 2:09am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-improve-my-tokens-per-second%2F190270%2F1 "2026-10-10T02:09:55Z")

</div>

I am now pretraining a 1B model (Model: ~977M params, 24 layers, 1792 hidden, 16 heads, 112 head dim, SwiGLU, RoPE, weight-tied embeddings) from a RTX 5080 16gb VRAM, I ran it on WSL Ubuntu and also enables gradient checkpoints, BF16 autocast, 8-bit AdamW, Pytorch SDPA, and now my micro batch size is 1, gradient accumulation is 16, context is 4096; I tried to have larger micro batch but it will cause OOM; now I have a 8000-9000 tokens / second in average. Seeking for ways to make the training faster…

Thank you for reading.

---

<div class="post-metadata">

**Author:** ![RDTvlokip](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rdtvlokip/32/62725_2.png) [@RDTvlokip](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRDTvlokip)%5C
**Post date:** [October 10, 2026, 11:57am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-improve-my-tokens-per-second%2F190270%2F2 "2026-10-10T11:57:10Z")

</div>

You’re at roughly 65 TFLOPS of useful compute (about 6 × params FLOPs per token, plus the recompute from gradient checkpointing), which leaves headroom: the LLMQ paper reports around 51% MFU on consumer GPUs with an optimized stack. In order of expected payoff:

1. `torch.compile` on the model. It fuses RMSNorm, RoPE and SwiGLU into fewer kernels and was worth about 1.5x in published single-GPU training benchmarks.
2. Liger Kernel’s fused linear + cross-entropy (plus its RMSNorm/RoPE/SwiGLU kernels). It never materializes the full 4096 x vocab logits, which is often the biggest memory hog at your size. The freed VRAM is the real win: you can drop gradient checkpointing or only checkpoint some layers, which removes roughly a third of the extra compute, and then try micro batch 2 or more.
3. FP8 matmuls (torchao float8 or LLMQ). Blackwell consumer cards support it, but compare the loss curve against bf16 for a few thousand steps before trusting it for a long run.
4. Housekeeping: confirm SDPA is actually using the flash backend, keep the dataset on the WSL ext4 disk instead of `/mnt/c`, pre-tokenize and pack sequences so there’s no padding, and use a fused optimizer.

Run the PyTorch profiler for a few steps first to see whether you’re bound by memory-bound ops, recompute or data loading, so you apply the right fix.

Also worth knowing: the big matmuls are compute-bound, but everything between them (norms, RoPE, SwiGLU, softmax, logits) is memory-bandwidth-bound, and on a 16 GB card with ~960 GB/s that’s where a lot of your step time goes. That’s why kernel fusion (compile, Liger) gives such large gains, and why FP8 helps beyond just faster matmuls.

---

<div class="post-metadata">

**Author:** ![Digilidaahz](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@Digilidaahz](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FDigilidaahz)%5C
**Post date:** [October 23, 2026, 10:28am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-improve-my-tokens-per-second%2F190270%2F3 "2026-10-23T10:28:24Z")

</div>

Thank you! That breakdown of memory-bandwidth vs compute-bound actually makes perfect sense. It explains why everything feels so bottlenecked.

I actually tried a couple of these on my setup (RTX 5080, WSL, PyTorch 2.14 + CUDA 13). `torch.compile` basically died because of graph breaks with my custom checkpointing. Liger was even worse—I hit hard `CUBLAS` and `illegal memory access` errors on CUDA 13, even on the nightly build. So I just reverted to plain eager mode, sadly. FP8 sounds terrifying mid-run, so I’m definitely skipping that for now.

Data is already on ext4 and pre-packed, but I’ll double-check my SDPA backend right now.

Since Liger is a dead end for my stack, have you messed around with `torchao`’s fused kernels for norms/SwiGLU on newer Torch versions? Wondering if that’s a safer path. Thanks again for the pro breakdown!

---

<div class="post-metadata">

**Author:** ![nootxlm](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nootxlm/32/63395_2.png) [@nootxlm](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnootxlm)%5C
**Post date:** [October 23, 2026, 11:23am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-improve-my-tokens-per-second%2F190270%2F4 "2026-10-23T11:23:42Z")

</div>

Torchao is probably not that path — its feature set is quantization, sparsity, and FP8 training, not drop-in fused RMSNorm/SwiGLU kernels, so it leads back toward the FP8 route you already ruled out. Two routes stay in stock PyTorch: chunk the loss — run the LM head and cross-entropy over slices of the sequence (512 tokens at a time, each chunk weighted by its token count) so the full 4096 × vocab logits and their gradient are never materialized; and if your checkpointing is the reentrant variant, try use\_reentrant=False, the variant torch.compile traces far more cleanly. Check both on one fixed batch: the chunked loss should match your current loss to floating-point tolerance, and the peak-VRAM drop plus a compile run without graph-break warnings tells you whether the freed memory buys back a checkpointed layer.

---

<div class="post-metadata">

**Author:** ![RynHong](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/rynhong/32/63647_2.png) [@RynHong](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRynHong)%5C
**Post date:** [October 24, 2026, 11:01am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-improve-my-tokens-per-second%2F190270%2F5 "2026-10-24T11:01:17Z")

</div>

One thing worth checking is whether your model is running on the GPU or falling back to the CPU. You can also try a smaller batch size, use a lower-precision format like FP16 or BF16 if your hardware supports it, and make sure you’re using an optimized attention implementation. Benchmark with the same prompt and generation length each time so you can tell which change actually improves tokens per second.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [October 24, 2026, 11:01pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-improve-my-tokens-per-second%2F190270%2F6 "2026-10-24T23:01:28Z")

</div>

Closed on October 24, 2026, 11:01pm UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
