Alloy
Per-scope code generation backend for DaCe. Input: a dace numpy program with symbolic sizes (as an SDFG).
Alloy splits it into scopes, renders each scope under many codegen knobs, compilers and FP levels,
verifies every candidate, times the survivors, and links the best into one program plus a report. On
HPCAgent-Bench it is a user plugin (alloy/hb_plugin): agents give a manifest with C or NumPy and read the report.
pip install dace-alloy # imports as `alloy`; pulls DaCe extended (PyPI dace-extended, imports as `dace`)
uv sync --extra dev # a checkout of https://github.com/ThrudPrimrose/dace-alloy
import pathlib
from alloy import api
from alloy.frontend import inputs
from examples.two_scopes import two_scopes
manifest = inputs.load(pathlib.Path("examples/two_scopes.yaml"), "examples/two_scopes.py:two_scopes")
if __name__ == "__main__": # Alloy's worker processes re-import this script
result = api.generate(two_scopes.to_sdfg(), pathlib.Path("out"), manifest=manifest) # result.report: report.md
As DaCe's backend no guard is needed: set compiler.build_plugin = alloy-speculative and call sdfg.compile().
Extras: the core (outline, sweep, build) needs only DaCe. bench adds HPCAgent-Bench, which verification and
timing use for manifest inputs and the tolerance band. nvgpu / amdgpu add the matching cupy build. dev is
bench plus the test tools (CPU, what CI installs); dev-nvidia and dev-amd add the GPU extra.
Inputs come from an HPCAgent-Bench style manifest next to the program (two_scopes.yaml: sizes, a fuzzed range,
an args block); without one, candidates are built but not verified.
Layout:
alloy/frontend/:scopesoutlines a program,inputsdraws its inputs from a bench manifest,treeprints the control-flow tree the report carries,cnumpylifts a C kernel plus the bench's binding JSON to canonical NumPy and its SDFG (python -m alloy.frontend.cnumpy kernel.c kernel_binding.json --sdfg kernel.sdfg; the C it accepts is inalloy/hb_plugin/skills/alloy-c/SKILL.md).alloy/backend/:candidatesenumerates the sweep,buildrenders, compiles and checks one candidate,intrinsicsrewrites admitted innermost loops into checked intrinsic DaCe tasklets,runtimeresolves and checks the OpenMP runtime,sweepbuilds every candidate.alloy/evaluate/:linkbuilds whole programs from scope archives,verifychecks candidates on fuzzed inputs,timingtimes them and links alloy-full.alloy/isa/: the machine abstract math ISA (ops.py, 37 ops across 414 CPU rows + 22 assists inintrinsics.toml, 390llvm-mcacost rows incosts.toml, 19 precision-bounded math functions inmathkernels.toml, 26 CUDA + 26 HIP device rows insimt.toml, 23 Tensix rows + 2 card-checked SFPI rungs intensix.toml, 14 SoftHier ops insofthier.toml, and tile kernels inalloy_tile_{cpu,sme,sm90,cdna}*) exposed through one CLI:python -m alloy.isa host|lookup|reverse|assist|kernel|tiers|time|validate|skeleton|ops|isas|schedule|tile|ask|ask-all.validate.pyruns a row's intrinsic or recipe in a compiled kernel, natively or underqemu-aarch64when that is on PATH, or re-measures its tier, before an agent sees it; a row that did not run staysunverified, however it compiled;hints.pybuilds the do-it-yourself response from a scope's tasklets when emission fails;schedules.pyemits compile-and-run-verified C skeletons per loop schedule, with the compiler flags that ask gcc/clang for the same shape. This is the bridge between DaCe's auto-vectorized intrinsic code and the math an agent reasons in.alloy/heuristics/: what Alloy picks without timing:predict,prune,fission,fp,ranges.alloy/tensixgen/: Tenstorrent Tensix code generation from DaCe tile SDFGs (backend.py,split.py,ttsim.py), lowering checkedtensix.tomlrows and automatically substituting card-checked SFPI rungs wherett-metal0.63 misses f32 tolerance.alloy/softhiergen/: SoftHier v1 code generation as a DaCe target (importing it registers the storages, the schedule and the expansions);program.generatelowers an SDFG to one C++ unit, andgate/checks the programs on GVSoC on ault.docs/softhiergen.mddescribes the code as built; update it with every change of behavior.alloy/:api(generate, the entry point),dace_backend(Alloy behindSDFG.compile),gpu/gpu_build/gpu_matrix.toml(GPU threadblock speculation,scalar_decl, intrinsic maps, and profile coordinate descent),guidance(advice for the scopes left short),machine(cores, cache),report(buildsreport.jsonschema 8, rendersreport.mdfrom it, loads it back),records(the strict pydantic configuration of the timing, verdict, report and manifest records). Every CPU compiler, flag and option is inalloy/configuration_matrix.toml, validated by the pydantic models ofalloy/configuration_matrix.py.examples/: input programs for Alloy (dace numpy with symbolic sizes).samples/: A/B studies. Each holds a slow and a fast rendering of one kernel, the harness, and the setup that measured the gap.tests/: one file per module, plus the cross-compiler OpenMP link test.docs/: design decisions with build status, measurement rules, related work.
Tests: pytest -m "not icx" on a box without Intel oneAPI (each compiler is a pytest mark); CI installs gcc,
clang, oneAPI and the NVIDIA HPC SDK and runs all but the avx512, cuda and hip marks, including the
cross-compiler OpenMP link test.
Notes: docs/design.md (decisions), docs/measurement.md (A/B rules), docs/related_work.md (citations).
How to extend it
A run goes frontend/scopes (outline), backend/candidates (the sweep), heuristics/prune (drop what cannot change
the code), backend/sweep and build (render and compile), evaluate/verify (fuzzed inputs), evaluate/timing
(screen and final reps, link alloy_full), report. Add to the step that owns the decision.
- A compiler, FP level, ISA, tail or vector library. Edit
alloy/configuration_matrix.toml; add a field to its pydantic model inalloy/configuration_matrix.pyonly for a new kind of setting.one_factor_at_a_timesweeps what the file lists, and every candidate is verified, so no Python changes for a new row. - A sweep axis. Add the factor to
Candidateand its flips tobackend/candidates.py, then tellheuristics/prunewhen the factor cannot change the object. The prune reason goes in the report, so an axis that looks useless shows up there. - An ISA row. Add
[isa.<isa>.<dtype>.<op>]toalloy/isa/intrinsics.toml, with the spelling checked against the compiler's headers; a composite needs arecipeand thecodethat states its operand order. A new op also goes inOPSinalloy/isa/ops.py, which holds the math, never a spelling. Runpython -m alloy.isa validate: a row is compiled and executed natively, or underqemu-aarch64when that andaarch64-linux-gnu-gccare on PATH. A row that only cross-compiled staysunverified. Do not mark a row verified by hand. - A math kernel.
alloy/isa/mathkernels.pyandhelpers/mathfit.py, which fits the coefficients. State the level (strict,relaxed,fast) and re-measure the ulp bound the row cites. - A verification rule.
alloy/evaluate/verify.py. A candidate is judged by its outputs on fuzzed inputs against the reference, so a new check must be able to fail a candidate that builds and runs. - A hint for agents.
alloy/isa/hints.pyreads a scope's tasklets when emission fails;alloy/guidance.pyadvises on the scopes left short. - A bench tool or packet.
alloy/hb_plugin: the tool intools/alloy.py, its judge half inroutes/alloy.py, the packet inplugin.toml, prompt changes inprompt/overlay.yaml, and the agent-facing text inskills/. The judge half runs Alloy in a process of its own, because the judge's threads never fork.
After any change to what a scope builds, run the whole suite: uv run pytest -m "not icx" -n 3 --maxfail=10, and
BENCH_BRANCH=<branch> bash helpers/bump_pins.sh when the bench pin or a sibling release moves.
Metadata
Release files for dace-alloy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dace_alloy-0.1.1.tar.gz | 2.4 MB | Without provenance | Details for dace_alloy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dace_alloy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for dace_alloy-0.1.1-py3-none-any.whl |
Total release size: 4.8 MB
Release files / dace_alloy-0.1.1.tar.gz
| Download URL | dace_alloy-0.1.1.tar.gz |
|---|---|
| Size | 2.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fde86d00e19741f94d36e2c53fa64e4f6ca1c1d65f609c9912c41c892362fa91
|
|
BLAKE2b-256 checksum How to use checksums |
5e2da979ca7eb350f6f97e4bf506b97307fa1ba8e05e472f24350a52aead863e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / dace_alloy-0.1.1-py3-none-any.whl
| Download URL | dace_alloy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.4 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54fe907d053e212a4ed13f32602f08b969e7b35957e5fa92d807a8de3e2836df
|
|
BLAKE2b-256 checksum How to use checksums |
1f01de1a7c29dd96f40ebfeecb77bdb4684c8c503003d41106d0039b37301db5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for dace-alloy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.