Skip to content

test: add end-to-end coverage for adversarial_temperature/grouped sampling - #456

Merged
Demirrr merged 1 commit into
developfrom
test/adversarial-temperature-e2e
Sep 16, 2026
Merged

Demirrr merged 1 commit into
developfrom
test/adversarial-temperature-e2e

Conversation

@Demirrr

@Demirrr Demirrr commented Sep 16, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #446.

Before this, the only coverage of adversarial_temperature/grouped_negative_sampling/strict_negative_sampling was the unit-level routing test in tests/test_unit_base_model.py::TestAdversarialTemperatureLossFunction (#441) — it checks that BaseKGE.loss_function calls grouped_adversarial_bce, but never trains a real model through Execute(args).start(). That's the same kind of gap that let the loss_function dead-code bug (#441) go unnoticed for a while: training looked fine (no errors, a loss value came out) while silently using the wrong loss.

Adds tests/test_adversarial_temperature.py:

  • DistMult on UMLS trains and produces a finite MRR with adversarial_temperature set (both the temperature > 0 softmax-weighted branch and the temperature = 0 uniform-weight branch of grouped_adversarial_bce), with grouped_negative_sampling=True, and with strict_negative_sampling=True — individually and combined, under both torchCPUTrainer and PL.
  • Edge cases from static_preprocess_funcs.py's validation: neg_ratio at its minimum allowed value (1) trains successfully; neg_ratio=0, negative/NaN/infinite adversarial_temperature, scoring_technique != "NegSample", byte_pair_encoding=True, and an unsupported trainer each raise the expected ValueError.

No source changes — test-only PR.

Test plan

  • ruff check dicee/ --line-length=200 — clean (unaffected, test-only change)
  • All 14 new tests pass

…pling

Before this, the only coverage of adversarial_temperature/
grouped_negative_sampling/strict_negative_sampling was the unit-level
routing test in tests/test_unit_base_model.py::TestAdversarialTemperatureLossFunction
(#441), which checks BaseKGE.loss_function calls grouped_adversarial_bce
but never trains a real model through Execute(args).start(). That's the
same kind of gap that let the loss_function dead-code bug (#441) go
unnoticed - training looked fine (no errors, a loss value came out) while
silently using the wrong loss.

Adds tests/test_adversarial_temperature.py:
- DistMult on UMLS trains and produces a finite MRR with
  adversarial_temperature set (both the temperature>0 softmax-weighted
  branch and the temperature=0 uniform-weight branch of
  grouped_adversarial_bce), with grouped_negative_sampling=True, and with
  strict_negative_sampling=True, individually and combined - under both
  torchCPUTrainer and PL
- edge cases from static_preprocess_funcs.py's validation: neg_ratio at
  its minimum allowed value (1) trains successfully; neg_ratio=0,
  negative/NaN/infinite adversarial_temperature, scoring_technique!=
  NegSample, byte_pair_encoding=True, and an unsupported trainer (TP;
  torchDDP/torchFSDP fail earlier for an unrelated reason - they require
  a torchrun launch) each raise the expected ValueError

Fixes #446

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Demirrr
Demirrr merged commit e0b09f1 into develop Sep 16, 2026
7 checks passed
@Demirrr
Demirrr deleted the test/adversarial-temperature-e2e branch September 16, 2026 11:49
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.

No end-to-end regression test for adversarial_temperature / grouped negative sampling

1 participant