diff --git a/models/model_moire_c4.py b/models/model_moire_c4.py index 19da233..189971f 100644 --- a/models/model_moire_c4.py +++ b/models/model_moire_c4.py @@ -583,6 +583,18 @@ def build_moire_c4( twobody.report(warn_frac) logger.info("") + # AutoMPO repeatedly compresses the running operator sum. At production + # sizes, the interaction-map order contains long sequences that decay to + # ~1e-10 and then jump back to ~1e-2 at the next index family. Adding in + # that order can make the repeated norm redistribution ill-conditioned + # and eventually feed non-finite values to an SVD. Magnitude ordering is + # algebraically neutral, deterministic (Python's sort is stable), and + # keeps each partial sum well scaled. Zero terms naturally move last and + # remain filtered by build_hamiltonian. + interactions.sort(key=lambda interaction: abs(interaction.cpl), reverse=True) + logger.info(" Ordered interactions by descending |coupling| for stable AutoMPO accumulation") + logger.info("") + # Attach coefficient tables on the ops dict for tests / inspection. ops['_moire_B'] = B ops['_moire_V'] = Vtable diff --git a/registry.yaml b/registry.yaml index 5896e6f..8098a11 100644 --- a/registry.yaml +++ b/registry.yaml @@ -11,7 +11,7 @@ categories: - name: model_moire_c4 file: models/model_moire_c4.py description: LLL-projected C4 moire model builder for Alice - sha256: a4c3b224270fdf73b9f57ee7221756f6a3de990a3467c7126c4d87c858902554 + sha256: 809fa874fe7b1972ab3f38c89e9b1a591227acf667820c029c8effc41df03baa intrcmaps: description: Interaction maps for Alice