Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

docs(readme): fix spectral-radius example for 1-D diagonal A#60

Open
NFTAC wants to merge 1 commit intokyegomez:mainkyegomez/OpenMythos:mainfrom
NFTAC:fix/readme-spectral-radiusNFTAC/OpenMythos:fix/readme-spectral-radiusCopy head branch name to clipboard
Open

docs(readme): fix spectral-radius example for 1-D diagonal A#60
NFTAC wants to merge 1 commit intokyegomez:mainkyegomez/OpenMythos:mainfrom
NFTAC:fix/readme-spectral-radiusNFTAC/OpenMythos:fix/readme-spectral-radiusCopy head branch name to clipboard

Conversation

@NFTAC
Copy link
Copy Markdown

@NFTAC NFTAC commented Apr 25, 2026

Summary

The README's stability-check snippet errors when run as written:

```python
A = model.recurrent.injection.get_A()
rho = torch.linalg.eigvals(A).abs().max().item()

RuntimeError: linalg.eig: The input tensor A must have at least 2 dimensions.

```

`LTIInjection.get_A()` returns a 1-D tensor of shape `(dim,)` — the diagonal of a diagonal state matrix — so `torch.linalg.eigvals` rejects it. The eigenvalues of a diagonal matrix are simply its diagonal entries, so the correct (and simpler) form is `A.abs().max()`.

Reproduced on a fresh install (`open-mythos==0.5.0`, Python 3.11, PyTorch 2.8) using the exact README example. After the fix the example runs end-to-end and prints `ρ(A) = 0.3679` (= `exp(-1)` at init, matching the `log_dt = log_A = 0` parameterization).

Test plan

  • Ran the README snippet on a clean install — errored before, prints `ρ(A) = 0.3679` after
  • Cross-checked against `torch.linalg.eigvals(torch.diag(A)).abs().max()` — same value
  • Verified `ρ < 1` holds at init by construction (`A_i = exp(-exp(log_dt + log_A))`)

get_A() returns a 1-D tensor (the diagonal of a diagonal state matrix),
so torch.linalg.eigvals(A) raises 'input must have at least 2 dimensions'.
The eigenvalues of a diagonal matrix are its diagonal entries, so
A.abs().max() is both correct and simpler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.