fix(epp): reduce per-request memory retention during inference - #3
Open
Lucas-Fernandes-Martins wants to merge 1 commit into
Open
fix(epp): reduce per-request memory retention during inference#3Lucas-Fernandes-Martins wants to merge 1 commit into
Lucas-Fernandes-Martins wants to merge 1 commit into
Conversation
Lucas-Fernandes-Martins
marked this pull request as ready for review
July 26, 2026 14:22
Lucas-Fernandes-Martins
force-pushed
the
lfm/fix-memory-issues-request-parsing
branch
2 times, most recently
from
July 27, 2026 07:26
1907f26 to
df961a9
Compare
Release heavy InferenceRequestBody fields (Payload, ChatCompletions, Messages, etc.) immediately after repackage so GC can collect them during the long inference wait (60-700s). Only Stream, Model, and MaxOutputTokens are read post-repackage. Replace full base64 decode in image dimension estimation with a streaming decoder — image.DecodeConfig only needs the image header (~100 bytes), not the entire decoded payload. Profiling on production EPP pods showed multimodal requests retaining ~225 MB each for the full inference duration. These two fixes reduce live heap by ~11 GB at 100 concurrent multimodal requests.
Lucas-Fernandes-Martins
force-pushed
the
lfm/fix-memory-issues-request-parsing
branch
from
July 27, 2026 07:30
df961a9 to
0cf5db0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Profiling EPP pods under multimodal load (1325 heap dumps over 11 hours) showed each request retaining ~225 MB for the full inference duration (60-700s). At 100 concurrent multimodal requests, live heap hits 22.5 GB and RSS balloons to ~40 GB. Two unnecessary memory retention patterns account for most of the waste.
Summary
1. Release heavy fields after repackage (
director.go)Setting request payload to nil after it's used for the last time to save memory (GC won't free that memory since it belongs to a struct that is still in use).
2. Stream base64 for image dimensions (
mm_estimate.go)imageDimensionsFromBase64Payloadfully decodes base64 images into memory just to callimage.DecodeConfig, which only reads the image header (~100 bytes for PNG/JPEG/GIF). Replaced with a streamingbase64.NewDecoderthat decodes lazily asimage.DecodeConfig.