Skip to content

fix(hash): fall back to fxhash when AES is not enabled - #238

Open
david-pl wants to merge 2 commits into
mainfrom
david/gxhash-fallback
Open

david-pl wants to merge 2 commits into
mainfrom
david/gxhash-fallback

Conversation

@david-pl

@david-pl david-pl commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

gxhash only compiles when AES is enabled at compile time. The repo's .cargo/config.toml enables it for builds inside this repo, but that config doesn't apply to crates that depend on ppvm. So any crate depending on ppvm-pauli-sum, ppvm-tableau-sum and so on failed to build on x86_64 and aarch64 Linux unless its users set RUSTFLAGS themselves. That blocks publishing to crates.io (#237). ppvm-tableau-sum uses gxhash unconditionally, so turning the feature off wasn't a workaround.

This extends the existing wasm32 fallback. The gxhash dependency and every use of it are now gated on all(target_feature = "aes", any(target_arch = "x86_64", target_arch = "aarch64")) instead of "not wasm32":

  • Without AES, the gxhash configs are left out and the fingerprint in ppvm-tableau-sum uses fxhash, as on wasm.
  • With AES (repo builds, Apple Silicon, or RUSTFLAGS="-C target-feature=+aes"), nothing changes.
  • Side fix: the dashmap ByteGxHash configs were never gated, so --no-default-features --features dashmap failed to compile. It now builds.
  • Docs: the landing page, Developer Guide and usage skill no longer tell non-x86 users to drop gxhash by hand.

No simulator or gate code changes. The edits are 13 cfg attributes on the hashing configs, the hashing hook and the fingerprint function, plus the four Cargo.toml dependency tables.

Test plan

  • A scratch crate outside the repo that depends on ppvm-pauli-sum + ppvm-tableau-sum builds on x86_64, aarch64 Linux and Apple Silicon (previously failed on the first two), and uses gxhash with +aes.
  • cargo test --workspace (gxhash path): 1141 passed.
  • Fallback path, with AES forced off (-C target-feature=-aes): 678 passed across traits, pauli-word, pauli-sum, tableau-sum, tableau and stim, doctests included.
  • cargo clippy --workspace --all-targets -D warnings, the x86_64 all-targets build, the wasm32 CI build, --no-default-features --features dashmap.
  • Python tests: 221 passed. The docs build and the pre-commit hooks pass.

The benches still use the gxhash configs unguarded. They're only built by cargo bench / --all-targets, which CI runs on x86_64 with AES enabled.

Follow-up for #237: with this merged, the linux-aarch64 wheel no longer needs the +aes,+neon flag that #237 adds. Removing it makes that wheel portable to CPUs without AES (e.g. Raspberry Pi 4), at some speed cost on AES-capable ARM servers.

🤖 Generated with Claude Code

gxhash only compiles with hardware AES enabled at compile time, so any
crate depending on ppvm failed to build on x86_64 and aarch64 Linux
unless its users set RUSTFLAGS themselves (the repo's .cargo/config.toml
only applies to builds inside this repo).

Gate the gxhash dependency and every use of it on
`all(target_feature = "aes", any(target_arch = "x86_64", target_arch =
"aarch64"))` instead of `not(wasm32)`. Without AES the gxhash configs are
dropped and ppvm-tableau-sum's fingerprint uses fxhash, as on wasm. This
also fixes the dashmap gxhash configs failing to compile with the
`gxhash` feature off. Update the build docs and the usage skill.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The example’s guard still permits references to unavailable gxhash configs when AES is enabled but the gxhash feature is disabled.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Makes downstream Rust builds work without AES flags, supporting the publishing work in #237.

Changes:

  • Gates gxhash dependencies and configs on supported AES-enabled targets.
  • Extends the tableau fingerprint’s fxhash fallback and guards optional gxhash usage.
  • Updates installation and contributor guidance.
File Description
skills/​ppvm-usage/​SKILL.md Explains automatic fallback.
docs/​src/​pages/​index.astro Updates installation flags.
docs/​src/​pages/​develop.astro Documents AES gating and fallback.
crates/​ppvm-traits/​src/​traits/​hash.rs Gates gxhash implementation and test.
crates/​ppvm-traits/​Cargo.toml Gates gxhash dependency.
crates/​ppvm-tableau-sum/​src/​storage/​mod.rs Extends fingerprint fallback.
crates/​ppvm-tableau-sum/​Cargo.toml Gates gxhash dependency.
crates/​ppvm-pauli-word/​Cargo.toml Gates gxhash dependency.
crates/​ppvm-pauli-sum/​src/​config/​mod.rs Gates gxhash config module.
crates/​ppvm-pauli-sum/​src/​config/​indexmap.rs Gates gxhash configs.
crates/​ppvm-pauli-sum/​src/​config/​dashmap.rs Adds gxhash config guards.
crates/​ppvm-pauli-sum/​examples/​trotter_qubit_sweep.rs Guards gxhash benchmark branch.
crates/​ppvm-pauli-sum/​Cargo.toml Gates gxhash dependency.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/ppvm-pauli-sum/examples/trotter_qubit_sweep.rs
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://QuEraComputing.github.io/ppvm/pr-preview/pr-238/

Built to branch gh-pages at 2026-10-06 14:43 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

The gxhash configs need both the `gxhash` feature and AES, but the
example only checked for AES, so `--no-default-features` builds on AES
targets failed to compile it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

CPU-feature-dependent Cargo dependency selection needs human confirmation across supported downstream toolchains.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@david-pl
david-pl requested a review from Roger-luo October 7, 2026 06:28

This branch has not been deployed

No deployments
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.

2 participants