When casting a spell or playing an ability all costs associated with playing it are paid at that time. When you announce a spell or ability, you announce it, make all necessary choices associated with the playing the spell and then pay all costs.
This means that when you play Harvest Pyre, you must exile cards from your graveyard during the casting process. You cannot announce Harvest Pyre, wait to see if your opponent responds and then either change the number of cards you choose to exile or choose which specific cards to exile. Once you have started to announce Harvest Pyre, before any player can perform any actions, you must choose a value of X and exile the appropriate number of cards from your graveyard.