tvalentyn opened a new issue, #40636:
URL: https://github.com/apache/beam/issues/40636

   ### What happened?
   
   It appears that the NNLS approximation is done over data points that 
sometimes represent the deltas in the memory usage, and sometimes the total 
currently used memory. This can reduce the quality of the approximation / 
prediction of future memory usage.
   
   All content below , including Suggested Fix, is LLM-generated:
   
   ResourceEstimator receives inconsistent observations (delta vs. total memory)
   
   - 
[`ModelManager._spawn_new_model`](https://github.com/apache/beam/blob/51ea3f080c23362666a46e0db9f56ebade53cdee/sdks/python/apache_beam/ml/inference/model_manager.py#L756-L762)
 calls `add_observation({tag: 1}, peak_during_load - baseline_snap)`, which 
records a **delta**.
   - 
[`ModelManager.release_model`](https://github.com/apache/beam/blob/51ea3f080c23362666a46e0db9f56ebade53cdee/sdks/python/apache_beam/ml/inference/model_manager.py#L610-L616)
 calls `add_observation(snapshot_of_all_models, peak_during_job)`, which 
records **total** GPU memory.
   - 
[`ResourceEstimator._solve`](https://github.com/apache/beam/blob/51ea3f080c23362666a46e0db9f56ebade53cdee/sdks/python/apache_beam/ml/inference/model_manager.py#L251-L261)
 adds a `+1` bias column to every row. So delta rows say `cost + bias ≈ delta`, 
while total rows say `Σ count·cost + bias ≈ total`. The NNLS system contradicts 
itself.
   - When only one model is loaded, both kinds of reading land in the same 
`history[(("tag", 1),)]` bucket.
   - The spawn delta is also noisy in the concurrent path. `peak` is a 30s 
sliding window that isn't reset before the load, so it can include earlier 
spikes.
   
   **Impact:** per-model memory estimates are skewed, so admission control and 
eviction decisions can be wrong (overcommit → OOM, or needless 
waiting/eviction).
   
   **Suggested fix**
   Feed the estimator only total-memory observations with a consistent model 
snapshot, or drop the spawn-time observation.
   
   
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [x] Component: Python SDK
   - [ ] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [ ] Component: IO connector
   - [ ] Component: Beam YAML
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Infrastructure
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Prism Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to