Rule-based GPU kernel hack detector.
Project description
KernelGuard
KernelGuard is a rule-based kernel hack detector for GPU-kernel competition submissions.
The core module is kernelguard.py, which can:
- classify a single submission from stdin
- scan JSONL pair datasets
- scan submission parquet exports
- generate a rule audit from a local review corpus
- load runtime config from built-in profiles, TOML files, and command-line overrides
Current Layout
kernelguard.pyMain detector and audit tool.
Install
From PyPI:
pip install kernelguard
With parquet support:
pip install kernelguard[parquet]
Via uv (no install needed):
uvx kernelguard --help
uvx --with pyarrow kernelguard --parquet submissions.parquet
Or install permanently with uv:
uv tool install kernelguard
uv tool install kernelguard[parquet]
Both kernelguard and kguard are available as entry points after installation.
Quick Start
Single kernel from stdin:
kernelguard --api-mode < submission.py
JSONL scan:
kernelguard --jsonl /path/to/pairs.jsonl --output-dir out/
Parquet scan:
kernelguard --parquet /path/to/submissions.parquet --output-dir out/
Runtime Config
The standalone repo already includes the later config-support additions from the newer line of development.
Runtime behavior can be controlled with:
--profileSelect a built-in profile.--configLoad a TOML config file.--setApply dottedkey=valueoverrides from the CLI.--export-configPrint or write the resolved config and exit.
Examples:
Export the default resolved config:
kernelguard --export-config
Export the strict profile:
kernelguard --profile strict --export-config
Run with a TOML config file:
kernelguard --config kernelguard.toml --jsonl /path/to/pairs.jsonl --output-dir out/
Apply a one-off override:
kernelguard --set 'entrypoints.names=["kernel"]' --api-mode < submission.py
The config layer covers:
- rule policy overrides
- score thresholds
- duplicate handling
- classification behavior
- entrypoint-name configuration
Compatibility
The primary public interfaces are:
--api-modefor a single kernel--jsonlfor pair datasets--parquetfor submission exports
The detector also keeps some legacy compatibility for older internal audit/archive workflows so historical corpora can still be reused.
Audit Behavior
--audit-rules is meant to run in a workspace that contains the audit corpora and prior detector outputs.
This is an internal evaluation mode, not a normal first-run path.
If no audit fixtures are discovered, the command exits with a clear error instead of silently producing an empty audit report.
Minimal audit run:
kernelguard --audit-rules --output-dir audit_out/
If you want to drive audit mode from explicit inputs, put them in your config file:
[audit]
archive_dir = "/path/to/archive"
ground_truth_dir = "/path/to/ground_truth_dir"
manual_review_files = [
"/path/to/manual_review_1.json",
"/path/to/manual_review_2.json",
]
filtered_results_path = "/path/to/filtered_results.jsonl"
To compare old and new detector outputs explicitly during audit, put them in config too:
[audit.result_files]
old = "/path/to/old_results.jsonl"
new = "/path/to/new_results.jsonl"
Then run:
kernelguard --config kernelguard.toml --audit-rules --output-dir audit_out/
Generated audit artifacts include:
classifier_fixture_manifest.jsonrule_audit_report.jsonrule_audit_report.md
Generated scan artifacts include:
detection_results_*.jsonldetection_summary_*.jsoncleaned_pairs.jsonl
These generated files are ignored by the repo-level .gitignore.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kernelguard-0.1.0.tar.gz.
File metadata
- Download URL: kernelguard-0.1.0.tar.gz
- Upload date:
- Size: 48.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8b2c6a1bb97a6159959b479742a531a4e13cc43c4c7dc34e29653e28bc3ef9f
|
|
| MD5 |
4f66a1278c8db6d4a88cddebb358a4e0
|
|
| BLAKE2b-256 |
e37410e54c3062e4dfc29e4d7b447f54186b0837b51f5d4d69014007a585a253
|
File details
Details for the file kernelguard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kernelguard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 48.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a0385ac88797b08e605a1fed3e7164959908b4e274c9f915e2c1d33c97de8d8
|
|
| MD5 |
645515acea6e77306a47db9baceed6ff
|
|
| BLAKE2b-256 |
b7768d6cf915f0f6cabe1da24e98b405045b21f5d95d1ce6765c9ba8b605cfbe
|