[GH-ISSUE #418] GLM v1.1.25: image conversations bypass RAM slots and fully prefill after switching chats (independent validation of #331) #164

Closed
opened 2026-10-29 21:21:53 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @CoolJohn-lab on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/418

GLM conversations containing an image are excluded from parked conversation slots in v1.1.25, causing a full prefill after switching to another conversation even with ample RAM cache capacity.

This is an independent reproduction of the problem addressed by open PR #331. That PR appears to contain the appropriate upstream fix; please consider this report additional validation rather than a competing implementation.

Environment

  • Project Maya v1.1.25, commit 94878e25e3860e22ea29b4fff506ade8c477a57b
  • GLM-5.3-Flash Maya-M, Linux/CUDA, four RTX 3080 GPUs
  • 1,048,576-token context, one active generation
  • MAYA_GLM_SLOT_RAM_GB=32, MAYA_GLM_SLOTS=16, MAYA_GLM_RAM_HEADROOM_GB=44
  • Initially observed while alternating VS Code conversations; reproduced with controlled API requests.

Reproduction

  1. Start conversation A with an image, then receive an answer.
  2. Run an unrelated text-only conversation B.
  3. Continue A, including its original image in the history.
  4. Repeat switching between A and B.

Expected: A's compatible prefix restores from a parked slot.
Actual: image-bearing A repeatedly starts with zero cached tokens; text-only conversations restore normally. In the real workload, approximately 70–74K-token image conversations repeatedly required a full prefill. At diagnosis only approximately 4.3 GB of the 32 GiB cache budget was used, so this was not a capacity eviction.

A controlled pre-fix blue-image probe returned zero cached tokens after the switch.

Root cause / proposed fix

In src/program/generate.cpp, slot_put returns when snap_img_hash != kNoImages, and slot_take returns when !cur_img_pos.empty().

Removing those guards alone would be unsafe: different images can have identical text and placeholder tokens. The fix should:

  • Store the image fingerprint in each slot.
  • Require both token-prefix equality and the matching image fingerprint at the saved prefix length: saved.image_hash == img_hash(saved.tokens.size()).
  • Restore snap_img_hash from the selected slot.
  • Supersede an older slot only when its token prefix AND image fingerprint match, so saving a red-image variant does not discard a blue-image variant with the same text.
  • Version persisted slot metadata if adding the fingerprint to disk slots, as proposed in #331.

We applied and tested a narrower local RAM-only implementation. It leaves the existing disk format and image checkpoint guards unchanged. PR #331 handles the broader persistent-slot case.

Live results after RAM-only fix

Greedy short answers, same running model, alternating controlled blue/red images and text conversations:

Request Prompt tokens Cached tokens New prompt tokens Correct answer Request wall time
Blue image, cold 1673 0 1673 Blue 6.79 s
Unrelated text conversation 1651 0 1651 READY 5.46 s
Blue image, restored 1687 1672 15 Blue 0.86 s
Same text, changed to red image 1673 0 1673 Red 7.35 s
Text conversation restored 1651 1650 1 READY 0.21 s
Red image, restored 1687 1672 15 Red 0.68 s
Original blue variant restored again 1687 1686 1 Blue 0.16 s

These are request wall times, not isolated prefill benchmarks. The changed-image miss and later restoration of both variants verify image identity protection and safe slot supersession. Native RAM save/load logs also confirm restoration.

Five local checks passed, including compiled C++ prefix/image-identity and supersession checks. Authentication rejection, arithmetic, forced tool use, and vision smoke checks passed after deployment. Full-budget/1M-context cache soak and image slot persistence across restart were not tested by us.

Would be happy to provide the small RAM-only diff if useful; #331 already proposes the same core identity checks with persistent-slot support.

Originally created by @CoolJohn-lab on GitHub (Oct 23, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/418 GLM conversations containing an image are excluded from parked conversation slots in v1.1.25, causing a full prefill after switching to another conversation even with ample RAM cache capacity. This is an independent reproduction of the problem addressed by open PR #331. That PR appears to contain the appropriate upstream fix; please consider this report additional validation rather than a competing implementation. ### Environment - Project Maya v1.1.25, commit `94878e25e3860e22ea29b4fff506ade8c477a57b` - GLM-5.3-Flash Maya-M, Linux/CUDA, four RTX 3080 GPUs - 1,048,576-token context, one active generation - `MAYA_GLM_SLOT_RAM_GB=32`, `MAYA_GLM_SLOTS=16`, `MAYA_GLM_RAM_HEADROOM_GB=44` - Initially observed while alternating VS Code conversations; reproduced with controlled API requests. ### Reproduction 1. Start conversation A with an image, then receive an answer. 2. Run an unrelated text-only conversation B. 3. Continue A, including its original image in the history. 4. Repeat switching between A and B. Expected: A's compatible prefix restores from a parked slot. Actual: image-bearing A repeatedly starts with zero cached tokens; text-only conversations restore normally. In the real workload, approximately 70–74K-token image conversations repeatedly required a full prefill. At diagnosis only approximately 4.3 GB of the 32 GiB cache budget was used, so this was not a capacity eviction. A controlled pre-fix blue-image probe returned zero cached tokens after the switch. ### Root cause / proposed fix In `src/program/generate.cpp`, `slot_put` returns when `snap_img_hash != kNoImages`, and `slot_take` returns when `!cur_img_pos.empty()`. Removing those guards alone would be unsafe: different images can have identical text and placeholder tokens. The fix should: - Store the image fingerprint in each slot. - Require both token-prefix equality and the matching image fingerprint at the saved prefix length: `saved.image_hash == img_hash(saved.tokens.size())`. - Restore `snap_img_hash` from the selected slot. - Supersede an older slot only when its token prefix AND image fingerprint match, so saving a red-image variant does not discard a blue-image variant with the same text. - Version persisted slot metadata if adding the fingerprint to disk slots, as proposed in #331. We applied and tested a narrower local RAM-only implementation. It leaves the existing disk format and image checkpoint guards unchanged. PR #331 handles the broader persistent-slot case. ### Live results after RAM-only fix Greedy short answers, same running model, alternating controlled blue/red images and text conversations: | Request | Prompt tokens | Cached tokens | New prompt tokens | Correct answer | Request wall time | |---|---:|---:|---:|---|---:| | Blue image, cold | 1673 | 0 | 1673 | Blue | 6.79 s | | Unrelated text conversation | 1651 | 0 | 1651 | READY | 5.46 s | | Blue image, restored | 1687 | 1672 | 15 | Blue | 0.86 s | | Same text, changed to red image | 1673 | 0 | 1673 | Red | 7.35 s | | Text conversation restored | 1651 | 1650 | 1 | READY | 0.21 s | | Red image, restored | 1687 | 1672 | 15 | Red | 0.68 s | | Original blue variant restored again | 1687 | 1686 | 1 | Blue | 0.16 s | These are request wall times, not isolated prefill benchmarks. The changed-image miss and later restoration of both variants verify image identity protection and safe slot supersession. Native RAM save/load logs also confirm restoration. Five local checks passed, including compiled C++ prefix/image-identity and supersession checks. Authentication rejection, arithmetic, forced tool use, and vision smoke checks passed after deployment. Full-budget/1M-context cache soak and image slot persistence across restart were not tested by us. Would be happy to provide the small RAM-only diff if useful; #331 already proposes the same core identity checks with persistent-slot support.
Author
Owner

@mw00 commented on GitHub (Oct 28, 2026):

Fixed by @Cass67's #331: GLM's conversation slots now keep picture conversations too, so a chat with an image is restored after a switch instead of read again from the start (on our V100s a 3.6K-token picture conversation came back in 0.5 s instead of 8 s). Thanks for the clear report - closing.

Released in v1.1.35: https://github.com/mw00/project-maya/releases/tag/v1.1.35

<!-- gh-comment-id:6464812251 --> @mw00 commented on GitHub (Oct 28, 2026): Fixed by @Cass67's #331: GLM's conversation slots now keep picture conversations too, so a chat with an image is restored after a switch instead of read again from the start (on our V100s a 3.6K-token picture conversation came back in 0.5 s instead of 8 s). Thanks for the clear report - closing. Released in **v1.1.35**: https://github.com/mw00/project-maya/releases/tag/v1.1.35
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#164
No description provided.