rns-engine 0.11.1__tar.gz → 0.11.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. {rns_engine-0.11.1 → rns_engine-0.11.2}/PKG-INFO +1 -1
  2. {rns_engine-0.11.1 → rns_engine-0.11.2}/pyproject.toml +1 -1
  3. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/g4_results.py +19 -14
  4. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/g4_trust.py +84 -6
  5. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine.egg-info/PKG-INFO +1 -1
  6. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine.egg-info/SOURCES.txt +1 -0
  7. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_g4_results.py +8 -4
  8. rns_engine-0.11.2/tests/test_g4_species_labels.py +109 -0
  9. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_g4_trust.py +2 -2
  10. {rns_engine-0.11.1 → rns_engine-0.11.2}/CAPACITY_PLANNING.md +0 -0
  11. {rns_engine-0.11.1 → rns_engine-0.11.2}/CUDA_PARALLEL_LANES.md +0 -0
  12. {rns_engine-0.11.1 → rns_engine-0.11.2}/G4_SERIES1_EVIDENCE.md +0 -0
  13. {rns_engine-0.11.1 → rns_engine-0.11.2}/LICENSE +0 -0
  14. {rns_engine-0.11.1 → rns_engine-0.11.2}/MANIFEST.in +0 -0
  15. {rns_engine-0.11.1 → rns_engine-0.11.2}/PRE_CUDA_READINESS.md +0 -0
  16. {rns_engine-0.11.1 → rns_engine-0.11.2}/README.md +0 -0
  17. {rns_engine-0.11.1 → rns_engine-0.11.2}/benchmarks/weighted_int32_baseline.py +0 -0
  18. {rns_engine-0.11.1 → rns_engine-0.11.2}/colab/T4_EXACT_GEMM_BRINGUP.ipynb +0 -0
  19. {rns_engine-0.11.1 → rns_engine-0.11.2}/setup.cfg +0 -0
  20. {rns_engine-0.11.1 → rns_engine-0.11.2}/setup.py +0 -0
  21. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/__init__.py +0 -0
  22. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/_core.cpp +0 -0
  23. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/_weighted.cpp +0 -0
  24. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/capacity.py +0 -0
  25. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/coefficients.py +0 -0
  26. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/cuda_contract.py +0 -0
  27. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_public_summary.json +0 -0
  28. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part01.b64 +0 -0
  29. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part02.b64 +0 -0
  30. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part03.b64 +0 -0
  31. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part04.b64 +0 -0
  32. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part05.b64 +0 -0
  33. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part06a.b64 +0 -0
  34. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part06b.b64 +0 -0
  35. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part07.b64 +0 -0
  36. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part08a.b64 +0 -0
  37. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part08b.b64 +0 -0
  38. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part09.b64 +0 -0
  39. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part10a.b64 +0 -0
  40. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part10b1.b64 +0 -0
  41. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part10b2.b64 +0 -0
  42. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part10b4.b64 +0 -0
  43. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part11.b64 +0 -0
  44. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part12a.b64 +0 -0
  45. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part12b.b64 +0 -0
  46. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part13.b64 +0 -0
  47. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part14a.b64 +0 -0
  48. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part14b.b64 +0 -0
  49. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part15a.b64 +0 -0
  50. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part15b.b64 +0 -0
  51. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part16a.b64 +0 -0
  52. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part16b.b64 +0 -0
  53. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part17a.b64 +0 -0
  54. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part17b1.b64 +0 -0
  55. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part17b2a.b64 +0 -0
  56. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part17b2b1.b64 +0 -0
  57. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part17b2b2.b64 +0 -0
  58. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_replay.part17b2b3.b64 +0 -0
  59. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/data/g4s1_t4_runtime.json +0 -0
  60. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/engine.py +0 -0
  61. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/exact_gemm.py +0 -0
  62. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/g4_benchmark.py +0 -0
  63. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/lane_plan.py +0 -0
  64. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/pre_cuda.py +0 -0
  65. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/rail_planning.py +0 -0
  66. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/signed.py +0 -0
  67. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/weighted.py +0 -0
  68. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine/wide.py +0 -0
  69. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine.egg-info/dependency_links.txt +0 -0
  70. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine.egg-info/entry_points.txt +0 -0
  71. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine.egg-info/not-zip-safe +0 -0
  72. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine.egg-info/requires.txt +0 -0
  73. {rns_engine-0.11.1 → rns_engine-0.11.2}/src/rns_engine.egg-info/top_level.txt +0 -0
  74. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_capacity.py +0 -0
  75. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_coefficients.py +0 -0
  76. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_cuda_contract.py +0 -0
  77. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_exact_gemm.py +0 -0
  78. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_g4_benchmark.py +0 -0
  79. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_packaging.py +0 -0
  80. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_pre_cuda.py +0 -0
  81. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_pre_cuda_assets.py +0 -0
  82. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_rail_planning.py +0 -0
  83. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_rns.py +0 -0
  84. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_session.py +0 -0
  85. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_signed.py +0 -0
  86. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_weighted.py +0 -0
  87. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_weighted_benchmark.py +0 -0
  88. {rns_engine-0.11.1 → rns_engine-0.11.2}/tests/test_wide.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rns_engine
3
- Version: 0.11.1
3
+ Version: 0.11.2
4
4
  Summary: Exact RNS engine with session/cache API.
5
5
  Author: Evan Wesley
6
6
  License-Expression: AGPL-3.0-only
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
11
11
 
12
12
  [project]
13
13
  name = "rns_engine"
14
- version = "0.11.1"
14
+ version = "0.11.2"
15
15
  description = "Exact RNS engine with session/cache API."
16
16
  readme = "README.md"
17
17
  requires-python = ">=3.10,<3.15"
@@ -34,29 +34,31 @@ def _pct(value: float) -> str:
34
34
 
35
35
 
36
36
  def _print_integer(campaign: dict, stream: TextIO) -> None:
37
- print("[Exact integer / NVIDIA FP16-input cuBLASLt]", file=stream)
37
+ print("=== G4 INTEGERS vs NVIDIA FP16 cuBLASLt ===", file=stream)
38
+ print("Frozen Series 1 integer test — separate from the rational test below.", file=stream)
38
39
  print(
39
- f"Exact wins: {campaign['exact_wins']} / {campaign['declared_shapes']} "
40
+ f"G4 exact integers faster: {campaign['exact_wins']} / {campaign['declared_shapes']} "
40
41
  f"({_pct(campaign['exact_win_rate'])})",
41
42
  file=stream,
42
43
  )
43
- print(f"NVIDIA wins: {campaign['floating_wins']}", file=stream)
44
- print("Exact replay before + after timing: PASS on all 1,024 shapes", file=stream)
45
- print(f"Median speedup among exact wins: {campaign['exact_win_speedup_median']:.3f}x", file=stream)
46
- print(f"Best exact-win speedup: {campaign['best_exact_win_speedup']:.3f}x", file=stream)
44
+ print(f"NVIDIA FP16 faster: {campaign['floating_wins']} / {campaign['declared_shapes']}", file=stream)
45
+ print("Integer exactness: replay before + after timing PASS on all 1,024 shapes", file=stream)
46
+ print(f"Median integer speedup among G4 wins: {campaign['exact_win_speedup_median']:.3f}x", file=stream)
47
+ print(f"Best integer G4 speedup: {campaign['best_exact_win_speedup']:.3f}x", file=stream)
47
48
 
48
49
 
49
50
  def _print_rational(campaign: dict, stream: TextIO) -> None:
50
- print("[Exact rational / NVIDIA FP16]", file=stream)
51
+ print("=== G4 RATIONALS vs NVIDIA FP16 cuBLASLt ===", file=stream)
52
+ print("Frozen Series 1 rational test — separate from the integer test above.", file=stream)
51
53
  print(
52
- f"Certified exact wins: {campaign['certified_exact_wins']} / {campaign['target_shapes']} "
54
+ f"G4 exact rationals faster (certified): {campaign['certified_exact_wins']} / {campaign['target_shapes']} "
53
55
  f"({_pct(campaign['certified_exact_win_rate'])})",
54
56
  file=stream,
55
57
  )
56
- print(f"Remaining unresolved at archive freeze: {campaign['remaining_unresolved']}", file=stream)
57
- print("Certified winners: non-integer inputs PASS | range proof PASS | FP16 value-set proof PASS", file=stream)
58
- print(f"Median certified speedup: {campaign['certified_speedup_median']:.3f}x", file=stream)
59
- print(f"Best certified speedup: {campaign['best_certified_speedup']:.3f}x", file=stream)
58
+ print(f"Rational shapes unresolved at archive freeze: {campaign['remaining_unresolved']}", file=stream)
59
+ print("Certified rational winners: non-integer inputs PASS | range proof PASS | FP16 value-set proof PASS", file=stream)
60
+ print(f"Median rational speedup among certified G4 wins: {campaign['certified_speedup_median']:.3f}x", file=stream)
61
+ print(f"Best certified rational G4 speedup: {campaign['best_certified_speedup']:.3f}x", file=stream)
60
62
 
61
63
 
62
64
  def g4_results(
@@ -97,6 +99,7 @@ def g4_results(
97
99
  if display:
98
100
  out = stream if stream is not None else sys.stdout
99
101
  print("=== G4 SERIES 1 — TESLA T4 RESULTS ===", file=out)
102
+ print("Two separate tests are reported below. Do not combine their scores.", file=out)
100
103
  print(file=out)
101
104
  if selected in ("all", "integer_fp16_input_clean_sweep"):
102
105
  _print_integer(evidence["campaigns"]["integer_fp16_input_clean_sweep"], out)
@@ -106,9 +109,11 @@ def g4_results(
106
109
  _print_rational(evidence["campaigns"]["dynamic_exact_rational"], out)
107
110
  if selected == "all":
108
111
  print(file=out)
109
- print("91.60% integer and 84.96% rational are separate benchmark results.", file=out)
112
+ print("INTEGER RESULT: 938 / 1024 = 91.60%", file=out)
113
+ print("RATIONAL RESULT: 870 / 1024 = 84.96%", file=out)
114
+ print("These are separate benchmark results against NVIDIA FP16 cuBLASLt.", file=out)
110
115
 
111
116
  return result
112
117
 
113
118
 
114
- __all__ = ["g4_results"]
119
+ __all__ = ["g4_results"]
@@ -24,6 +24,54 @@ from .g4_benchmark import (
24
24
 
25
25
  _TRUST_SCHEMA = "RNS-ENGINE-G4S1-TRUST-PACK-1"
26
26
 
27
+ _LIVE_REPORT_REPLACEMENTS = (
28
+ ("EXACTNESS - FRESH RUN", "G4 RATIONALS - EXACTNESS - FRESH RUN"),
29
+ (
30
+ "SPEED - FRESH RUN DIRECTLY AGAINST NVIDIA FP16",
31
+ "G4 RATIONALS - SPEED vs NVIDIA FP16 - FRESH RUN",
32
+ ),
33
+ ("REPRODUCIBILITY", "G4 RATIONALS - REPRODUCIBILITY"),
34
+ ("Exact rational calculations correct:", "G4 rational calculations correct:"),
35
+ ("Exact rational faster:", "G4 RATIONALS faster than NVIDIA FP16:"),
36
+ ("NVIDIA FP16 faster:", "NVIDIA FP16 faster than G4 RATIONALS:"),
37
+ ("Too close to call:", "G4 RATIONALS / NVIDIA FP16 statistical ties:"),
38
+ ("Median speedup when exact wins:", "Median speedup when G4 RATIONALS win:"),
39
+ (
40
+ "Same winner/tie result as original:",
41
+ "RATIONAL winner/tie classification matches original RATIONAL benchmark:",
42
+ ),
43
+ )
44
+
45
+
46
+ class _RationalLiveReportStream:
47
+ """Relabel the existing live report without touching benchmark math or progress output."""
48
+
49
+ def __init__(self, target: TextIO):
50
+ self._target = target
51
+
52
+ @staticmethod
53
+ def _replace(text: str) -> str:
54
+ for old, new in _LIVE_REPORT_REPLACEMENTS:
55
+ text = text.replace(old, new)
56
+ return text
57
+
58
+ def _rewrite_line(self, line: str) -> str:
59
+ newline = "\n" if line.endswith("\n") else ""
60
+ body = line[:-1] if newline else line
61
+ if body.startswith("| ") and body.endswith(" |"):
62
+ inner_width = len(body) - 4
63
+ content = body[2:-2].rstrip()
64
+ content = self._replace(content)
65
+ return "| " + content[:inner_width].ljust(inner_width) + " |" + newline
66
+ return self._replace(body) + newline
67
+
68
+ def write(self, text: str) -> int:
69
+ rewritten = "".join(self._rewrite_line(line) for line in text.splitlines(keepends=True))
70
+ return self._target.write(rewritten)
71
+
72
+ def flush(self) -> None:
73
+ self._target.flush()
74
+
27
75
 
28
76
  def _utc_now() -> str:
29
77
  return datetime.now(timezone.utc).isoformat(timespec="seconds").replace("+00:00", "Z")
@@ -134,6 +182,28 @@ def _build_cuda_summary(build_nvcc: str) -> str:
134
182
  return "unavailable"
135
183
 
136
184
 
185
+ def _print_test_scope(stream: TextIO) -> None:
186
+ _box(
187
+ "G4 SERIES 1 - TWO SEPARATE TESTS",
188
+ [
189
+ "G4 INTEGERS vs NVIDIA FP16 cuBLASLt: frozen result 938 / 1024 (91.60%)",
190
+ "G4 RATIONALS vs NVIDIA FP16 cuBLASLt: frozen result 870 / 1024 (84.96%)",
191
+ "",
192
+ "LIVE BENCHMARK BELOW: G4 RATIONALS vs NVIDIA FP16 ONLY.",
193
+ "g4_benchmark() does not rerun the integer benchmark; the integer score is context only.",
194
+ ],
195
+ stream,
196
+ width=112,
197
+ )
198
+
199
+
200
+ def _add_species_labels(result: dict) -> None:
201
+ result["live_test"] = "G4_RATIONALS_vs_NVIDIA_FP16_cuBLASLt"
202
+ summary = result.setdefault("summary", {})
203
+ if "frozen_decision_matches" in summary:
204
+ summary["rational_frozen_decision_matches"] = summary["frozen_decision_matches"]
205
+
206
+
137
207
  def _make_trust_pack(
138
208
  result: dict,
139
209
  *,
@@ -154,6 +224,7 @@ def _make_trust_pack(
154
224
  "schema": _TRUST_SCHEMA,
155
225
  "series": result.get("series"),
156
226
  "campaign": result.get("campaign"),
227
+ "live_test": result.get("live_test", "G4_RATIONALS_vs_NVIDIA_FP16_cuBLASLt"),
157
228
  "mode": result.get("mode"),
158
229
  "started_utc": started_utc,
159
230
  "completed_utc": completed_utc,
@@ -172,7 +243,7 @@ def _make_trust_pack(
172
243
  "gpu_state_before": gpu_before,
173
244
  "gpu_state_after": gpu_after,
174
245
  "protocol": {
175
- "comparison": "exact rational GEMM vs NVIDIA FP16 cuBLASLt",
246
+ "comparison": "G4 exact rational GEMM vs NVIDIA FP16 cuBLASLt",
176
247
  "paired_timing_blocks_per_shape": _BLOCKS,
177
248
  "bootstrap_resamples_per_shape": _BOOTSTRAP_REPETITIONS,
178
249
  "bootstrap_confidence_interval": 0.95,
@@ -213,8 +284,9 @@ def _print_trust_pack(trust: dict, stream: TextIO) -> None:
213
284
  environment = trust["environment"]
214
285
 
215
286
  _box(
216
- "TRUST PACK - CRYPTOGRAPHIC RUN RECEIPT",
287
+ "TRUST PACK - G4 RATIONAL RUN RECEIPT",
217
288
  [
289
+ "Live test: G4 RATIONALS vs NVIDIA FP16 cuBLASLt",
218
290
  f"Environment: {environment['name']} | rns_engine {package['version']} | release {package['release_tag']}",
219
291
  f"Python: {environment['python']} | CUDA reported by NVIDIA: {environment['current_cuda_reported_by_nvidia_smi']}",
220
292
  f"GPU: {gpu.get('name', 'unknown')} | compute capability {gpu.get('compute_capability', 'unknown')} | driver {gpu.get('driver_version', 'unknown')}",
@@ -223,7 +295,7 @@ def _print_trust_pack(trust: dict, stream: TextIO) -> None:
223
295
  f"GPU state after: {_format_gpu_state(trust['gpu_state_after'])}",
224
296
  "",
225
297
  f"Protocol: {protocol['paired_timing_blocks_per_shape']} paired timing blocks/shape | {protocol['bootstrap_resamples_per_shape']:,} bootstrap resamples/shape | 95% CI",
226
- f"Exactness gate: {exactness['rows_exact']} / {exactness['rows_total']} exact | runtime errors {exactness['runtime_errors']} | exactness failures {exactness['exact_replay_failures']}",
298
+ f"Rational exactness gate: {exactness['rows_exact']} / {exactness['rows_total']} exact | runtime errors {exactness['runtime_errors']} | exactness failures {exactness['exact_replay_failures']}",
227
299
  "",
228
300
  f"Replay binary SHA-256: {runtime['binary_sha256']}",
229
301
  f"Replay payload SHA-256: {runtime['payload_sha256']}",
@@ -244,7 +316,7 @@ def g4_benchmark(
244
316
  display: bool = True,
245
317
  stream: TextIO | None = None,
246
318
  ) -> dict:
247
- """Run the public G4 benchmark and append a cryptographic trust receipt."""
319
+ """Run the public rational G4 benchmark and append a cryptographic trust receipt."""
248
320
  out = stream if stream is not None else sys.stdout
249
321
  started_utc = _utc_now()
250
322
  environment = _environment_name()
@@ -252,7 +324,13 @@ def g4_benchmark(
252
324
  current_cuda = _current_cuda_version()
253
325
  gpu_before = _gpu_state_snapshot()
254
326
 
255
- result = _core_g4_benchmark(mode, display=display, stream=out)
327
+ if display:
328
+ _print_test_scope(out)
329
+ print(file=out)
330
+
331
+ live_out = _RationalLiveReportStream(out) if display else out
332
+ result = _core_g4_benchmark(mode, display=display, stream=live_out)
333
+ _add_species_labels(result)
256
334
 
257
335
  gpu_after = _gpu_state_snapshot()
258
336
  completed_utc = _utc_now()
@@ -275,4 +353,4 @@ def g4_benchmark(
275
353
  return result
276
354
 
277
355
 
278
- __all__ = ["g4_benchmark"]
356
+ __all__ = ["g4_benchmark"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rns_engine
3
- Version: 0.11.1
3
+ Version: 0.11.2
4
4
  Summary: Exact RNS engine with session/cache API.
5
5
  Author: Evan Wesley
6
6
  License-Expression: AGPL-3.0-only
@@ -72,6 +72,7 @@ tests/test_cuda_contract.py
72
72
  tests/test_exact_gemm.py
73
73
  tests/test_g4_benchmark.py
74
74
  tests/test_g4_results.py
75
+ tests/test_g4_species_labels.py
75
76
  tests/test_g4_trust.py
76
77
  tests/test_packaging.py
77
78
  tests/test_pre_cuda.py
@@ -28,15 +28,19 @@ def test_g4_results_keeps_integer_and_rational_claims_distinct():
28
28
  assert rational["all_certified_fp16_value_set_proved"] is True
29
29
 
30
30
 
31
- def test_g4_results_report_labels_both_percentages():
31
+ def test_g4_results_report_labels_both_species_and_percentages():
32
32
  stream = io.StringIO()
33
33
  g4_results(stream=stream)
34
34
  text = stream.getvalue()
35
- assert "938 / 1024 (91.60%)" in text
36
- assert "870 / 1024 (84.96%)" in text
35
+ assert "G4 INTEGERS vs NVIDIA FP16 cuBLASLt" in text
36
+ assert "G4 RATIONALS vs NVIDIA FP16 cuBLASLt" in text
37
+ assert "G4 exact integers faster: 938 / 1024 (91.60%)" in text
38
+ assert "G4 exact rationals faster (certified): 870 / 1024 (84.96%)" in text
39
+ assert "INTEGER RESULT: 938 / 1024 = 91.60%" in text
40
+ assert "RATIONAL RESULT: 870 / 1024 = 84.96%" in text
37
41
  assert "separate benchmark results" in text
38
42
 
39
43
 
40
44
  def test_g4_results_bad_campaign_rejected():
41
45
  with pytest.raises(ValueError):
42
- g4_results("series2", display=False)
46
+ g4_results("series2", display=False)
@@ -0,0 +1,109 @@
1
+ from copy import deepcopy
2
+ from io import StringIO
3
+
4
+ import rns_engine.g4_trust as trust
5
+
6
+
7
+ def _result():
8
+ return {
9
+ "schema": "RNS-ENGINE-G4S1-LIVE-BENCHMARK-2",
10
+ "series": 1,
11
+ "campaign": "dynamic_exact_rational_vs_fp16",
12
+ "mode": "full",
13
+ "gpu": {"name": "Tesla T4", "compute_capability": "7.5", "driver_version": "580.82.07"},
14
+ "runtime": {
15
+ "binary_sha256": "a" * 64,
16
+ "payload_sha256": "b" * 64,
17
+ "source_archive_sha256": "c" * 64,
18
+ "build_nvcc": "Cuda compilation tools, release 12.8, V12.8.93",
19
+ "config_provenance": {},
20
+ },
21
+ "timing_seconds": {"gpu_test": 1.0, "result_verification": 1.0, "total": 2.0},
22
+ "summary": {
23
+ "shapes_run": 2,
24
+ "runtime_errors": 0,
25
+ "exact_replay_failures": 0,
26
+ "live_exact_wins": 1,
27
+ "live_floating_wins": 1,
28
+ "live_statistical_ties": 0,
29
+ "frozen_decision_matches": 2,
30
+ },
31
+ "rows": [
32
+ {"shape_id": "A", "exact_replay_passed": True, "live_decision": "EXACT_WIN"},
33
+ {"shape_id": "B", "exact_replay_passed": True, "live_decision": "FLOATING_WIN"},
34
+ ],
35
+ }
36
+
37
+
38
+ def _snapshot():
39
+ return {
40
+ "available": True,
41
+ "pstate": "P0",
42
+ "temperature_c": "45",
43
+ "power_w": "38.50",
44
+ "sm_clock_mhz": "1590",
45
+ "memory_clock_mhz": "5001",
46
+ }
47
+
48
+
49
+ def _fake_core(mode, *, display, stream):
50
+ if display:
51
+ trust._box(
52
+ "EXACTNESS - FRESH RUN",
53
+ ["Exact rational calculations correct: 2 / 2", "Result: PASS"],
54
+ stream,
55
+ )
56
+ trust._box(
57
+ "SPEED - FRESH RUN DIRECTLY AGAINST NVIDIA FP16",
58
+ [
59
+ "Exact rational faster: 1 / 2 (50.00%)",
60
+ "NVIDIA FP16 faster: 1 / 2 (50.00%)",
61
+ "Too close to call: 0 / 2 (0.00%)",
62
+ "Median speedup when exact wins: 1.400x",
63
+ "Median speedup including rational bookkeeping: 1.350x",
64
+ ],
65
+ stream,
66
+ )
67
+ trust._box(
68
+ "REPRODUCIBILITY",
69
+ [
70
+ "Same winner/tie result as original: 2 / 2 (100.00%)",
71
+ "Validated replay binary SHA-256: " + "a" * 64,
72
+ "Total elapsed: 00:02",
73
+ ],
74
+ stream,
75
+ )
76
+ return deepcopy(_result())
77
+
78
+
79
+ def test_live_report_is_explicitly_rational(monkeypatch):
80
+ monkeypatch.setattr(trust, "_core_g4_benchmark", _fake_core)
81
+ monkeypatch.setattr(trust, "_gpu_state_snapshot", _snapshot)
82
+ monkeypatch.setattr(trust, "_environment_name", lambda: "Google Colab")
83
+ monkeypatch.setattr(trust, "_package_version", lambda: "0.11.2")
84
+ monkeypatch.setattr(trust, "_current_cuda_version", lambda: "12.8")
85
+ times = iter(["2026-08-09T06:00:00Z", "2026-08-09T06:10:00Z"])
86
+ monkeypatch.setattr(trust, "_utc_now", lambda: next(times))
87
+
88
+ output = StringIO()
89
+ result = trust.g4_benchmark("full", display=True, stream=output)
90
+ text = output.getvalue()
91
+
92
+ assert result["live_test"] == "G4_RATIONALS_vs_NVIDIA_FP16_cuBLASLt"
93
+ assert result["summary"]["rational_frozen_decision_matches"] == 2
94
+ assert "G4 INTEGERS vs NVIDIA FP16 cuBLASLt" in text
95
+ assert "G4 RATIONALS vs NVIDIA FP16 cuBLASLt" in text
96
+ assert "LIVE BENCHMARK BELOW: G4 RATIONALS vs NVIDIA FP16 ONLY." in text
97
+
98
+ assert "G4 RATIONALS - EXACTNESS - FRESH RUN" in text
99
+ assert "G4 rational calculations correct: 2 / 2" in text
100
+ assert "G4 RATIONALS - SPEED vs NVIDIA FP16 - FRESH RUN" in text
101
+ assert "G4 RATIONALS faster than NVIDIA FP16: 1 / 2" in text
102
+ assert "NVIDIA FP16 faster than G4 RATIONALS:" in text
103
+ assert "G4 RATIONALS / NVIDIA FP16 statistical ties:" in text
104
+ assert "G4 RATIONALS - REPRODUCIBILITY" in text
105
+ assert "RATIONAL winner/tie classification matches original RATIONAL benchmark:" in text
106
+
107
+ assert "Same winner/tie result as original:" not in text
108
+ assert "Too close to call:" not in text
109
+ assert "TRUST PACK - G4 RATIONAL RUN RECEIPT" in text
@@ -110,10 +110,10 @@ def test_public_wrapper_adds_and_prints_trust_pack(monkeypatch):
110
110
  text = output.getvalue()
111
111
 
112
112
  assert "trust_pack" in result
113
- assert "TRUST PACK - CRYPTOGRAPHIC RUN RECEIPT" in text
113
+ assert "TRUST PACK - G4 RATIONAL RUN RECEIPT" in text
114
114
  assert "Environment: Google Colab | rns_engine 0.11.1 | release v0.11.1" in text
115
115
  assert "Replay binary SHA-256: " + "a" * 64 in text
116
116
  assert "Replay payload SHA-256: " + "b" * 64 in text
117
117
  assert "Source archive SHA-256: " + "c" * 64 in text
118
118
  assert result["trust_pack"]["result_rows_sha256"] in text
119
- assert result["trust_pack"]["run_receipt_sha256"] in text
119
+ assert result["trust_pack"]["run_receipt_sha256"] in text
File without changes
File without changes
File without changes
File without changes
File without changes