Example Hamiltonian: the linearised graphene Hamiltonian
In condensed matter, we typically write down Hamiltonians instead of Lagrangians. An example is given by the Hamiltonian for graphene. When we linearise the theory about the Dirac points of the model, we obtain a pair of Dirac Hamiltonians, see Eq. (18) of this review for example. Let's focus on one of these Hamiltonians, it is given by
$$ H = \int dx \psi^\dagger (-i\alpha^i \partial_i + \beta m) \psi \equiv \int dx \mathcal{H}, $$
where I have set the $v_F = 1$ and $\alpha^i$, $\beta$ are the usual Dirac alpha and beta matrices used for expressing the Dirac equation in the form of a Schrodinger equation.
What is the Lagrangian of this Hamiltonian?
Now I ask, what is the Lagrangian of this model? Well, I could write the obivous Lagrangian as
$$ \mathcal{L} = i \psi^\dagger \partial_t \psi - \mathcal{H} = \bar{\psi}( i \gamma^\mu \partial_\mu-m) \psi$$
where I have combined the space and time derivatives into a single object $\partial_\mu = (\partial_t , \partial_i)$ and defined the objects $\gamma^0 = \beta$, $\gamma^i = \beta \alpha^i$ and $\bar{\psi} = \psi^\dagger \gamma^0$ which brings the action into its standard covariant form. This is nothing but the Dirac Lagrangian and it returns the Hamiltonian after a Legendre transformation as expected.
However, what if I decided to insert some arbitrary matrix $M$ into the time derivative part of my Lagrangian such as
$$ \mathcal{L}'= i \psi^\dagger M \partial_t \psi -\mathcal{H}$$
where I could let $M$ be horribly space-dependent if I wish. This Lagrangian $\mathcal{L}'$ would yield a different equation of motion to the Dirac equation, however it would still yield the same Hamiltonian. Using the definition of the Legendre transformation, we have
$$ \mathcal{H}' = \frac{\partial \mathcal{L'}}{\partial (\partial_t \psi)} \partial_t \psi - \mathcal{L}'= i\psi^\dagger M \partial_t \psi-\mathcal{L}'=\mathcal{H}$$
My question
It appears that the Hamiltonian can be derived from both of the Lagrangians $\mathcal{L}$ and $\mathcal{L}'$, however the equations of motion of these two Lagrangians differ. The equations of motion are
$$ \mathcal{L} \quad \Rightarrow \quad i \gamma^\mu \partial_\mu \psi = 0 $$ $$ \mathcal{L}' \quad \Rightarrow \quad i \gamma^0 M \partial_t \psi + i \gamma^i \partial_i \psi = 0$$
This is puzzling, because when I quantise the theory, I have to construct the mode expansion from the equations of motion. This will diagonalise the Hamiltonian. But it appears that this process would yield diferent results depending on whether I let $M \neq \mathbb{I}$ or not. For this reason my question is the following: if the Lagrangian corresponding to a Hamiltonian is not unique, which Lagrangian do I choose?