Magnesium-aluminum alloy is one of the most common alloy materials in the industry, widely utilized due to its low density and excellent mechanical properties. Investigating the properties or predicting new structures through experimentation inevitably involves complex processes, which consume significant time and resources. To facilitate the discovery, simulations such as Density Functional Theory (DFT) and machine learning (ML) methods are primarily employed. However, DFT incurs significant computational costs. While ML methods are versatile and efficient, they demand high-quality datasets and may exhibit some degree of inaccuracy. To address these challenges, we employ a combination of generative model and automatic differentiation (AD), reducing the search space and accelerating the discovery of target materials. We have predicted a variety of magnesium-aluminum alloys. We conducted structure optimization and property evaluation for ten potentially valuable intermetallic compounds. Ultimately, we identified five stable structures: Mg3Al3, Mg2Al6, Mg4Al12, Mg15Al and Mg14Al2. Among these, Mg4Al12, Mg15Al and Mg14Al2 may hold higher potential for practical applications.