This is a good question. And I think this is one that the Church does not have a definitive answer on.
With the question of grace, we know that those in the friendship of God receive grace, and the surest way to be in a state of grace is to be baptized, receive the sacraments regularly, and live a life of discipleship.
Yet, the Lord is not bound by the means of the Church, for He regularly also helps those outside of the Church, as well as those who have lost their friendship with God through committing mortal sins.
The Church therefore explains this as the difference between habitual grace and actual grace. Habitual grace comes as a stable relationship with God through the means taught by Jesus: namely baptism, sacraments and discipleship. This is the sure path of sanctification, where we are actually transformed body and soul to be more united with God. The grace is therefore habitual for it stays in us.
For those outside of this relationship, God’s help is not habitual with their body and soul. God’s grace acts on them from without and gratuitously, even though they may have no desire for God, or have the desire but have not yet the desire to commit. It is therefore not habitual in them, but is given through a free act of God, hence “actual”.
I suppose this is the same with the gifts of the Holy Spirit For non-believers.