A major artifact of realistic photonic filters is the waveguide power loss. Its detrimental effect on the allpass structure is particularly alarming because the phase response is highly sensitive to perturbations. While the loss can be simply captured into a variation on the unit delay in signal processing analysis, its non-linearity makes it mathematically difficult to address. We present an allpass filter design algorithm that is able to provide filter coefficients that compensate for the waveguide power loss. By absorbing the loss parameter into the design cost function, the optimization problem becomes non-convex and NP hard. Our approach solves this problem by utilizing an iterative algorithm in conjunction with the branch and bound global optimization technique. The proposed algorithm is expected to improve the performance and increase the utilization of allpass filters for optical signal phase based applications such as distortion compensation and group delay equalization.