Typically, and USA specific, the rules are to grind it up, mix with equal parts existing dirt/compost and then it's OK. So that dilutes it by half; then this compost is spread around and, like you said, can be used for other crops. Also, as the material sits in the compost pile, which should be agitated, the pesticides will leach out/break down.
Many asterisks here but there are methods for remediating herbicide and pesticide contamination. Not saying it’s universally solved, but its not universally unsolvable either.
Edit: I meant to speak specifically in terms of compost production.
I just got a message from WA-LCB today with updated pesticide information, working with WSU, so here's some details -- https://agr.wa.gov/departments/cannabis/pesticide-use
And here's the Action Limits defined in WA law: https://app.leg.wa.gov/WAC/default.aspx?cite=314-55-108