python-cut-cross-entropy

CLEAN
maintainer Smoolak 0 votes scanned 2026-09-21 00:26:32.109917
View on AUR

Triggered rules

Clean AI review downgraded a static finding llm_review

The static rules flagged this LOW, but an AI model (qwen/qwen3-235b-a22b-2507) reviewed the full PKGBUILD and judged it CLEAN (confidence 95%): The package builds from a pinned commit of the official GitHub repository, applies a minor patch for test correctness, and installs a wheel built locally; no untrusted remote code execution or supply-chain risks are present.

1 higher static finding superseded - not the current verdict (shown for transparency)
Low Few votes, recently uploaded zero_votes_recent

Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.

PKGBUILD

1# Maintainer: Smoolak <smoolak@gmail.com>
2
3pkgname=python-cut-cross-entropy
4_pkgname=cut_cross_entropy
5pkgver=25.9.3
6pkgrel=3
7pkgdesc="A fast implementation of cross entropy loss using cut method with Triton kernels"
8arch=('any')
9url="https://github.com/apple/ml-cross-entropy"
10license=('LicenseRef-Apple-Sample-Code')
11depends=(
12 'python'
13 'python-packaging'
14 'python-pytorch'
15 'python-setuptools'
16 'python-triton'
17)
18makedepends=(
19 'git'
20 'python-build'
21 'python-installer'
22 'python-setuptools'
23 'python-setuptools-scm'
24 'python-wheel'
25)
26checkdepends=(
27 'python-pytest'
28)
29optdepends=(
30 'python-nvidia-ml-py: for GPU clock detection when nvidia-smi is unavailable'
31 'python-transformers: for Hugging Face Transformers monkey-patching'
32)
33_archive="ml-cross-entropy"
34# Upstream cuts no tags; pin the commit whose cut_cross_entropy.__version__ == pkgver.
35_commit=b7a02791b234e187b524fb1dba6a812d521b203a
36source=(
37 "git+$url.git#commit=$_commit"
38 'cce-exact-cpu-test-skip.patch'
39)
40sha256sums=(
41 'SKIP'
42 'e2b118aff76eced3e32650c75e2fd38b36549c8527a523c434eae5d1b88c7400'
43)
44
45prepare() {
46 cd "$_archive"
47 # The parameter is named "cce_exact"; upstream's "cce" comparison can
48 # never match and runs Ampere-only kernels during its CPU test job.
49 patch -Np1 -i "$srcdir/cce-exact-cpu-test-skip.patch"
50}
51
52build() {
53 cd "$_archive"
54 python -m build --wheel --no-isolation
55}
56
57check() {
58 cd "$_archive"
59 # CUDA/Triton kernel cases carry their own upstream skip marker. The same
60 # complete suite also exercises CPU z-loss and distributed/FSDP utilities.
61 CUDA_VISIBLE_DEVICES='' PYTHONPATH="$PWD:$PYTHONPATH" pytest -ra
62
63 CUDA_VISIBLE_DEVICES='' PYTHONPATH="$PWD:$PYTHONPATH" python - <<'PY'
64import torch
65from cut_cross_entropy import linear_cross_entropy
66
67torch.manual_seed(4)
68embeddings = torch.randn(2, 3, 5, requires_grad=True)
69classifier = torch.randn(7, 5, requires_grad=True)
70targets = torch.tensor([[1, 2, 3], [3, 4, 5]])
71actual = linear_cross_entropy(
72 embeddings, classifier, targets, impl="torch_compile"
73)
74expected = torch.nn.functional.cross_entropy(
75 (embeddings @ classifier.T).flatten(0, 1), targets.flatten()
76)
77torch.testing.assert_close(actual, expected, rtol=1e-4, atol=1e-5)
78actual.backward()
79assert embeddings.grad is not None and classifier.grad is not None
80print("CPU linear cross-entropy workflow passed")
81PY
82}
83
84package() {
85 cd "$_archive"
86 python -m installer --destdir="$pkgdir" dist/*.whl
87 install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
88}
89

Scan history

Scanned at (UTC)SeverityRules
2026-09-21 00:26:32 Clean 2
2026-09-20 23:33:19 Low 1

Report a package

Reports go to the AURWatch maintainer (one person) and are read by hand. No login required.

0 / 4000
Your suggestion