undo changed to 3-stage chain. (focus on two-stage for now).
implementation of adaptive inference.