Skip to main content

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/: scopes outlines a program, inputs draws its inputs from a bench manifest, tree prints the control-flow tree the report carries, cnumpy lifts 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 in alloy/hb_plugin/skills/alloy-c/SKILL.md).
  • alloy/backend/: candidates enumerates the sweep, build renders, compiles and checks one candidate, intrinsics rewrites admitted innermost loops into checked intrinsic DaCe tasklets, runtime resolves and checks the OpenMP runtime, sweep builds every candidate.
  • alloy/evaluate/: link builds whole programs from scope archives, verify checks candidates on fuzzed inputs, timing times them and links alloy-full.
  • alloy/isa/: the machine abstract math ISA (ops.py, 37 ops across 414 CPU rows + 22 assists in intrinsics.toml, 390 llvm-mca cost rows in costs.toml, 19 precision-bounded math functions in mathkernels.toml, 26 CUDA + 26 HIP device rows in simt.toml, 23 Tensix rows + 2 card-checked SFPI rungs in tensix.toml, 14 SoftHier ops in softhier.toml, and tile kernels in alloy_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.py runs a row's intrinsic or recipe in a compiled kernel, natively or under qemu-aarch64 when that is on PATH, or re-measures its tier, before an agent sees it; a row that did not run stays unverified, however it compiled; hints.py builds the do-it-yourself response from a scope's tasklets when emission fails; schedules.py emits 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 checked tensix.toml rows and automatically substituting card-checked SFPI rungs where tt-metal 0.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.generate lowers an SDFG to one C++ unit, and gate/ checks the programs on GVSoC on ault. docs/softhiergen.md describes the code as built; update it with every change of behavior.
  • alloy/: api (generate, the entry point), dace_backend (Alloy behind SDFG.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 (builds report.json schema 8, renders report.md from it, loads it back), records (the strict pydantic configuration of the timing, verdict, report and manifest records). Every CPU compiler, flag and option is in alloy/configuration_matrix.toml, validated by the pydantic models of alloy/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 in alloy/configuration_matrix.py only for a new kind of setting. one_factor_at_a_time sweeps what the file lists, and every candidate is verified, so no Python changes for a new row.
  • A sweep axis. Add the factor to Candidate and its flips to backend/candidates.py, then tell heuristics/prune when 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>] to alloy/isa/intrinsics.toml, with the spelling checked against the compiler's headers; a composite needs a recipe and the code that states its operand order. A new op also goes in OPS in alloy/isa/ops.py, which holds the math, never a spelling. Run python -m alloy.isa validate: a row is compiled and executed natively, or under qemu-aarch64 when that and aarch64-linux-gnu-gcc are on PATH. A row that only cross-compiled stays unverified. Do not mark a row verified by hand.
  • A math kernel. alloy/isa/mathkernels.py and helpers/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.py reads a scope's tasklets when emission fails; alloy/guidance.py advises on the scopes left short.
  • A bench tool or packet. alloy/hb_plugin: the tool in tools/alloy.py, its judge half in routes/alloy.py, the packet in plugin.toml, prompt changes in prompt/overlay.yaml, and the agent-facing text in skills/. 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)

Source distribution for dace-alloy 0.1.1
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)

Table of built distributions (wheels) for dace-alloy 0.1.1
File Interpreter ABI Platform Actions
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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page