Agree that 2-3 months' notice is plenty. I personally would probably let my supervisor know as soon as I knew, but I also have a good relationship with him and would not except retribution.
I also agree that letting the trainer director know in advance, possibly before rank order lists are submitted (so they can pass the info along to applicants), would be nice. Not absolutely necessary, but nice. It would also allow them to plan ahead for your impending absence.