Skip to content

feat: expose committed_device_memory on DistributedWorker - #2209

Open
sunghajung6688 wants to merge 1 commit into
hw-native-sys:mainfrom
sunghajung6688:cdm
Open

feat: expose committed_device_memory on DistributedWorker#2209
sunghajung6688 wants to merge 1 commit into
hw-native-sys:mainfrom
sunghajung6688:cdm

Conversation

@sunghajung6688

Copy link
Copy Markdown

Delegates to the underlying simpler Worker(level=3) facade (self._w.committed_device_memory), which forwards a CTRL_COMMITTED_DEVICE_MEMORY query to the forked chip child and sums across chips.

Closes hw-native-sys/simpler#1457

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e6862d1e-36fc-487b-a1e9-6a045e7dfa75

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

DistributedWorker now provides committed_device_memory(worker_id=0), returning committed device HBM in bytes while handling closed or unavailable underlying workers. The runtime submodule reference is also updated.

Changes

Distributed memory API

Layer / File(s) Summary
Committed memory query
python/pypto/runtime/distributed_runner.py
Adds committed_device_memory, validating worker state, handling absent workers, checking runtime support, and returning the underlying committed-memory value as an integer.
Runtime support update
runtime
Updates the runtime submodule reference used by the distributed memory query.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A bunny checked the HBM with care,
And found committed bytes hiding there.
“Query the worker!” the rabbit cried,
Zero if absent, values supplied.
Memory’s now easier to trace—
Hop, hop, through the distributed space!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: exposing committed device memory on DistributedWorker.
Description check ✅ Passed The description explains delegation to simpler and links the directly related issue for exposing committed device memory.
Linked Issues check ✅ Passed The PR adds the requested DistributedWorker API and delegates to simpler to report committed NPU memory, satisfying issue #1457.
Out of Scope Changes check ✅ Passed The changes are focused on exposing committed device memory and updating the runtime dependency needed to support that behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6d4b8991d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

self._require_open("committed_device_memory")
if self._w is None:
return 0
return int(self._w.committed_device_memory(worker_id))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bump simpler before exposing the passthrough

When this new API is called with the repository-managed/runtime-pinned simpler checkout, self._w is still the current simpler.worker.Worker from the unchanged runtime gitlink, which does not expose committed_device_memory yet; callers therefore get an AttributeError instead of the memory counter. Please update the pinned/runtime dependency to a simpler revision containing that method, or guard this path with a clear version/runtime error so the PyPTO API is not advertised while its backend is absent.

Useful? React with 👍 / 👎.

@sunghajung6688
sunghajung6688 force-pushed the cdm branch 2 times, most recently from 46f3ce4 to 8b94e80 Compare July 31, 2026 01:13
@sunghajung6688

Copy link
Copy Markdown
Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
python/pypto/runtime/distributed_runner.py (1)

1627-1643: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add focused tests for the new public API.

Cover normal per-worker forwarding, integer conversion, closed-worker behavior, absent workers, and the missing-runtime-method error. Place tests under tests/, since this API affects memory accounting used for KV-cache sizing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/pypto/runtime/distributed_runner.py` around lines 1627 - 1643, Add
focused tests under tests/ for DistributedRunner.committed_device_memory
covering forwarding the requested worker_id and converting the result to int,
returning the closed-worker behavior, handling absent workers, and raising the
expected RuntimeError when the underlying runtime lacks committed_device_memory.
Use the existing runner and mock/fake runtime test utilities and preserve the
documented error message expectations.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@python/pypto/runtime/distributed_runner.py`:
- Around line 1627-1643: Add focused tests under tests/ for
DistributedRunner.committed_device_memory covering forwarding the requested
worker_id and converting the result to int, returning the closed-worker
behavior, handling absent workers, and raising the expected RuntimeError when
the underlying runtime lacks committed_device_memory. Use the existing runner
and mock/fake runtime test utilities and preserve the documented error message
expectations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 14f974a0-3afe-4493-83ea-4f9399d6871e

📥 Commits

Reviewing files that changed from the base of the PR and between c6d4b89 and 8b94e80.

📒 Files selected for processing (2)
  • python/pypto/runtime/distributed_runner.py
  • runtime

Delegates to the underlying simpler Worker(level=3) facade (self._w.committed_device_memory), which forwards a CTRL_COMMITTED_DEVICE_MEMORY query to the forked chip child and sums across chips.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Feature] Expose simpler's committed NPU memory (rtMalloc pool is invisible to aclrtGetMemInfo)

1 participant