Shadowlord/Grumman's idea is much better than KoE's. Sorry, KoE.
I disagree. Both ideas require a relatively unlikely thing (imp is right next to grate when the flow pushes through) to happen repeatedly. But in the Shadowlord/Grumman construction, those events are not at all independent: first, the imp is next to the first fortification and gets pushed in. If it moves right away, it's guaranteed to move back to the magma pipe, which is good. But if not, the flow will push the imp into the middle fortification. Now the imp can't move, so the imp is pushed through and on to the other side, and this holds no matter how many fortifications you have in a row. The KoE construction allows the imp to move away from the successive grates, so it's more reasonable to assume independence and thus exponential decrease in probability. Doubling up grates in the KoE style would probably be optimal for sideways channels.
As I mentioned earlier, and someone else did also, you can also just drop the flow through a floor grate and have a guaranteed filter.
One thing to note: I've never seen an imp walk even 20 tiles down an unguarded magma channel. My forts tend to be quite far from the pipe, 100-200 tiles away, which makes it basically impossible that an imp would get the idea to walk all the way to the forges (it also takes most of a year to get the magma to the destination, but more recently I realized that if you make the channel 2 zlevels deep until just before the forges, there's a huge speedup until first light -- takes just as long to fill the channel, but the front moves much faster).