Skip to content

Fix KS evaluator dropping literal Triton constexpr globals - #194

Merged
zhaochaoxing merged 7 commits into
mainfrom
fix/ks-constexpr-global-loading
Oct 23, 2026
Merged

zhaochaoxing merged 7 commits into
mainfrom
fix/ks-constexpr-global-loading

Conversation

@xieminghui187

Copy link
Copy Markdown
Contributor

Problem

The definition loader keeps module-level assignments only when their RHS is a literal. Valid Triton globals such as LOG2_E = tl.constexpr(1.4426950408889634) and NEG_INF = tl.constexpr(float("-inf")) are silently discarded. Kernels referencing them then fail with undefined-name errors before an effective accuracy comparison.

Changes

  • Resolve Triton constexpr constructors from imports, including aliases.
  • Preserve literal-valued constexpr assignments and annotated assignments, including literal float(...) sentinels.
  • Preserve source order without special-casing contestant constant names.
  • Continue filtering arbitrary call assignments and executable top-level statements.
  • Leave output structure/type checks, tolerances, timing, and device handling unchanged.

This remains a narrow definition-loading policy, not a security sandbox: imports, decorators, and class bodies already execute.

Validation

python -m unittest discover -s tests -p test_ks_auto_bench_loader.py -v
git diff --check

All 6 CPU-only regression tests pass. PyTorch/Triton dependencies are stubbed, while the actual evaluator loader is exercised. Coverage includes constant visibility in a kernel, aliases, annotated assignments, arbitrary constant names, source ordering, rejected arbitrary calls, unrelated constexpr methods, and unchanged strict list/Tensor rejection.

The regression case also reproduces NameError: name 'LOG2_E' is not defined with the original upstream filter. Uploaded files were fetched back and verified byte-for-byte against the locally tested files.

No accelerator end-to-end benchmark has been run with this generalized patch. This PR does not change submissions or determine competition scores.

Preserve literal-valued Triton constexpr globals, including infinity sentinels and import aliases. Keep arbitrary calls filtered and strict output comparison unchanged.
@CLAassistant

CLAassistant commented Oct 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@zhaochaoxing
zhaochaoxing merged commit 12242ca into main Oct 23, 2026
4 checks passed
@zhaochaoxing
zhaochaoxing deleted the fix/ks-constexpr-global-loading branch October 23, 2026 06:48
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.

3 participants