# Certificate Challenge: Introduction to PennyLane

**URL:** <https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494>\
**Category:** PennyLane Challenges\
**Created:** [April 24, 2024, 3:06pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494 "2024-04-24T15:06:33Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![essa](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/essa/32/2666_2.png) [@essa](https://discuss.pennylane.ai/u/essa)\
**Post date:** [June 24, 2024, 8:44pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/23 "2024-06-24T20:44:50Z")

</div>

I’m getting wrong probabilities and the subsequent error:

```auto
Failure message: Assertion Error: Something isn't quite right with the trainable block..

```

I can’t quite understand where am I going wrong with the trainable block. My circuit seems to be correct too:

 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/1/1772b6d2c64830e29c7f12d20c9df9764d6d3b14.png)

Edit: Fixed it! The last CNOT in the trainer block was switched with source and target.

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [June 25, 2024, 12:51am UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/24 "2024-06-25T00:51:55Z")

</div>

Hi @essa, welcome to the Forum!

Congratulations on solving the challenge! Remember to accept your certificate in your account settings and share it on LinkedIn.

Note: I’ve blurred your circuit and solution so that others don’t get a spoiler.

---

<div class="post-metadata">

**Author:** ![baudoin](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/baudoin/32/2800_2.png) [@baudoin](https://discuss.pennylane.ai/u/baudoin)\
**Post date:** [August 30, 2024, 4:19pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/26 "2024-08-30T16:19:02Z")

</div>

@essa nevermind I was able to do it.

---

<div class="post-metadata">

**Author:** ![baudoin](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/baudoin/32/2800_2.png) [@baudoin](https://discuss.pennylane.ai/u/baudoin)\
**Post date:** [August 30, 2024, 4:20pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/27 "2024-08-30T16:20:45Z")

</div>

Hi @CatalinaAlbornoz , what could be the reason of this. I don’t understand.  
 ![Screenshot from 2024-08-30 18-16-35](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/9/9b090249c2bc49b89950134005a4249a2ff88340.png)

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [September 4, 2024, 4:50am UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/28 "2024-09-04T04:50:38Z")

</div>

Hi @baudoin,

This happens when your solution doesn’t work for all valid inputs. Private tests are secret and they’re used to ensure that your solution actually works as expected for any valid input. So for example if you tweak you solution to work only for the inputs in the public tests, your code might fail for other inputs such as the private ones.

You’re probably close to the answer if you already got your code to work for the public tests. You can make up your own test scenarios of input vs expected output to keep improving and testing your solution! This can help you find where you can improve your code.

I hope this helps and good luck with the challenge!

---

<div class="post-metadata">

**Author:** ![pabloramosdev](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/pabloramosdev/32/2879_2.png) [@pabloramosdev](https://discuss.pennylane.ai/u/pabloramosdev)\
**Post date:** [December 12, 2024, 3:45am UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/29 "2024-12-12T03:45:00Z")

</div>

I’m trying to solve this challenge but I get this error:

> Blockquote  
> Running submission…

```
	Running on public test set

		Test 1 of 2 failed! 🚫
			Input: [[[[0.62832, 0.3927, 1.0472, 0.7854],[0.7854, 0.31416, 0.62832, 0.5236]],[[0.31416, 0.7854, 0.7854, 0.3927],[0.31416, 0.3927, 0.31416, 0.3927]]],"PauliY", 0.5236]
			Expected output: [0.68594, 0.31406]
			Solution output: null
			Failure message: Runtime Error: Failed to execute run() function: _expand_transform_param_shift() got an unexpected keyword argument 'level'.

		Test 2 of 2 failed! 🚫
			Input: [[[[1.0472, 0.7854, 3.1416, 0.3927],[1.0472, 0.7854, 3.1416, 0.5236]],[[1.0472, 0.7854, 1.5708, 0.3927],[0.7854, 0.7854, 1.5708, 0.7854]]],"PauliX", 0.7854]
			Expected output: [0.46653, 0.53347]
			Solution output: null
			Failure message: Runtime Error: Failed to execute run() function: _expand_transform_param_shift() got an unexpected keyword argument 'level'.

	Running on private test set

			One or more private tests failed. Try again! 🚫

```

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [December 13, 2024, 8:56pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/30 "2024-12-13T20:56:04Z")

</div>

Hi @pabloramosdev,

Welcome to the forum!

It looks like your solution isn’t correct.  
In your particular case it looks like you’re using the word ‘level’ somewhere in your solution and this is causing the error.

Keep trying and you’ll succeed with the challenge!

If you’re stuck make sure to check the Codebook, the documentation, and the examples available at [pennylane.ai](https://pennylane.ai/).

---

<div class="post-metadata">

**Author:** ![pabloramosdev](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/pabloramosdev/32/2879_2.png) [@pabloramosdev](https://discuss.pennylane.ai/u/pabloramosdev)\
**Post date:** [December 14, 2024, 8:23pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/31 "2024-12-14T20:23:59Z")

</div>

Hi @CatalinaAlbornoz,

Thank you for your reply. I fixed the solution and finally I succeeded the challenge! 😄

---

<div class="post-metadata">

**Author:** ![gab](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/gab/32/3444_2.png) [@gab](https://discuss.pennylane.ai/u/gab)\
**Post date:** [December 18, 2024, 4:39pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/32 "2024-12-18T16:39:22Z")

</div>

can you give me a hint why my circuit gives the wrong probabilites. the W and S layers pass the test.

 ![Screenshot 2024-12-18 at 15.06.07](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/f/f38dc16a5d480ef277fee5388c2903a96f14449b.png)

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [December 19, 2024, 9:32pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/33 "2024-12-19T21:32:37Z")

</div>

Hi @gab , welcome to the Forum!

Your W layer doesn’t look right. If you look closely at the instructions you’ll note that all of the RY gates are applied before all of the CNOT gates for each layer. In your case it looks like all of the RY and CNOT layers are alternating which is not the same.

From the image you shared it’s hard to know whether your implementation for S is correct or not.

Give the challenge a new try and you’ll surely succeed!

 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/6/68723e2a25a1967297f817ee9c1ccf75e4483fc3.png)

---

<div class="post-metadata">

**Author:** ![gab](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/gab/32/3444_2.png) [@gab](https://discuss.pennylane.ai/u/gab)\
**Post date:** [December 20, 2024, 8:04am UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/34 "2024-12-20T08:04:46Z")

</div>

How could I miss that? 🤦‍♂️ Thank you for pointing out.

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [December 21, 2024, 1:08am UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/35 "2024-12-21T01:08:19Z")

</div>

No problem!  
Missing these details is more common than you may think.

Good luck with the challenge!

---

<div class="post-metadata">

**Author:** ![jose.suarez](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/jose.suarez/32/3260_2.png) [@jose.suarez](https://discuss.pennylane.ai/u/jose.suarez)\
**Post date:** [January 15, 2025, 2:35pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/36 "2025-01-15T14:35:51Z")

</div>

Hi there! I’ve almost completed the challenge, but am having issues with defining my device. My code passes the public tests when I set my device to 4 qubits. I am not sure how this can be made dynamic to pass all of the private tests.

So far, I have been defining the number of qubits within my functions based on the length of params[0] (for the W block) or param\_set[0][0] (for the quantum\_model circuit). However, these cannot be used to specify the number of qubits outside of the functions, as these matrices are not accessible prior to when the device needs to be defined. What could I try to make a device with the correct number of qubits?

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [January 16, 2025, 5:09pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/37 "2025-01-16T17:09:29Z")

</div>

Hi @jose.suarez, welcome to the Forum!

I don’t think your issues are due to the number of qubits in your device. The issue may be in how you’re using wires in your functions. Note that for both the `W` and `quantum_model` functions you’ll need a _range_ of wires instead of a single number. E.g. `range(2)=[0,1]` \neq`2`.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![jose.suarez](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/jose.suarez/32/3260_2.png) [@jose.suarez](https://discuss.pennylane.ai/u/jose.suarez)\
**Post date:** [January 17, 2025, 4:24pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/38 "2025-01-17T16:24:15Z")

</div>

Hi Catalina, thanks for your response.

I took another look at the W function, and I did have code left that I was using to originally debug the function.

Thanks again for the advice. All the best!

---

<div class="post-metadata">

**Author:** ![eigenname](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/eigenname/32/3930_2.png) [@eigenname](https://discuss.pennylane.ai/u/eigenname)\
**Post date:** [July 24, 2025, 2:57pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/39 "2025-07-24T14:57:13Z")

</div>

I’ve gotten close to a solution, I’ve implemented the W subcircuit and the circuit quantum\_model and according to the log,

```auto
Running on public test set

	Test 1 of 2 failed! 🚫
		Input: [[[[0.62832, 0.3927, 1.0472, 0.7854],[0.7854, 0.31416, 0.62832, 0.5236]],[[0.31416, 0.7854, 0.7854, 0.3927],[0.31416, 0.3927, 0.31416, 0.3927]]],"PauliY", 0.5236]
		Expected output: [0.68594, 0.31406]
		Solution output: [0.3684651333359519, 0.6315348666640477]
		Failure message: Assertion Error: Something isn't quite right with the encoding block..

	Test 2 of 2 failed! 🚫
		Input: [[[[1.0472, 0.7854, 3.1416, 0.3927],[1.0472, 0.7854, 3.1416, 0.5236]],[[1.0472, 0.7854, 1.5708, 0.3927],[0.7854, 0.7854, 1.5708, 0.7854]]],"PauliX", 0.7854]
		Expected output: [0.46653, 0.53347]
		Solution output: [0.6586170165096314, 0.34138298349036755]
		Failure message: Assertion Error: Something isn't quite right with the encoding block..

```

Meanwhile, my S function is implemented as

```auto
for _ in range(num_wires):
   qml.exp(op=g(_), coeff=-0.5j*x)

```

I’m not sure where to go from here, there’s not a built-in function for applying matrix exponentials for all wires is there? Is looping and applying a matrix exponential for each wire a valid approach, and if so, what’s wrong with my implementation?

---

<div class="post-metadata">

**Author:** ![daniela.murcillo](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/daniela.murcillo/32/3612_2.png) [@daniela.murcillo](https://discuss.pennylane.ai/u/daniela.murcillo)\
**Post date:** [July 24, 2025, 9:29pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/40 "2025-07-24T21:29:27Z")

</div>

Hi!  
That’s the correct approach, yes. Looping and applying the exp. Why is there a -0.5 factor in the coefficient?

---

<div class="post-metadata">

**Author:** ![eigenname](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/eigenname/32/3930_2.png) [@eigenname](https://discuss.pennylane.ai/u/eigenname)\
**Post date:** [July 25, 2025, 12:53pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/41 "2025-07-25T12:53:16Z")

</div>

Oh, really? Oh I think I got hung up on how Rotation operators are exponentials of Pauli operators and thought that -0.5 also applies to here lol

---

<div class="post-metadata">

**Author:** ![eigenname](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/eigenname/32/3930_2.png) [@eigenname](https://discuss.pennylane.ai/u/eigenname)\
**Post date:** [July 25, 2025, 1:00pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/42 "2025-07-25T13:00:17Z")

</div>

I had just omitted the -0.5 factor and just have coeff=1j\*x, my code passed both of the public tests but failed the private tests..

---

<div class="post-metadata">

**Author:** ![daniela.murcillo](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/daniela.murcillo/32/3612_2.png) [@daniela.murcillo](https://discuss.pennylane.ai/u/daniela.murcillo)\
**Post date:** [July 25, 2025, 7:19pm UTC](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494/43 "2025-07-25T19:19:58Z")

</div>

There might be something else failing. I ran the code with your S function and it passed all the tests.  
Could you provide then all the answers you have given to the challenge? so I can verify.

[Previous page](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494.md?page=1)

[Next page](https://discuss.pennylane.ai/t/certificate-challenge-introduction-to-pennylane/4494.md?page=3)
