Skip to content

Reduce data that is transmitted and stored for memory devices - #4733

Draft
terickson-nvidia wants to merge 8 commits into
NVIDIA:mainfrom
terickson-nvidia:tom/memory-devices
Draft

Reduce data that is transmitted and stored for memory devices#4733
terickson-nvidia wants to merge 8 commits into
NVIDIA:mainfrom
terickson-nvidia:tom/memory-devices

Conversation

@terickson-nvidia

@terickson-nvidia terickson-nvidia commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

For better scaling, this PR reduces the size of data transmitted and stored for memory devices. It adds a count field to {size, type} so that repeating MemoryDevice records can be condensed into a single MemoryDeviceGroup record. Wherever the code expects the MemoryDevice list, the condensed list is rehydrated from the new internal format.

Related issues

#4819

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

A note about breaking changes:

If new code is installed, it will write condensed memory device groups, and the deprecated flat list of memory devices will be empty. If code is rolled back to an earlier version, it will read the empty list and the memory devices will be
lost.

But that's a re-enumeration problem, not a permanent data loss.

I don't think that counts as a breaking change since currently downgrade is not supported (see docs/development/release_and_qa_process.md). Nothing is broken when upgrade applies this change. All the user-visible outputs remain the same; only the internal, persisted format is condensed, and deserialization handles both old and new formats.

@terickson-nvidia
terickson-nvidia requested a review from a team as a code owner August 7, 2026 22:35
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Draft detected.

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 045552f1-87b0-43a2-8568-178ebcc96979

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

Summary by CodeRabbit

  • New Features

    • Memory inventory now groups identical memory devices and records their quantity.
    • Memory totals, capacity breakdowns, and component counts accurately include device quantities.
    • Hardware discovery and host displays support grouped memory details.
  • Bug Fixes

    • Corrected calculations that previously counted each device entry only once.
    • Added compatibility for reading legacy, ungrouped memory data.
  • Refactor

    • Deprecated flat memory reporting for new data while preserving legacy read support.

Walkthrough

Memory inventory now uses grouped records with device counts. Protocols, discovery, RPC conversion, display formatting, capability totals, SKU generation, fixtures, and legacy compatibility handling were updated.

Changes

Grouped memory device flow

Layer / File(s) Summary
Memory grouping contracts
crates/api-model/src/hardware_info.rs, crates/rpc/proto/..., rest-api/proto/..., crates/rpc/src/protos/mod.rs
Added MemoryDeviceGroup, count-based expansion and condensation, zero-count filtering, and legacy deserialization support. Deprecated flat RPC fields remain readable.
RPC conversion and compatibility
crates/rpc/src/model/hardware_info.rs
RPC conversion prefers grouped data, condenses legacy flat data, emits grouped data, and expands groups for flat projections. Tests cover round trips, count preservation, and zero-count filtering.
Discovery and memory display
crates/host-support/..., crates/machine-a-tron/..., crates/api-web/..., crates/rpc-utils/...
Discovery producers write grouped records. Display formatting uses group counts and falls back to legacy flat records.
Count-aware aggregation and fixtures
crates/api-model/src/machine/capabilities.rs, crates/api-db/src/sku.rs, crates/api-model/src/test_support/...
Capability totals and SKU aggregation multiply memory size by count. GPU count increments use saturating arithmetic. Hardware fixtures use grouped records.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HardwareDiscovery
  participant DiscoveryInfo
  participant RpcHardwareInfo
  participant ManagedHostDisplay
  HardwareDiscovery->>DiscoveryInfo: write memory_device_groups
  DiscoveryInfo->>RpcHardwareInfo: convert grouped discovery data
  RpcHardwareInfo->>ManagedHostDisplay: provide grouped memory data
  ManagedHostDisplay->>ManagedHostDisplay: multiply sizes and counts
Loading

Possibly related issues

  • Issue 4819: The changes use counted MemoryDeviceGroup records and preserve rehydration semantics, matching the issue objective.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 67.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: reducing transmitted and stored memory-device data.
Description check ✅ Passed The description directly explains memory-device grouping, rehydration, scaling benefits, compatibility, and testing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

🔐 TruffleHog Secret Scan

No secrets or credentials found!

Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉

🔗 View scan details

🕐 Last updated: 2026-08-08 00:01:25 UTC | Commit: 28c67ec

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@crates/rpc/proto/machine_discovery.proto`:
- Around line 206-210: Define and apply one explicit zero-count contract for
MemoryDeviceGroup across all grouped-memory paths. In
crates/rpc/proto/machine_discovery.proto lines 206-210 and
rest-api/proto/core/src/v1/machine_discovery_nico.proto lines 211-215, document
whether zero is invalid or normalizes to one; in
crates/api-model/src/hardware_info.rs lines 290-315 and
crates/rpc-utils/src/managed_host_display.rs lines 544-557, enforce that
contract before merging or calculating totals. In
crates/rpc/src/model/hardware_info.rs lines 2134-2184, add a table-driven
compatibility case covering zero counts and the chosen normalized or rejected
result.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bce7494d-d4b8-401d-aa89-79f2b15d1523

📥 Commits

Reviewing files that changed from the base of the PR and between e05a814 and b9cec8b.

⛔ Files ignored due to path filters (1)
  • rest-api/proto/core/gen/v1/machine_discovery_nico.pb.go is excluded by !**/*.pb.go, !**/gen/**, !rest-api/**/*.pb.go
📒 Files selected for processing (11)
  • crates/api-db/src/sku.rs
  • crates/api-model/src/hardware_info.rs
  • crates/api-model/src/machine/capabilities.rs
  • crates/api-model/src/test_support/machine_snapshot.rs
  • crates/api-web/src/managed_host.rs
  • crates/host-support/src/hardware_enumeration.rs
  • crates/machine-a-tron/src/discovery_info.rs
  • crates/rpc-utils/src/managed_host_display.rs
  • crates/rpc/proto/machine_discovery.proto
  • crates/rpc/src/model/hardware_info.rs
  • rest-api/proto/core/src/v1/machine_discovery_nico.proto

Comment thread crates/rpc/proto/machine_discovery.proto
@terickson-nvidia
terickson-nvidia marked this pull request as draft August 7, 2026 22:59
@copy-pr-bot

copy-pr-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@copy-pr-bot

copy-pr-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@terickson-nvidia

Copy link
Copy Markdown
Contributor Author

Temporarily taking out of draft to troubleshoot trufflehog false positive. Don't merge merge until tested on DPU.

@terickson-nvidia
terickson-nvidia marked this pull request as ready for review August 7, 2026 23:58
@terickson-nvidia

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

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.

@terickson-nvidia

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 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.

Inline comments:
In `@crates/api-db/src/sku.rs`:
- Around line 554-562: The SKU aggregation paths use unchecked arithmetic for
memory totals and component counts. In crates/api-db/src/sku.rs lines 554-562,
update generate_base_sku_from_hardware so total_mem and entry.count use widened
operands with saturating_add, or reject overflow before constructing SKU data;
apply the same policy in generate_sku_from_machine_at_version_0_or_1 at lines
414-422.

In `@crates/api-model/src/hardware_info.rs`:
- Around line 54-55: Preserve legacy compatibility across
crates/api-model/src/hardware_info.rs:54-55,
crates/rpc/src/model/hardware_info.rs:564-570,
crates/host-support/src/hardware_enumeration.rs:916-918, and
crates/machine-a-tron/src/discovery_info.rs:232-234, 289-291, 356-358, 447-449,
and 580-582 by populating both memory_devices and memory_device_groups in
outgoing DiscoveryInfo. Keep the grouped-to-flat fallback for reads, and use
capability gating or a documented migration/rollout plan so legacy clients
receive correctly expanded devices rather than one device per group when count
exceeds one.

In `@crates/api-model/src/machine/capabilities.rs`:
- Around line 352-360: Use a consistent zero-count policy for grouped-memory
aggregation: skip any MemoryDeviceGroup with count == 0 before updating results.
Apply this in crates/api-model/src/machine/capabilities.rs:352-360 around the
mem_map insertion, crates/api-db/src/sku.rs:414-422 before SKU totals/components
updates, and crates/api-db/src/sku.rs:554-562 within
generate_base_sku_from_hardware; define and add tests covering the zero-count
behavior.
- Around line 352-360: Update the memory capability aggregation around
MemoryDeviceGroup::rehydrate so groups with count == 0 do not insert or
contribute a zero-valued capability; skip them before calculating or updating
mem_map. Define the zero-count behavior explicitly and add or update tests
covering that no capability entry is produced for such groups.

In `@crates/machine-a-tron/src/discovery_info.rs`:
- Line 979: Update the test around the discovery memory group assertion to
compare the complete expected MemoryDeviceGroup, including count, size, memory
type, and the 983,040 MiB inventory, rather than checking only len(). Also
update the related tests to preserve the count and verify discovery round trips.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d5cd1f6f-28fb-45cd-910f-b9b8a6f8b90e

📥 Commits

Reviewing files that changed from the base of the PR and between 70a9804 and 088894c.

⛔ Files ignored due to path filters (1)
  • rest-api/proto/core/gen/v1/machine_discovery_nico.pb.go is excluded by !**/*.pb.go, !**/gen/**, !rest-api/**/*.pb.go
📒 Files selected for processing (11)
  • crates/api-db/src/sku.rs
  • crates/api-model/src/hardware_info.rs
  • crates/api-model/src/machine/capabilities.rs
  • crates/api-model/src/test_support/machine_snapshot.rs
  • crates/api-web/src/managed_host.rs
  • crates/host-support/src/hardware_enumeration.rs
  • crates/machine-a-tron/src/discovery_info.rs
  • crates/rpc-utils/src/managed_host_display.rs
  • crates/rpc/proto/machine_discovery.proto
  • crates/rpc/src/model/hardware_info.rs
  • rest-api/proto/core/src/v1/machine_discovery_nico.proto

Comment thread crates/api-db/src/sku.rs Outdated
Comment thread crates/api-model/src/hardware_info.rs
Comment thread crates/api-model/src/machine/capabilities.rs
Comment thread crates/machine-a-tron/src/discovery_info.rs Outdated
@terickson-nvidia
terickson-nvidia marked this pull request as draft August 8, 2026 01:27
@terickson-nvidia

Copy link
Copy Markdown
Contributor Author

The last commit condenses only consecutive ranges of memory devices with the same size+type, without empty slot placeholders, since that best matches the information we currently preserve: "populated slot N" but not "physical slot N".

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@crates/api-model/src/hardware_info.rs`:
- Around line 311-316: The three memory-device count accumulation sites must
prevent u32 overflow by using saturating addition. Update the grouping logic
around MemoryDeviceGroup in crates/api-model/src/hardware_info.rs:283-291 and
311-316, plus the enumeration accumulation in
crates/host-support/src/hardware_enumeration.rs:929-937; add a regression test
covering merging counts u32::MAX and 1, preserving the resulting count at
u32::MAX.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 049385b3-6930-4838-8688-363b4f5ea091

📥 Commits

Reviewing files that changed from the base of the PR and between 088894c and 9f57420.

📒 Files selected for processing (7)
  • crates/api-db/src/sku.rs
  • crates/api-model/src/hardware_info.rs
  • crates/host-support/src/hardware_enumeration.rs
  • crates/machine-a-tron/src/discovery_info.rs
  • crates/rpc-utils/src/managed_host_display.rs
  • crates/rpc/src/model/hardware_info.rs
  • crates/rpc/src/protos/mod.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • crates/api-db/src/sku.rs
  • crates/rpc-utils/src/managed_host_display.rs
  • crates/machine-a-tron/src/discovery_info.rs
  • crates/rpc/src/model/hardware_info.rs

Comment thread crates/api-model/src/hardware_info.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant