Skip to content

[DRAFT] Allow manual and automatic memory/compute working together#3195

Draft
fedimser wants to merge 5 commits into
mainfrom
fedimser/memory-re
Draft

[DRAFT] Allow manual and automatic memory/compute working together#3195
fedimser wants to merge 5 commits into
mainfrom
fedimser/memory-re

Conversation

@fedimser
Copy link
Copy Markdown
Contributor

@fedimser fedimser commented May 5, 2026

This PR allows to enable memory-compute architecture with LRU/LFU cache, and use manual Load/Store instructions. So that runtime automatically writes qubits to memory when not needed, but the user can force such a write to memory at any point.

TODO: this PR misses removing qubits from cache on release.

@fedimser fedimser changed the title MemoryQubits via Std.ResourceEstimation.Load/Store [DRAFT] MemoryQubits via Std.ResourceEstimation.Load/Store May 5, 2026
@fedimser fedimser force-pushed the fedimser/memory-re branch from 01d759f to b93c05a Compare May 5, 2026 05:42
@fedimser fedimser force-pushed the fedimser/memory-re branch from b93c05a to f4317ae Compare May 5, 2026 05:44
@fedimser fedimser force-pushed the fedimser/memory-re branch from 557b8c8 to 12661e2 Compare May 7, 2026 18:20
@fedimser fedimser changed the title [DRAFT] MemoryQubits via Std.ResourceEstimation.Load/Store [DRAFT] MemoryQubits via Std.Memory.Load/Store May 8, 2026
@fedimser fedimser changed the title [DRAFT] MemoryQubits via Std.Memory.Load/Store [DRAFT] Allow manual and automatic memory/compute working together May 8, 2026
// Licensed under the MIT License.


/// Loads a qubit from "memory/cold" qubit to "compute/hot" qubit.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would remove all references to "hot" and "cold". Let's consistently use "compute" and "memory".


/// Loads a qubit from "memory/cold" qubit to "compute/hot" qubit.
/// Does nothing if qubit is already "hot".
function MemoryQubitLoad(q : Qubit) : Unit {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that this is already too detailed and does not match with what I had in mind at our last meeting. I suggest a single intrinsic operation AssertComputeQubits(qubits : Qubit[]) (or something like that), with the following meaning:

  • After the operation has been called, only qubits are in compute. Compute qubits that were present before the call and that are not in qubits are assumed to be moved back to memory. Qubits in qubits that were not compute qubits before need to be read from memory.
  • Any gate that tries to access a qubit that is not explicitly in compute must fail, unless this is used in combination with dynamic memory/compute allocation
  • There is no need to write back to memory, because this happens at the next call to AssertComputeQubits

This would require to understand how we want to use EnableMemoryComputeArchitecture. I suggest that if the compute capacity is a positive number, we assume dynamic memory compute (even though calls to AssertComputeQubits can be respected and may fail on insufficient capacity) and if we call it with 0 or a negative number (or any other kind of signature if that's better), there is no dynamic movement, but all compute qubits need to be pre-asserted with AssertComputeQubits.

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