Cannot use tensor_contract and TextbookQPE together

Open
#1,861 6 comments 0 reactions 0 assignees View on GitHub

@rupasri118 is already working on this.

Since Sep 29, 2026.

  • #1 by @rupasri118 — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Read the attached reproducer, qualtran_bug_reproducer.py, and summary, QUALTRAN_BUG_REPORT.md, then trace how raising a Bloq to a power interacts with tensor_contract, TextbookQPE, and BloqAsCirqGate. Reproduce the reported assertion in Qualtran 0.7.0 and inspect the related implementation and tests. Done when the combination works without the cirq.Gate assertion and a regression test covers the reproducer.

Written by the indexing model from the issue text.

Description

As stated in title: Cannot use tensor_contract and TextbookQPE together. The issue is that when you try to raise a Bloq to a power Qualtran becomes inconsistent: it creates something that inherits from cirq.Gate then immediately passes that to BloqAsCirqGate, which asserts that the object is not a cirq.Gate.

I found this problem while using Qualtran 0.4.0 (I'm limited by another dependency that hasn't yet updated), but it appears to still be present in the most current release (0.7.0).

Claude Code diagnosed this problem for me, so I asked it to generate a minimal reproducer and a summary document, both of which I'm attaching. Both look right to me, but I want to explicitly call out the fact that they are LLM generated so that you can apply appropriate caution.

qualtran_bug_reproducer.py
QUALTRAN_BUG_REPORT.md

Dominant language
Python
Stars
397
Forks
127
Avg merge
2d 22h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from quantumlib/Qualtran

All issues in quantumlib/Qualtran

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.