---
title: "Beyond Prompting: How Algorithmic Evolution Doubled our Training Speed"
description: "Klarna used Google DeepMind's AlphaEvolve to evolve nearly 6,000 candidate versions of the PyTorch training pipeline for a large transformer trained on payment events."
url: "https://swe.quest/articles/beyond-prompting-how-algorithmic-evolution-doubled-our-training-speed-3669307c6d5f1431"
canonical: "https://engineering.klarna.com/beyond-prompting-how-algorithmic-evolution-doubled-our-training-speed-8f874af3080d"
source: "Klarna Engineering"
published: "2026-03-30"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["model-training","performance","ai-coding","payments"]
---

# Beyond Prompting: How Algorithmic Evolution Doubled our Training Speed

A post on [Klarna Engineering](https://swe.quest/sources/klarna.md), published 2026-03-30, 7 min read, Case study. Original: [https://engineering.klarna.com/beyond-prompting-how-algorithmic-evolution-doubled-our-training-speed-8f874af3080d](https://engineering.klarna.com/beyond-prompting-how-algorithmic-evolution-doubled-our-training-speed-8f874af3080d)

## Summary

Klarna used Google DeepMind's AlphaEvolve to evolve nearly 6,000 candidate versions of the PyTorch training pipeline for a large transformer trained on payment events. Over three weeks it raised throughput from 49 to about 97 samples per second under strict determinism, while also improving model quality. Early generations found mixed precision, async CPU-GPU transfers and on-device metric accumulation. Opening the forward pass and data loader to evolution led to deeper rewrites: direct scaled dot-product attention calls in place of PyTorch Transformer modules, and a pre-allocated contiguous dataset buffer sliced into batches. Key lessons: impose hard constraints such as reproducibility from the start (a non-deterministic TF32/cuDNN path reached 143 samples/s but could never be deployed), set plateau-based early stopping, and use a stronger LLM, which raised valid-program rates from about a third to 86–97%.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [AI for coding](https://swe.quest/tags/ai-coding.md) (AI & ML)
- [Payments & fintech](https://swe.quest/tags/payments.md) (Domains)

## Prerequisites

- PyTorch training loops ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- mixed-precision training ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- transformer attention

## Keywords

AlphaEvolve, PyTorch, Google DeepMind, scaled dot-product attention, TensorFloat-32, cuDNN, Klarna

## Related posts

- [Accelerating Transformers Fine-Tuning with NVIDIA NeMo AutoModel](https://swe.quest/articles/accelerating-transformers-fine-tuning-with-nvidia-nemo-automodel-c196d721b8de0a9a.md): Hugging Face · 2026-06-24 · Hard · 10 min read · Model training, Performance engineering, LLMs, Python
  NeMo AutoModel subclasses Transformers v5's AutoModelForCausalLM and adds Expert Parallelism as a dedicated mesh orthogonal to data parallelism, DeepEP fused all-to-all dispatch, and TransformerEngine kernels.
- [Productizing Large Language Models](https://swe.quest/articles/productizing-large-language-models-5be0923873af50a1.md): Replit · 2022-09-21 · Medium · 6 min read · Inference & serving, LLMs, AI for coding, Evaluation, Kubernetes
  Replit runs transformer models from ~100M parameters (search, spam) through 1-10B (GhostWriter code autocomplete) to 100B+ in production, and shares lessons on making them usable.
- [Accelerate 1.0.0](https://swe.quest/articles/accelerate-1-0-0-3876b57c9168d12c.md): Hugging Face · 2024-09-13 · Medium · 5 min read · Model training, Python, Machine learning
  Hugging Face has published the first release candidates for Accelerate 1.0.0.
- [GEM Training: How Meta Doubled the Efficiency of Its LLM-Scale Ads Foundation Model](https://swe.quest/articles/gem-training-how-meta-doubled-the-efficiency-of-its-llm-scale-ads-foundation-1bf8547a323404ba.md): Meta Engineering · 2026-08-03 · Hard · 21 min read · Model training, Recommendations & ranking, Performance engineering, Hardware, Ads
  Meta doubled end-to-end training efficiency of GEM, its LLM-scale ads recommendation foundation model, to 20–25% MFU while scaling training FLOPs 4x in a year, by co-designing kernels, precision, parallelism, networking and memory.
- [Optimum+ONNX Runtime - Easier, Faster training for your Hugging Face models](https://swe.quest/articles/optimum-onnx-runtime-easier-faster-training-for-your-hugging-face-models-99e01d7695af970a.md): Hugging Face · 2023-01-24 · Medium · 6 min read · Model training, Performance engineering, Python
  Hugging Face Optimum's ORTTrainer swaps ONNX Runtime in as the training backend for Transformers models.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
