Pass "bypass_equivalence_test => 1" to the cmp method for the answer. That will skip the check that the previous answer and current answer are equivalent. In your problem that would be
$ans = $ans->cmp(
checker => sub {
...
},
bypass_equivalence_test => 1
);
Note that this will only work for webwork2 and pg version 2.16 or newer.