Thailand is set to sell half-a-million tons of rice on world markets at a loss, as it scrambles to offload a record stockpile deteriorating in quality in warehouses filled with grain.