My idea for a solution would be to offer better pay/benefits opportunities for your good developers, at the same time giving them also more creative freedom when they rise the ranks in a technical role.
Making management the only option for having a "career" is the issue.
Another option to avoid the downsides of the Peter Principle is to test drive people in their new roles. Basically you slowly add responsibilities that look more like the post-promotion job, if they do well they get the promotion and they've already proven to be able to do these things. If at some point you notice it isn't working, well then you don't promote them, or promote them to a different position.