A CDI is a solid state device. Not the culprit. I have never seen one intermittently function. It's either good or bad. There is NO in between.
You have a connection issue. Not sure which connection.... But it is certainly electronic...
Change the plug again.
Reseat the plug wire ends.
Check grounds
Check kill switch
Does it have a battery? Could be dead.
Stator may be on the way out and not able to maintain output great enough to run the ignition.
I had this issue on my streetbike. Exact same issues. We called it the 'ghost.'
It would be running fine and then make horrible burbls, then eventully die completely.
Then when I would be messing with it, it would backfire but never start.
Turned out the alternator was not maintaining the battery high enough to run ignition. It was the weirdest thing.
NEVER ASSUME IT'S A CDI!