Skip to content

docs(examples): demonstrate per-ring runtime_env sizing#1122

Merged
ChaoZheng109 merged 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:docs/per-ring-runtime-env-examples
Jun 24, 2026
Merged

docs(examples): demonstrate per-ring runtime_env sizing#1122
ChaoZheng109 merged 1 commit into
hw-native-sys:mainfrom
ChaoZheng109:docs/per-ring-runtime-env-examples

Conversation

@ChaoZheng109

Copy link
Copy Markdown
Collaborator

What

#1099 added per-ring array fields (ring_task_windows / ring_heaps / ring_dep_pools) to CallConfig.runtime_env, alongside the existing scalar knobs. The two per_task_runtime_env examples, however, only demonstrated the scalar form — there was no worked example of the new per-ring sizing.

This extends both examples to also cover the per-ring form, where each scope-depth ring (0..3) is sized independently.

Changes

  • L2 examples/workers/l2/per_task_runtime_env/ — new per_ring config entry sizing rings 0..3 with the array fields; _make_config now iterates a RING_FIELDS tuple so a spec dict can carry either the scalar or array keys.
  • L3 examples/workers/l3/per_task_runtime_env/ — new l2_per_ring task showing heterogeneous per-ring footprints across L2s in one launch; _l2_config similarly generalized.
  • READMEs updated with the scalar-vs-array table, the full precedence chain (per-ring field > scalar field > per-ring env > scalar env > default), and the --enable-scope-stats verification path.

Per-ring values are valid per RuntimeEnv::validate() (task_windows are powers of 2 in [4, INT32_MAX], heaps >= 1024, dep_pools in [4, INT32_MAX]), and total footprint stays below the already-working scalar_large broadcast.

Test

Both examples pass under a2a3sim, including the new per-ring configs (golden max diff = 0). The STs call run() directly, so existing test_per_task_runtime_env.py automatically covers the added configs.

python examples/workers/l2/per_task_runtime_env/main.py -p a2a3sim -d 0
python examples/workers/l3/per_task_runtime_env/main.py -p a2a3sim -d 0

@coderabbitai

coderabbitai Bot commented Jun 23, 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

Run ID: 5ac8f9eb-08ab-4d86-a87d-7f0e0089e2b2

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
📝 Walkthrough

Walkthrough

Both the L2 and L3 per-task runtime-env examples are extended to support per-ring array sizing alongside existing scalar fields. A RING_FIELDS tuple enumerates all supported runtime_env keys; RING_CONFIGS/L2_TASKS gain a new per_ring/l2_per_ring entry using 4-element arrays. Config helpers are refactored to iterate RING_FIELDS generically. READMEs document the updated model, precedence chain, and verification path.

Changes

Per-ring array runtime_env sizing in L2/L3 examples

Layer / File(s) Summary
L2 RING_FIELDS, RING_CONFIGS, _make_config, and README
examples/workers/l2/per_task_runtime_env/main.py, examples/workers/l2/per_task_runtime_env/README.md
Introduces RING_FIELDS tuple; expands RING_CONFIGS to scalar_small, scalar_large, per_ring (4-entry arrays for scope-depth rings 0–3), and env_or_default; refactors _make_config to iterate RING_FIELDS instead of hardcoding scalar keys; updates README with both config forms, precedence chain, field constraints, and --enable-scope-stats verification guidance.
L3 RING_FIELDS, L2_TASKS expansion, _l2_config refactor, and README
examples/workers/l3/per_task_runtime_env/main.py, examples/workers/l3/per_task_runtime_env/README.md
Introduces RING_FIELDS; expands L2_TASKS from two to three entries, adding l2_per_ring with array-based sizing; refactors _l2_config to loop over RING_FIELDS; updates run-logging to use len(L2_TASKS); updates README to name three tasks (l2_scalar_small, l2_scalar_large, l2_per_ring), document both config forms and fallback behavior, and generalize execution descriptions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • hw-native-sys/simpler#1042: Introduced the per-task CallConfig.runtime_env API and the initial versions of the same l2/l3 per-task runtime-env example files that this PR extends.
  • hw-native-sys/simpler#1099: Added the per-ring fields (ring_task_windows, ring_heaps, ring_dep_pools) and scope_stats verification that this PR's examples now demonstrate and document.

Poem

🐇 Hop, hop! Four rings in a row,
Arrays now tell each scope where to go.
RING_FIELDS enumerated neat,
per_ring configs — oh what a feat!
The scalar and array live side by side,
Down the precedence chain they glide. 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% 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 'docs(examples): demonstrate per-ring runtime_env sizing' clearly and specifically describes the main change: adding worked examples of per-ring runtime_env sizing to documentation examples.
Description check ✅ Passed The description is well-related to the changeset, explaining the motivation (PR #1099 added per-ring fields but examples only showed scalar form), the specific changes to L2 and L3 examples, documentation updates, and validation/testing results.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces support for per-ring sizing (independent sizing of the four scope-depth rings) alongside the existing scalar form (broadcasting one value to all rings) for L2 and L3 workers. It updates the examples, configurations, and documentation to demonstrate and support both forms. The reviewer suggests improving the _l2_config helper in the L3 example to preserve pre-existing runtime_env fields from the base configuration that are not overridden by the task specification, and recommends using getattr for safer attribute access.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread examples/workers/l3/per_task_runtime_env/main.py

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
examples/workers/l2/per_task_runtime_env/README.md (1)

53-53: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the stale run count in the layout comment.

Line 53 says 3 runs, but this example now runs four configs (scalar_small, scalar_large, per_ring, env_or_default), so the docs are inconsistent.

Suggested patch
-  main.py                 # 3 runs, one CallConfig.runtime_env each
+  main.py                 # 4 runs, one CallConfig.runtime_env each
🤖 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 `@examples/workers/l2/per_task_runtime_env/README.md` at line 53, The layout
comment in the README incorrectly states that main.py performs 3 runs, but the
example actually contains 4 CallConfig.runtime_env configurations (scalar_small,
scalar_large, per_ring, and env_or_default). Update the comment that says "3
runs" to say "4 runs" to accurately reflect the current number of configurations
in the example.
🤖 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 `@examples/workers/l3/per_task_runtime_env/README.md`:
- Around line 18-26: The code snippet unconditionally accesses both scalar form
keys (ring_task_window, ring_heap, ring_dep_pool) and per-ring form keys
(ring_task_windows, ring_heaps, ring_dep_pools) when assigning to
cfg.runtime_env. However, according to the actual task specs in main.py, each
spec contains only one form, not both, so this code will raise KeyError. Make
the assignments conditional by checking which form exists in the spec and only
accessing the appropriate keys for that particular spec, either the scalar form
or the per-ring form, but not both.

---

Outside diff comments:
In `@examples/workers/l2/per_task_runtime_env/README.md`:
- Line 53: The layout comment in the README incorrectly states that main.py
performs 3 runs, but the example actually contains 4 CallConfig.runtime_env
configurations (scalar_small, scalar_large, per_ring, and env_or_default).
Update the comment that says "3 runs" to say "4 runs" to accurately reflect the
current number of configurations in the example.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0baf788b-adb0-449f-a1a8-b9d6bb98bc50

📥 Commits

Reviewing files that changed from the base of the PR and between 78b123e and f147164.

📒 Files selected for processing (4)
  • examples/workers/l2/per_task_runtime_env/README.md
  • examples/workers/l2/per_task_runtime_env/main.py
  • examples/workers/l3/per_task_runtime_env/README.md
  • examples/workers/l3/per_task_runtime_env/main.py

Comment thread examples/workers/l3/per_task_runtime_env/README.md Outdated
ChaoZheng109 added a commit to ChaoZheng109/simpler that referenced this pull request Jun 23, 2026
Address review feedback on hw-native-sys#1122:
- L2 README layout comment said 3 runs; now 4 after adding per_ring.
- L3 README orch_fn snippet indexed both scalar and per-ring keys
  unconditionally, which would KeyError since each spec carries only
  one form. Match the real main.py: iterate RING_FIELDS and set the
  keys the spec actually has.
hw-native-sys#1099 added per-ring array fields (ring_task_windows / ring_heaps /
ring_dep_pools) alongside the scalar runtime_env knobs, but neither
per_task_runtime_env example exercised them.

Extend both the L2 and L3 examples to also cover the per-ring form:
each scope-depth ring (0..3) sized independently. The config helpers
now iterate a RING_FIELDS tuple so a spec dict can carry either the
scalar or the array keys, and the READMEs document the full precedence
chain and the --enable-scope-stats verification path.
@ChaoZheng109 ChaoZheng109 force-pushed the docs/per-ring-runtime-env-examples branch from a13231c to 39af1a4 Compare June 23, 2026 12:28
@ChaoZheng109 ChaoZheng109 merged commit cce3087 into hw-native-sys:main Jun 24, 2026
16 checks passed
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