Conversation
Emit the pytorch_inference resident set size on a fixed 10s interval, independent of inference requests, reporting both the current RSS (memory_rss) and the OS peak (memory_max_rss). This lets Elasticsearch track real native memory use per trained model deployment and keep assignment and adaptive scaling OOM-safe rather than relying on an a priori estimate. The process-stats field is renamed to "stats" to match the Elasticsearch PyTorchResult parser. Relates elastic#2885
|
buildkite run_serverless_tests ES_SERVERLESS_BRANCH=feature/ml-cpp-repo-override |
|
Pinging @elastic/ml-core (Team:ML) |
|
Hi @edsavage, I've created a changelog YAML for you. |
|
buildkite run_serverless_tests ES_SERVERLESS_BRANCH=feature/ml-cpp-repo-override |
|
buildkite run_serverless_tests |
There was a problem hiding this comment.
Pull request overview
Adds periodic current and peak RSS reporting for pytorch_inference, with updated stats serialization and evaluation tooling.
Changes:
- Adds a stoppable 10-second memory reporter thread.
- Renames process-stat output to
statsand includes RSS fields. - Updates tests, evaluator parsing, and changelog documentation.
Reviewed changes
Copilot reviewed 2 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
docs/changelog/3160.yaml |
Adds changelog metadata. |
docs/CHANGELOG.asciidoc |
Adds the release-note entry. |
bin/pytorch_inference/unittest/CResultWriterTest.cc |
Updates stats serialization expectations. |
bin/pytorch_inference/Main.cc |
Adds periodic memory reporting and shutdown handling. |
bin/pytorch_inference/evaluate.py |
Parses and displays updated memory statistics. |
bin/pytorch_inference/CResultWriter.h |
Documents memory stats output. |
bin/pytorch_inference/CResultWriter.cc |
Updates the stats output schema. |
The periodic stats documents use request_id ignore, but evaluate.py counts them as request-triggered samples, which can misassociate request sizes and cause an IndexError. These samples must be distinguished before incrementing stats_count.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
buildkite build this |
… 3160.yaml Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Adds a periodic memory reporter to
pytorch_inferenceso Elasticsearch can track the process's real resident set size (RSS) for a trained model deployment, independent of inference traffic.memory_rss) and the OS peak / high-water mark (memory_max_rss). The peak is transmitted explicitly rather than derived on the ES side from the sample stream, so transient spikes between reports are not lost — this is the signal used to keep model assignment and adaptive scaling OOM-safe.process_statstostatsto match the ElasticsearchPyTorchResult/InferenceProcessStatsparser.Relates #2885
Release-ordering note (important)
ES's
InferenceProcessStatsparser is strict and treats an unknown field as a fatal parse error for the result stream. Because this PR (re)introducesmemory_max_rss, the Elasticsearch-side change that acceptsmemory_max_rssas an optional field must be merged before this PR is merged into ml-cpp. See the companion Elasticsearch PR.Merging this PR before the ES-side fix is not simply "safe with the constraint on the version bump" — once this PR lands, the nightly ml-cpp snapshot will start emitting
memory_max_rss. The automatic ES version bump PR will pick up that snapshot and run ES integration tests and QAF tests against an ES parser that still rejects unknown fields, causing those tests to fail with a fatal parse error. The version bump PR will be stuck until the ES-side fix lands. To avoid that: merge the ES-side PR first, then merge this one.Test plan
CResultWriterTest.testWriteProcessStatsupdated for thestatsschema +memory_max_rss; passes (all 7CResultWriterTestcases pass).pytorch_inferencewith a model and confirm periodicstatsdocs are emitted ~every 10s withmemory_rssandmemory_max_rss. Observed{"request_id":"ignore","stats":{"memory_rss":0,"memory_max_rss":93339648}}after one 10s tick on macOS (memory_rssis 0 on macOS — platform-specific; both fields will be non-zero on Linux).Made with Cursor