Skip to content

Baseline SDPA returning attention weights, calling FlexAttention 2x (… - #78

Merged
mseeger merged 2 commits into
mainfrom
flexatt_attn_weights3
Mar 31, 2026
Merged

mseeger merged 2 commits into
mainfrom
flexatt_attn_weights3

Conversation

@mseeger

@mseeger mseeger commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

…#78)

Closes #77.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mseeger

mseeger commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Timing comparisons:

h2o-torch-quantized8, batch_size 2 [old way]

CUDA_VISIBLE_DEVICES="1" PYTORCH_ALLOC_CONF=expandable_segments:True KEYSVALS_LOG_DIR="/home/ubuntu/out/finetune/neurips_exp/lora/qwen3_4b/debug3/logs" python3 keys_values/__main__.py finetune_long_lora Qwen/Qwen3-4B-Instruct-2507 --out_dir /home/ubuntu/out/finetune/neurips_exp/lora/qwen3_4b/debug3 --precision bf16-true --verbose some --data Helmet --data.dataset_key nq --data.max_length 64k --data.metadata_dir /home/ubuntu/out/finetune/data --train.save_interval 10 --train.micro_batch_size 2 --train.global_batch_size 2 --eval.interval 10  --eval.initial_validation False --data.trainloader_longest_first True --attention_forward_temp_size_gb 2 --kv_cache.cache_length 32768 --kv_cache.chunk_size 2048 --kv_cache.name h2o-torch-quantized8 --kv_cache.cpu_offload True --grad.layers_per_cell 1 --sdpa.use_flex_for_attn_weights False

Epoch 0 | iter   1 step   1 | loss train: 35.500, val: n/a | iter time: 320.342 s (step)
Epoch 0 | iter   2 step   2 | loss train: 11.562, val: n/a | iter time: 231.608 s (step)
Epoch 0 | iter   3 step   3 | loss train: 18.500, val: n/a | iter time: 183.267 s (step)
Epoch 0 | iter   4 step   4 | loss train: 23.500, val: n/a | iter time: 203.630 s (step)
Epoch 0 | iter   5 step   5 | loss train: 12.062, val: n/a | iter time: 199.982 s (step)
Epoch 0 | iter   6 step   6 | loss train: 22.750, val: n/a | iter time: 194.152 s (step)
Epoch 0 | iter   7 step   7 | loss train: 17.125, val: n/a | iter time: 202.254 s (step)
Epoch 0 | iter   8 step   8 | loss train: 16.250, val: n/a | iter time: 187.373 s (step)
Epoch 0 | iter   9 step   9 | loss train: 22.500, val: n/a | iter time: 182.474 s (step)
Epoch 0 | iter  10 step  10 | loss train: 29.250, val: n/a | iter time: 185.096 s (step)
Epoch 0 | iter  10 | val loss: 24.032 | val ppl: 27337745273.068 | val_time: 4546.169 s
Epoch 0 | iter  11 step  11 | loss train: 21.375, val: 24.032 | iter time: 199.100 s (step)
Epoch 0 | iter  12 step  12 | loss train: 17.000, val: 24.032 | iter time: 230.288 s (step)

h2o-torch-quantized8, batch_size 2 [new code here]

Epoch 0 | iter   1 step   1 | loss train: 34.250, val: n/a | iter time: 197.395 s (step)
Epoch 0 | iter   2 step   2 | loss train: 11.750, val: n/a | iter time: 149.685 s (step)
Epoch 0 | iter   3 step   3 | loss train: 18.750, val: n/a | iter time: 123.937 s (step)
Epoch 0 | iter   4 step   4 | loss train: 23.000, val: n/a | iter time: 131.736 s (step)
Epoch 0 | iter   5 step   5 | loss train: 11.750, val: n/a | iter time: 132.532 s (step)
Epoch 0 | iter   6 step   6 | loss train: 23.625, val: n/a | iter time: 130.651 s (step)
Epoch 0 | iter   7 step   7 | loss train: 17.375, val: n/a | iter time: 132.344 s (step)
Epoch 0 | iter   8 step   8 | loss train: 16.000, val: n/a | iter time: 123.515 s (step)
Epoch 0 | iter   9 step   9 | loss train: 22.500, val: n/a | iter time: 120.728 s (step)
Epoch 0 | iter  10 step  10 | loss train: 29.250, val: n/a | iter time: 122.014 s (step)
Epoch 0 | iter  10 | val loss: 24.007 | val ppl: 26672499225.830 | val_time: 1386.918 s
Epoch 0 | iter  11 step  11 | loss train: 22.000, val: 24.007 | iter time: 139.328 s (step)
Epoch 0 | iter  12 step  12 | loss train: 17.000, val: 24.007 | iter time: 151.398 s (step)

lastrec-torch-quantized8, batch_size 2

Epoch 0 | iter   1 step   1 | loss train: 20.875, val: n/a | iter time: 188.503 s (step)
Epoch 0 | iter   2 step   2 | loss train: 30.250, val: n/a | iter time: 141.426 s (step)
Epoch 0 | iter   3 step   3 | loss train: 32.250, val: n/a | iter time: 116.182 s (step)
Epoch 0 | iter   4 step   4 | loss train: 39.000, val: n/a | iter time: 126.109 s (step)
Epoch 0 | iter   5 step   5 | loss train: 33.000, val: n/a | iter time: 125.339 s (step)
Epoch 0 | iter   6 step   6 | loss train: 33.750, val: n/a | iter time: 121.603 s (step)
Epoch 0 | iter   7 step   7 | loss train: 25.000, val: n/a | iter time: 124.318 s (step)
Epoch 0 | iter   8 step   8 | loss train: 42.750, val: n/a | iter time: 116.696 s (step)
Epoch 0 | iter   9 step   9 | loss train: 46.000, val: n/a | iter time: 115.306 s (step)
Epoch 0 | iter  10 step  10 | loss train: 48.000, val: n/a | iter time: 116.261 s (step)
Epoch 0 | iter  10 | val loss: 40.092 | val ppl: 258048193786467328.000 | val_time: 1151.639 s

Not much slower than lastrec, but better eval loss!

@mseeger mseeger self-assigned this Mar 31, 2026
@mseeger
mseeger merged commit ff6b269 into main Mar 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement baseline for SDPA returning summed attention weights (using FlexAttention)

1 participant