# Three packages. The GRU is written out by hand in numpy, forward and
# backward, so there is no deep learning framework here at all.
numpy==2.2.6
pandas==2.3.3
PyYAML==6.0.3

# ----------------------------------------------------------------------------
# torch, the optional path, and exactly what changes if you take it
# ----------------------------------------------------------------------------
# torch==2.5.1
#
# `models/gru.py` is about 260 lines, of which roughly 90 are the GRU forward
# pass, the backward pass and the Adam step. In torch those 90 lines become:
#
#     self.emb = nn.Embedding(n_items, emb_dim)
#     self.gru = nn.GRU(emb_dim, hidden_dim, batch_first=True)
#     self.out = nn.Linear(hidden_dim, n_items)
#     loss = F.cross_entropy(logits, targets)
#     loss.backward()
#
# What you GAIN, with numbers from this repository's own shapes:
#
#   cuDNN's fused GRU kernel runs the whole sequence in one launch instead of
#   one python-level loop iteration per timestep. At a 48-unit hidden state and
#   a mean session of 4.3 events that is worth maybe 3x on CPU; at a 512-unit
#   hidden state and 30-event sessions it is worth 50x or more, and the python
#   loop in `_forward` becomes the entire training cost.
#
#   Autograd removes the class of bug this repository actually hit. The one
#   real sign error here was in the BPR gradient and it did not crash, it
#   anti-learned to recall@20 of 0.0856 against a 0.0625 random floor. Autograd
#   cannot make that mistake. `check_gradients()` is the substitute and it is a
#   worse one.
#
#   A GPU, which is the whole reason to care at production scale: the output
#   layer at 180,000 items and a 512-unit state is a 92M-parameter matmul per
#   step, and that is a GPU problem.
#
# What you LOSE, which is the reason this repository does not take it:
#
#   The two decisions that moved the metric most here are invisible behind a
#   framework call. `nn.CrossEntropyLoss` over a full `nn.Linear` output does
#   not sample negatives at all, so the negative DISTRIBUTION question, which
#   is the largest single effect in `--negatives`, does not come up until the
#   catalogue is too large for a full softmax and you go looking for
#   `nn.functional.log_softmax` over a sampled subset and discover you have to
#   write the collision guard yourself anyway.
#
#   The sampled-softmax collision guard, the thing that stops a target from
#   appearing in its own negative set, is not in any framework's default path.
#   It is five lines in `_output_grads`, it is worth 0.0015 recall@20 here,
#   and the interesting part is that the collision RATE is 0.5002, so the
#   effect is 300x smaller than the rate. A collided pair contributes a logit
#   difference of exactly zero: it dilutes the update rather than reversing
#   it. That is the kind of thing you learn by writing the layer and not by
#   calling it.
#
# If you port this: keep `data/`, `eval/` and `models/baselines.py` unchanged,
# replace `models/gru.py`, and check the port against the numpy version's
# recall@20 of 0.6747 on the default config before trusting it.
#
# ----------------------------------------------------------------------------
# scipy and scikit-learn, deliberately absent
# ----------------------------------------------------------------------------
# scipy==1.14.1
# scikit-learn==1.5.2
#
# Neither is needed. `eval/diagnostics.py` computes its leading eigenvector by
# power iteration rather than calling `scipy.sparse.linalg.eigsh`, and
# `models/baselines.py` builds a dense 320x320 co-occurrence matrix rather than
# a `scipy.sparse` one. At a real catalogue size both choices flip: a
# 180,000 x 180,000 dense co-occurrence matrix is 130 TB and the item-kNN
# baseline becomes a `scipy.sparse.csr_matrix` with a top-k truncation per row,
# which is 40 lines and the single most useful thing scipy would add here.
