Why this could happen? I think g_cost should always have a dtype field.