from transformers import AutoConfig
from trl.trainer.utils import compute_flops_per_token
DENSE_MODEL_ID = "trl-internal-testing/tiny-Qwen3ForCausalLM"
# Tied and untied should have the same FLOPS
cfg = AutoConfig.from_pretrained(DENSE_MODEL_ID)
cfg.tie_word_embeddings = True
f_tied = compute_flops_per_token(cfg, 16384)
cfg.tie_word_embeddings = False
f_untied = compute_flops_per_token(cfg, 16384)
expected_delta = 0
assert f_untied - f_tied == expected_delta
AssertionError Traceback (most recent call last)
[/tmp/ipykernel_1600/1286663483.py](https://localhost:8080/#) in <cell line: 0>()
11 f_untied = compute_flops_per_token(cfg, 16384)
12 expected_delta = 0
---> 13 assert f_untied - f_tied == expected_delta
AssertionError:
Reproduction
outputs:
System Info
Checklist