Skip to content

Fix PREFETCH_M_AMOUNT assertion when MLEN > 64#59

Closed
booth-algo wants to merge 1 commit into
mainfrom
fix/prefetch-mlen-clamp
Closed

Fix PREFETCH_M_AMOUNT assertion when MLEN > 64#59
booth-algo wants to merge 1 commit into
mainfrom
fix/prefetch-mlen-clamp

Conversation

@booth-algo

Copy link
Copy Markdown
Collaborator

Summary

Fixes the emulator panic assertion failed: load_amount % write_amount == 0 when running with MLEN=128 or MLEN=256.

Root cause: HBM_M_Prefetch_Amount in plena_settings.toml defaults to 64. When MLEN > 64, the matrix SRAM tile write requires MLEN rows per tile, but only 64 rows are prefetched — 64 % 128 != 0 triggers the assertion in transfer_mx_from_hbm.

Fix: Clamp PREFETCH_M_AMOUNT to the nearest multiple of MLEN at startup, with a tracing warning when adjustment is needed.

Test plan

  • MLEN=64: no change (64 % 64 == 0, no warning)
  • MLEN=128: clamped to 128 with warning, linear test passes
  • MLEN=256: clamped to 256 with warning, linear test passes
  • MLEN=32: no change (64 % 32 == 0, no warning)

Reported via the dev console GUI at MLEN=128.

🤖 Generated with Claude Code

When MLEN=128 or 256, the TOML default HBM_M_Prefetch_Amount (64) is
smaller than MLEN, causing `load_amount % write_amount == 0` to fail
in transfer_mx_from_hbm. Each matrix SRAM tile write requires exactly
MLEN rows, so PREFETCH_M_AMOUNT must be >= MLEN and a multiple of it.

Fix: clamp PREFETCH_M_AMOUNT to the nearest multiple of MLEN at startup,
with a warning when adjustment is needed.

Fixes the dev console crash at MLEN=128 reported by the GUI backend.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@booth-algo

Copy link
Copy Markdown
Collaborator Author

Merged into PR #60 (fix/aten-test-configurable-mlen already includes this commit as its parent).

@booth-algo booth-algo closed this May 28, 2026
@booth-algo booth-algo deleted the fix/prefetch-mlen-clamp branch May 28, 2026 09:08
booth-algo added a commit that referenced this pull request Jun 3, 2026
booth-algo added a commit that referenced this pull request Jun 3, 2026
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