Commit 0aa39ed
Fix logical operator construction for non-CSS subsystem codes (#578)
* Fix get_logical_ops for non-CSS subsystem codes via symplectic Gram-Schmidt
QuditCode.get_logical_ops seeded the GL sector of the standard form with
M = inv(U.T @ W), which is non-square whenever the two GL-sector kernels
differ in rank: for ~34% of non-CSS subsystem codes this crashed
(LinAlgError/IndexError), and for k >= 2 it never enforced intra-type
symplectic orthogonality. get_gauge_ops and get_distance inherit the bug
through dual().get_logical_ops().
Compute the logical operators instead as a symplectic basis of the gauge
group's centralizer C(G) = symplectic_conjugate(canonicalized.matrix).null_space():
the symplectic radical of C(G) is the stabilizer group, so a hyperbolic
basis of C(G) is exactly the k dual pairs of logical operators. This is
correct by construction over every field and does roughly a third as many
Gaussian-elimination passes as the old path.
Add math.symplectic_gram_schmidt to split a space under the symplectic form
into hyperbolic pairs plus a radical. The non-subsystem standard-form path
is unchanged and keeps its pure-Z Z-type logicals; only the subsystem branch
is rewritten, so get_standard_form_data's subsystem branch is now covered by
a direct test rather than transitively.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Simplify subsystem logical-op tests and move their helpers below the caller
Drop two redundant cases from test_qudit_subsystem_logical_ops: the direct-sum
conjugations duplicated the k=2 property case (both are k>=2 crash regressions),
and the per-field get_distance assertions duplicated the shipped reproduction's.
Move the _local_fourier and _direct_sum helpers below the test that uses them.
Coverage stays at 100%.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Address review: restore CSS seeding explanation, tidy sgs, fix docstrings
Restore a self-contained derivation of the U/W/M GL-sector seeding in
CSSCode.get_logical_ops, whose explanatory comment pointed at a block this
change removed from QuditCode.get_logical_ops; also correct a transpose slip
carried over from that block (the seeding enforces A @ U = 0 and B @ V = 0).
Hoist the symplectic conjugates of the extracted pair out of the per-word
projection in symplectic_gram_schmidt. Reword two test docstrings and the
_local_fourier docstring to read standalone.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Tidy subsystem logical-op code and correct is_subsystem_code docstrings
Drop the redundant field view on the centralizer-derived logical operators, and
remove the gauge-sector fill-in in QuditCode.get_logical_ops: subsystem codes
return early, so that line only ran for non-subsystem codes where the gauge
column/row sectors are empty. Underscore the resulting unused sector names.
Warn in symplectic_gram_schmidt that promise_full_rank on linearly dependent
rows leaves those directions in the radical.
Correct both is_subsystem_code docstrings: the method reports whether some parity
checks fail to commute, not whether they all commute. Say "fail to commute"
rather than "anticommute", since over GF(q) non-commuting Paulis need not pick up
a -1 phase.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* revise docstring
* comment
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent ecbf273 commit 0aa39ed
4 files changed
Lines changed: 262 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
918 | | - | |
| 918 | + | |
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
| |||
1172 | 1172 | | |
1173 | 1173 | | |
1174 | 1174 | | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
1179 | 1182 | | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1186 | 1186 | | |
1187 | 1187 | | |
1188 | 1188 | | |
| |||
1198 | 1198 | | |
1199 | 1199 | | |
1200 | 1200 | | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1201 | 1213 | | |
1202 | 1214 | | |
1203 | 1215 | | |
1204 | 1216 | | |
1205 | | - | |
1206 | | - | |
| 1217 | + | |
| 1218 | + | |
1207 | 1219 | | |
1208 | 1220 | | |
1209 | 1221 | | |
| |||
1213 | 1225 | | |
1214 | 1226 | | |
1215 | 1227 | | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
| 1228 | + | |
| 1229 | + | |
1244 | 1230 | | |
1245 | 1231 | | |
1246 | 1232 | | |
| |||
1249 | 1235 | | |
1250 | 1236 | | |
1251 | 1237 | | |
1252 | | - | |
1253 | 1238 | | |
1254 | 1239 | | |
1255 | 1240 | | |
| |||
2406 | 2391 | | |
2407 | 2392 | | |
2408 | 2393 | | |
2409 | | - | |
| 2394 | + | |
2410 | 2395 | | |
2411 | 2396 | | |
2412 | 2397 | | |
| |||
2597 | 2582 | | |
2598 | 2583 | | |
2599 | 2584 | | |
2600 | | - | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
2601 | 2601 | | |
2602 | 2602 | | |
2603 | 2603 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
565 | 685 | | |
566 | 686 | | |
567 | 687 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
0 commit comments