Note on endianness

Endianness is not abstracted by the Quantum Learning Machine and may become a recurrent problem if no convention is fixed on the entire project.

This page contain the convention used by the qaths library.

Quantum Learning Machine internal endianness

This section precise the endianness used internally by the Quantum Learning Machine.

Known bugs

  1. The linear algebra simulator is known to return a swapped result when an oracle has been used in the simulated circuit. The bug has been verified with the StatePreparation gate and may also affect all the other oracles in qat.lang.AQASM.oracle. A fix will be soon available.

Arithmetic functions

All the arithmetic functions that interpret quantum registers as integers are designed to work in little-endian.

qaths endianness conventions

Tests

qaths’ tests should use the big-endian convention everywhere.

Why not little-endian?

Most of the time, byte-order is just a convention and there is not a specific reason to prefer one byte-order to the other.

Within tests, the big-endian order is the most convenient because:

  1. Humans (at least the ones using Arabic numerals) are used to read numbers in big-endian.

  2. The tensor operations to construct matrices or quantum states will follow the big-endian convention and so will be easier to read (see 1.).

Library

qaths should use the big-endian convention everywhere except:

  1. When one of the used external library use little-endian. In this particular case, the method calling the external library should expose a big-endian API (i.e. input is given in big-endian, output is returned as big-endian) but may use a little-endian representation internally.

    Warning

    The fact that the method is calling a little-endian function should be entirely hidden to the user. The method should handle transparently the endianness of the internal functions.