Skip to content

Add multi-hardware kernel-aware NAS artifact pack#123

Merged
peaktwilight merged 2 commits into
mainfrom
issue-111-nas-multihardware
May 25, 2026
Merged

Add multi-hardware kernel-aware NAS artifact pack#123
peaktwilight merged 2 commits into
mainfrom
issue-111-nas-multihardware

Conversation

@Darkroom4364

@Darkroom4364 Darkroom4364 commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #111

Summary

  • add generated NAS candidates and a size/capacity-constrained latency ranking so the search no longer recommends the smallest architecture purely by latency
  • add python scripts/nas_experiment.py --all-hardware, which emits deterministic A100/T4/H100 JSON and Markdown artifacts
  • include local .noeris/cost-model-training.json calibration metadata and A100 profile overrides when available
  • check in canonical multi-hardware NAS artifacts and link/update docs to clearly separate measured calibration, latency proxy behavior, and speculative quality claims

Verification

  • python3 -m unittest tests.test_arch_cost_model tests.test_public_claim_artifacts
  • python3 -m compileall src/research_engine/arch_cost_model.py scripts/nas_experiment.py tests/test_arch_cost_model.py
  • python3 scripts/check_public_claim_artifacts.py
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Multi-hardware NAS analysis across A100, T4, and H100 with deterministic candidate generation
    • Quality-constrained latency ranking and unified multi-hardware report/pack output (JSON + Markdown)
  • Documentation

    • Added research/results docs describing the kernel-aware NAS multi-hardware latency proxy, hardware mappings, constraint rules, calibration scope, and noted limitations and next steps
  • Tests

    • Added/expanded tests covering candidate generation, quality-constrained filtering, multi-hardware reporting, and CLI pack generation

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 96fe7d39-e1e4-4025-97ff-4cc79c33b1d4

📥 Commits

Reviewing files that changed from the base of the PR and between 93bd42a and 72e716c.

📒 Files selected for processing (5)
  • docs/research/kernel-aware-nas.md
  • docs/results/README.md
  • scripts/nas_experiment.py
  • src/research_engine/arch_cost_model.py
  • tests/test_arch_cost_model.py

📝 Walkthrough

Walkthrough

Adds deterministic multi-hardware NAS reporting (A100/T4/H100) with deterministic candidate generation, quality-proxy constraints, optional calibration-driven profile overrides, extended build_report constrained rankings, markdown/JSON artifact packing, docs, and tests.

Changes

Kernel-aware NAS multi-hardware reporting with quality constraints

Layer / File(s) Summary
Research goal and artifact documentation
docs/research/kernel-aware-nas.md, docs/results/README.md, docs/results/kernel-aware-nas-multihardware.md
Documented --all-hardware mode and canonical multi-hardware artifacts; added "Measured vs Proxy" details, constraints, calibration scope, and limitations.
Top-level script usage
scripts/nas_experiment.py
Updated usage/docstring for --all-hardware and added small imports used by new helpers.
Candidate generation and constraint catalog
scripts/nas_experiment.py
Added SUPPORTED_HARDWARE, QUALITY_CONSTRAINTS, deterministic candidate generators (generate_candidate_configs, all_candidate_configs), source labeling, quality_proxy computation, and per-candidate constraint reports/catalog.
Extended build_report with constrained ranking
scripts/nas_experiment.py
Changed build_report(..., candidate_configs=None, calibration=None) to predict over provided candidates, attach source/quality_proxy/constraints to comparisons, normalize ms_per_mparam_proxy per constraint report, and emit quality_constrained_latency.
Calibration and multi-hardware orchestration
scripts/nas_experiment.py, src/research_engine/arch_cost_model.py
Added build_calibration_metadata to load persisted DB and derive A100 profile overrides, _model_for_hardware to apply profile_overrides, build_multi_hardware_report to produce a deterministic pack across SUPPORTED_HARDWARE, and render_multi_hardware_markdown to render the pack summary.
Cost model profile overrides
src/research_engine/arch_cost_model.py
ArchitectureCostModel.__init__ now accepts `*, profile_overrides: dict[str,float]
Tests: candidates, constraints, multi-hardware CLI
tests/test_arch_cost_model.py
Tests now derive expected candidate counts from all_candidate_configs(), assert generated candidate sources exist, validate quality_constrained_latency and constraint satisfaction, check generated hidden-dim coverage and exclusion of tiny variants, and add multi-hardware pack and CLI artifact tests including missing calibration DB handling.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as nas_experiment CLI
  participant Cal as build_calibration_metadata
  participant Pack as build_multi_hardware_report
  participant Model as ArchitectureCostModel
  participant Report as build_report
  participant Writer as artifact writer

  CLI->>Cal: load calibration DB (optional path)
  CLI->>Pack: request multi-hardware pack (calibration)
  Pack->>Model: construct per-hardware model (profile_overrides)
  Pack->>Report: call build_report(hardware_model, candidate_catalog, calibration)
  Report->>Pack: return per-hardware report (comparisons, quality_constrained_latency)
  Pack->>Writer: write JSON artifact
  CLI->>Writer: render and write markdown via render_multi_hardware_markdown(pack)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • 0sec-labs/noeris#123: Similar changes to scripts/nas_experiment.py adding --all-hardware, deterministic candidate generation, and constrained ranking.
  • 0sec-labs/noeris#110: Related candidate generation and kernel-aware NAS candidate infrastructure used by this PR.
  • 0sec-labs/noeris#108: Prior work expanding JSON report generation and build_report utilities that this PR builds upon.

Poem

🐰 I hopped through profiles, seeds, and seeds anew,

I cataloged candidates — known, seeded, and true.
A100, T4, H100 in one careful run,
Calibration whispers, constraints keep it fun.
Pack and markdown written — a rabbit's small drum!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.63% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding a multi-hardware kernel-aware NAS artifact pack.
Linked Issues check ✅ Passed All requirements from #111 are addressed: multi-hardware command (--all-hardware), quality/size constraints, calibration metadata support, canonical artifacts with documentation, and test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to #111 requirements: CLI additions, candidate generation, multi-hardware reporting, calibration support, documentation updates, and test coverage.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-111-nas-multihardware

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 and usage tips.

@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: 2

🤖 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 `@scripts/nas_experiment.py`:
- Around line 355-360: The code in build_report unconditionally accesses
fastest_by_name["deep_narrow"]["rank"], which can KeyError if candidate_configs
omit "deep_narrow"; change the lookup to guard against missing key (e.g., use
fastest_by_name.get("deep_narrow") and extract "rank" only if present, otherwise
set deep_narrow_unconstrained_rank to None or a sensible default). Update the
return dict entry "deep_narrow_unconstrained_rank" to use this guarded value and
ensure any downstream assumptions handle the None/default case.

In `@src/research_engine/arch_cost_model.py`:
- Line 125: The assignment merging overrides into self.hw currently accepts any
keys/values; before performing self.hw = {**HARDWARE_PROFILES[hardware],
**(profile_overrides or {})} validate profile_overrides: ensure every key exists
in HARDWARE_PROFILES[hardware] (reject/raise on unknown keys to catch typos) and
ensure every override value is a finite positive number (reject/raise on zero,
negative, NaN, or infinity); perform these checks inside the ArchCostModel
constructor (or the method where self.hw is set) and either filter invalid
entries or raise a ValueError with a clear message referencing profile_overrides
and the invalid key(s).
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c888459-970e-412b-bf80-49a40e369fb5

📥 Commits

Reviewing files that changed from the base of the PR and between 9f10ea5 and 93bd42a.

📒 Files selected for processing (7)
  • docs/research/kernel-aware-nas.md
  • docs/results/README.md
  • docs/results/kernel-aware-nas-multihardware.json
  • docs/results/kernel-aware-nas-multihardware.md
  • scripts/nas_experiment.py
  • src/research_engine/arch_cost_model.py
  • tests/test_arch_cost_model.py

Comment thread scripts/nas_experiment.py
if hardware not in HARDWARE_PROFILES:
raise ValueError(f"Unknown hardware {hardware!r}, choose from {list(HARDWARE_PROFILES)}")
self.hw = HARDWARE_PROFILES[hardware]
self.hw = {**HARDWARE_PROFILES[hardware], **(profile_overrides or {})}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate override keys and values before merging calibration data.

Line 125 accepts arbitrary override keys and numeric values without checks. A typoed key is silently ignored, and zero/negative/non-finite values can later cause invalid predictions or division-by-zero in latency calculations.

Proposed fix
@@
     def __init__(
         self,
         hardware: str = "a100",
         *,
         profile_overrides: dict[str, float] | None = None,
     ):
         if hardware not in HARDWARE_PROFILES:
             raise ValueError(f"Unknown hardware {hardware!r}, choose from {list(HARDWARE_PROFILES)}")
-        self.hw = {**HARDWARE_PROFILES[hardware], **(profile_overrides or {})}
+        base_profile = HARDWARE_PROFILES[hardware]
+        overrides = profile_overrides or {}
+
+        unknown = set(overrides) - set(base_profile)
+        if unknown:
+            raise ValueError(
+                f"Unknown profile override keys for {hardware!r}: {sorted(unknown)}"
+            )
+
+        for key, value in overrides.items():
+            if not isinstance(value, (int, float)) or not math.isfinite(float(value)) or float(value) <= 0.0:
+                raise ValueError(
+                    f"Override {key!r} must be a finite positive number, got {value!r}"
+                )
+
+        self.hw = {**base_profile, **{k: float(v) for k, v in overrides.items()}}
         self.hardware = hardware
🤖 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 `@src/research_engine/arch_cost_model.py` at line 125, The assignment merging
overrides into self.hw currently accepts any keys/values; before performing
self.hw = {**HARDWARE_PROFILES[hardware], **(profile_overrides or {})} validate
profile_overrides: ensure every key exists in HARDWARE_PROFILES[hardware]
(reject/raise on unknown keys to catch typos) and ensure every override value is
a finite positive number (reject/raise on zero, negative, NaN, or infinity);
perform these checks inside the ArchCostModel constructor (or the method where
self.hw is set) and either filter invalid entries or raise a ValueError with a
clear message referencing profile_overrides and the invalid key(s).

Resolve conflicts from PR #122 quick fixes merging into main:
- docs/research/kernel-aware-nas.md: combine PR's artifact pack docs with main's generated search description
- scripts/nas_experiment.py: keep both PR's quality constraints/calibration and main's generated_candidate_configs()
- tests/test_arch_cost_model.py: keep both constraint assertions and generated search assertions

none
@peaktwilight peaktwilight merged commit d4222c2 into main May 25, 2026
@peaktwilight peaktwilight deleted the issue-111-nas-multihardware branch May 25, 2026 20:10
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.

[NAS] Add multi-hardware artifact pack and quality constraints

2 participants