Codercise G.5.1 - Preparing a multi-solution oracle

In Codercise G.5.1 it is written:

Let’s start by coding up this new oracle. Create an oracle for a random solution set of a given size using the MultiControlledX gate. Remember that this takes a string for control_values (e.g.,"11011") as a parameter rather than a list of bits.

However, when trying to implement the above gate as qp.MultiControlledX(all_wires,control_values=“11011”), it results in a ValueError: control_values must be boolean or int.

Indeed, in the official PennyLane documentation for the qml.MultiControlledX class, it is reported:

control_values (Union[bool, list[bool], int, list[int]]) – The value(s) the control wire(s) should take. Integers other than 0 or 1 will be treated as int(bool(x)).

This is confirmed also by the official solution provided for Codercise G.5.1, which is:

def oracle_multi(combos):
   """Implement multi-solution oracle using sequence of multi-controlled 
   X gates.
   Args:
       combos (list[list[int]]): A list of solutions.
   """
   for combo in combos:

       qp.MultiControlledX(wires=range(n_bits + 1), control_values=combo)

For this reason, I believe that the initial remark about control_values is misleading and should be corrected.

Hi again @delacroissant , thanks for pointing this out to us!

Indeed, I would agree that the language surrounding control_values is misleading and must be changed. Correspondingly, I have made an update to the language that should be live soon. Yesterday, we launched PennyLane v0.45 (Check out the blog: Assemble meaningful algorithms with PennyLane v0.45 and Catalyst v0.15 | PennyLane Blog), so we needed to wait for that to be available before making changes.

Thanks again!

— David