# Problem with comments and code rearranging in IBM Q web interface

I wrote some code in QASM in the IBM Q Experience web interface and then I added some comments. After that I saved the code and run it. However, the code was rearranged (for example some gates were moved on other places - probably because of optimization). Moreover, all comments were removed. The same occurs when I save the code and return to it later Fortunately more recent codes are intact, i.e. there are comments I put there previously, but I was afraid to run them because of a risk of losing comments.

I am used to this behavior when I write a code and then do some edits in composer. In that case comments are also removed and the code is rearranged. But the above described issue seems to be a bug.

Does anyone face similar problems? Can anybody from IBM check this and fix?

EDIT:

As there was a misunderstanding when the comments disappear, here is a screenshot which place of web interface I meant. The code is of course rearranged during transpiling process. However, the problem is that IBM Q erase comments and rearrange code in Circuit editor.

EDIT 2:

This code I wrote to Circuit editor:

OPENQASM 2.0;
include "qelib1.inc";

qreg q[5];
creg c[5];

x q[1]; //ancila

h q[0]; //init
h q[1];
h q[2];
//Oracle f = 11.x
cx q[0],q[1];
cx q[2],q[1];
//measurement in Hadamard basis
h q[0];
h q[2];
measure q[0] -> c[1];
measure q[2] -> c[0];


Then I clicked on Save, closed the the circuit, opened again from Dashboard and the code changed to this:

OPENQASM 2.0;
include "qelib1.inc";

qreg q[5];
creg c[5];

h q[0];
x q[1];
h q[2];
h q[1];
cx q[0],q[1];
h q[0];
cx q[2],q[1];
h q[2];
measure q[0] -> c[1];
measure q[2] -> c[0];


So, the code is changed to transpiled code. I would like to avoid this behavior.

## 1 Answer

You'e just experienced code transpilation. Transpilation is when source-to-source compilation takes place, as you have mentioned here. You can prevent the rearranging of the gates by using the "barriers", the Barrier operation is used to make your quantum program more efficient, the compiler will try to combine gates. The barrier is an instruction to the compiler to prevent these combinations being made.

When the code is transpiled the comments are omitted, but they are unchanged in the original code

• I know what the transpilation is. The problem is that the comments are removed in original code, i.e. in the window where I write the code. The same is valid for rearrangement of gates. Jun 19 '20 at 7:27
• The code shouldn't change in the window you've highlighted. You should only see the transpiled circuit in the results page for that job. You still have the original code in the results page as well, which includes the comment, and your original code should still show up on the actual composer page. Jun 22 '20 at 13:53
• @MatthewStypulkoski: Yes, the problem is that this is not happen. I added the problematic code to my question. Jun 23 '20 at 7:40
• Ok, I tested with your code and have the same problem. Interestingly, I tried to create a circuit with comments before, and when I would save it and/or reopen it, the comments would always stay. But when I tried with your code, they did not. Jun 23 '20 at 13:28
• @MartinVesely pretty sure this is a bug. I believe it is being worked on. Jun 24 '20 at 13:38