-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[runtime] QubitPlacer part 1 #4700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[runtime] QubitPlacer part 1 #4700
Conversation
f3b7a82
to
f95de7f
Compare
factored out named topology stuff in #4701 |
ptal @MichaelBroughton @tanujkhattar or anyone interested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, just a few high level questions before we merge.
def place_circuit( | ||
self, | ||
circuit: cirq.AbstractCircuit, | ||
problem_topo: NamedTopology, | ||
shared_rt_info: 'cg.SharedRuntimeInfo', | ||
rs: np.random.RandomState, | ||
) -> Tuple[cirq.FrozenCircuit, Dict[Any, cirq.Qid]]: | ||
return circuit.freeze(), {q: q for q in circuit.all_qubits()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why aren't there any strict checks that the resulting circuit is valid under the given topology ? Do we want to allow users to have a Placer totally ignore the Topology ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes; this placer totally ignores the topology. Validation can be done by the device as part of the execution loop
logger = _PrintLogger(n_total=len(executable_group)) | ||
logger.initialize() | ||
|
||
rs = np.random.RandomState(rt_config.random_seed) | ||
exe: QuantumExecutable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this declaration mess with the below loop ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is how you do type annotations for loop variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this annotation? Wouldn't the type of exe
get inferred automatically based on the type of executable_group
which we iterating on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pycharm wasn't picking it up
logger = _PrintLogger(n_total=len(executable_group)) | ||
logger.initialize() | ||
|
||
rs = np.random.RandomState(rt_config.random_seed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Should we give the seed to the rt_config
or the randomstate generator itself ? It seems like down the line if we kept creating randomState
s off of this seed we'd get a lot of duplicate random numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two part answer
rt_config
needs to be serializable and put in a database so we can groupby and agg the results. Seed is (much!) easier than the internal state of a random state- We don't create >1 randomstate based on this seed. We create one at the top of the function (here!) and it gets passed to any subroutines that require randomness.
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class NaiveQubitPlacer(QubitPlacer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the class to a more descriptive name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have a suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe NoOpQubitPlacer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not really a "no op", it's more like an identity
@MichaelBroughton ptal |
from cirq import _compat | ||
from cirq.devices import GridQubit, LineQubit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Duplicate imports? See lines 23-24 below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #4701 but I don't think there's any post merge duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the duplicate import is gone.
Splitting up quantumlib#4678 - The interface: `QubitPlacer` - The fallback: `NaiveQubitPlacer` - runtime hooks some hacks around quantumlib#4699
Splitting up #4678
QubitPlacer
NaiveQubitPlacer
some hacks around #4699