GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge remote-tracking branch 'origin/main' into feat/mps-backend · cslht11/diffct@0609753

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • ci.yml
    • formal.yml
  • CHANGELOG.md
  • diffct
    • geometry.py
  • docs/source
    • _static
      • custom.css
    • _templates
      • sidebar-site-nav.html
    • conf.py
    • index.rst
  • formal
    • README.md
    • tla
      • .gitignore
      • AutogradRouting.small.cfg
      • AutogradRouting.tla
      • BINDINGS.md
      • BudgetAgreement.small.cfg
      • BudgetAgreement.tla
      • Distributed.large.cfg
      • Distributed.small.cfg
      • Distributed.tla
      • MemoryEnvelope.small.cfg
      • MemoryEnvelope.symbolic.cfg
      • MemoryEnvelope.tla
      • NativeAdmission.small.cfg
      • NativeAdmission.tla
      • ObservedProtocol.tla
      • PipelineLifecycle.small.cfg
      • PipelineLifecycle.tla
      • README.md
      • RecomputeOrder.small.cfg
      • RecomputeOrder.tla
      • RecomputeTrace.tla
      • ThreadSafety.small.cfg
      • ThreadSafety.tla
      • TraceValidation.tla
      • check.py
      • collect_trace.py
      • tools.json
      • validate_trace.py
  • tests
    • test_geometry_input_validation.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/ci.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+39-2Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,39 @@ concurrency:
1414
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
1515

1616
jobs:
17+
changes:
18+
name: Changed files
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 5
21+
outputs:
22+
code: ${{ steps.filter.outputs.code }}
23+
steps:
24+
- uses: actions/checkout@v7
25+
with:
26+
persist-credentials: false
27+
fetch-depth: 0
28+
# A pull request that changes only files under docs/ skips the package and test jobs.
29+
# Pushes to main and release tags run every job.
30+
- id: filter
31+
env:
32+
EVENT: ${{ github.event_name }}
33+
BASE: ${{ github.event.pull_request.base.sha }}
34+
HEAD: ${{ github.event.pull_request.head.sha }}
35+
run: |
36+
if [ "$EVENT" != pull_request ]; then
37+
echo code=true >> "$GITHUB_OUTPUT"
38+
exit 0
39+
fi
40+
# Renames list both paths. Paths with non-ASCII bytes stay unquoted.
41+
git -c core.quotePath=false diff --no-renames --name-only "$BASE...$HEAD" > changed.txt
42+
cat changed.txt
43+
if grep -qv '^docs/' changed.txt; then code=true; else code=false; fi
44+
echo "code=$code" >> "$GITHUB_OUTPUT"
45+
1746
lint:
1847
name: Python error checks
48+
needs: changes
49+
if: needs.changes.outputs.code == 'true'
1950
runs-on: ubuntu-latest
2051
timeout-minutes: 5
2152
steps:
@@ -33,6 +64,8 @@ jobs:
3364

3465
package:
3566
name: Release metadata and distributions
67+
needs: changes
68+
if: needs.changes.outputs.code == 'true'
3669
runs-on: ubuntu-latest
3770
timeout-minutes: 10
3871
steps:
@@ -321,7 +354,7 @@ jobs:
321354
required:
322355
name: CI passed
323356
if: always()
324-
needs: [lint, package, cpu, clean-cpu, docs]
357+
needs: [changes, lint, package, cpu, clean-cpu, docs]
325358
runs-on: ubuntu-latest
326359
timeout-minutes: 2
327360
steps:
@@ -333,6 +366,10 @@ jobs:
333366
import json
334367
import os
335368
results = json.loads(os.environ['RESULTS'])
336-
failed = {name: job['result'] for name, job in results.items() if job['result'] != 'success'}
369+
# A documentation-only pull request skips these jobs on purpose.
370+
docs_only = results['changes']['outputs'].get('code') == 'false'
371+
skippable = {'lint', 'package', 'cpu', 'clean-cpu'} if docs_only else set()
372+
failed = {name: job['result'] for name, job in results.items()
373+
if job['result'] != 'success' and not (name in skippable and job['result'] == 'skipped')}
337374
assert not failed, failed
338375
PY
Collapse file

‎.github/workflows/formal.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/formal.yml
+76Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,84 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18+
changes:
19+
name: Changed files
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 5
22+
outputs:
23+
code: ${{ steps.filter.outputs.code }}
24+
steps:
25+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
26+
with:
27+
persist-credentials: false
28+
fetch-depth: 0
29+
# The models and property tests do not read the documentation. A pull request that
30+
# changes only files under docs/ skips them. Every other event runs them.
31+
- id: filter
32+
env:
33+
EVENT: ${{ github.event_name }}
34+
BASE: ${{ github.event.pull_request.base.sha }}
35+
HEAD: ${{ github.event.pull_request.head.sha }}
36+
run: |
37+
if [ "$EVENT" != pull_request ]; then
38+
echo code=true >> "$GITHUB_OUTPUT"
39+
exit 0
40+
fi
41+
# Renames list both paths. Paths with non-ASCII bytes stay unquoted.
42+
git -c core.quotePath=false diff --no-renames --name-only "$BASE...$HEAD" > changed.txt
43+
cat changed.txt
44+
if grep -qv '^docs/' changed.txt; then code=true; else code=false; fi
45+
echo "code=$code" >> "$GITHUB_OUTPUT"
46+
47+
tla:
48+
name: MODEL CHECK / TRACE VALIDATION
49+
needs: changes
50+
if: needs.changes.outputs.code == 'true'
51+
runs-on: ubuntu-latest
52+
timeout-minutes: 10
53+
env:
54+
PYTHONDONTWRITEBYTECODE: "1"
55+
NUMBA_ENABLE_CUDASIM: "1"
56+
OMP_NUM_THREADS: "1"
57+
TORCH_NCCL_TRACE_BUFFER_SIZE: "100000"
58+
TORCH_FR_BUFFER_SIZE: "100000"
59+
TORCH_DISTRIBUTED_DEBUG: DETAIL
60+
steps:
61+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
62+
- uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
63+
with:
64+
distribution: temurin
65+
java-version: "21"
66+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
67+
with:
68+
python-version: "3.12"
69+
cache: pip
70+
cache-dependency-path: formal/requirements.txt
71+
- name: Install CPU trace dependencies
72+
run: |
73+
python -m pip install torch==2.14.1 --index-url https://download.pytorch.org/whl/cpu
74+
python -m pip install -r formal/requirements.txt
75+
- name: Collect real CPU and Gloo executions
76+
run: python formal/tla/collect_trace.py --out .validation/formal-tla/traces --hybrid
77+
- name: Check protocols, mutations, and observed executions
78+
run: >-
79+
python formal/tla/check.py --large
80+
--cache .cache/formal-tla --out .validation/formal-tla/checks
81+
--trace-dir .validation/formal-tla/traces
82+
- name: Retain model and trace evidence
83+
if: always()
84+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
85+
with:
86+
name: formal-tla
87+
path: |
88+
.validation/formal-tla
89+
!.validation/formal-tla/**/*.states/**
90+
include-hidden-files: true
91+
if-no-files-found: error
1892
formal:
1993
name: PROOF models / BOUNDED simulator / PROPERTY TEST
94+
needs: changes
95+
if: needs.changes.outputs.code == 'true'
2096
runs-on: ubuntu-latest
2197
timeout-minutes: 15
2298
env:
Collapse file

‎CHANGELOG.md‎

Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Trajectory constructors reject degenerate inputs instead of building NaN or empty geometry: zero or non-finite `ray_dir_fn` directions in `custom_trajectory_2d_parallel`, `random_trajectory_3d` sources at the isocenter, and view counts that are not positive integers (`TypeError` for floats and booleans, `ValueError` for counts below 1). Explicit angle tensors are still accepted. Thanks to @cslht11 ([#56](https://github.com/sypsyp97/diffct/pull/56)).
13+
1014
## [2.4.4] - 2026-10-25
1115

1216
### Added
Collapse file

‎diffct/geometry.py‎

Copy file name to clipboardExpand all lines: diffct/geometry.py
+45-3Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import math
8+
import operator
89
import torch
910

1011
from .utils import _work_dtype
@@ -93,22 +94,50 @@ def _circular_angles(n_views, start_angle, end_angle, device, dtype):
9394
if not torch.isfinite(n_views).all().item():
9495
raise ValueError("angles must be finite")
9596
return n_views, n_views.numel(), n_views.device, n_views.dtype
97+
_check_n_views(n_views)
9698
step = (end_angle - start_angle) / n_views
9799
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
98100
return angles, n_views, device, dtype
99101

100102

101-
def _check_source_positions(src_pos):
103+
def _check_source_positions(src_pos, what="source_path_fn"):
102104
"""Reject non-finite sources and sources at the isocenter, which have no viewing direction."""
103105
if not torch.isfinite(src_pos).all():
104-
raise ValueError("source_path_fn returned non-finite source positions")
106+
raise ValueError(f"{what} returned non-finite source positions")
105107
if (torch.linalg.vector_norm(src_pos.detach(), dim=1) == 0).any():
106108
raise ValueError(
107-
"source_path_fn returned a source at the isocenter; every source needs a "
109+
f"{what} returned a source at the isocenter; every source needs a "
108110
"nonzero distance from the origin"
109111
)
110112

111113

114+
def _check_n_views(n_views):
115+
"""Reject view counts that are not positive integers.
116+
117+
A float count would space ``arange(ceil(n))`` views by ``span / n``, and a
118+
nonpositive count builds an empty trajectory or divides by zero.
119+
"""
120+
try:
121+
count = operator.index(n_views)
122+
except TypeError:
123+
count = None
124+
if count is None or isinstance(n_views, bool):
125+
raise TypeError(f"n_views must be a positive integer, got {n_views!r}")
126+
if count < 1:
127+
raise ValueError(f"n_views must be a positive integer, got {n_views!r}")
128+
129+
130+
def _check_ray_directions(ray_dir):
131+
"""Reject non-finite and zero ray directions, which normalize to NaN."""
132+
if not torch.isfinite(ray_dir).all():
133+
raise ValueError("ray_dir_fn returned non-finite ray directions")
134+
if (torch.linalg.vector_norm(ray_dir.detach(), dim=1) == 0).any():
135+
raise ValueError(
136+
"ray_dir_fn returned a zero ray direction; every view needs a "
137+
"nonzero direction vector"
138+
)
139+
140+
112141
def circular_trajectory_3d(n_views, sid, sdd, start_angle=0.0, end_angle=None, device='cuda', dtype=torch.float32):
113142
"""Generate circular trajectory geometry for cone-beam CT.
114143
@@ -295,6 +324,8 @@ def random_trajectory_3d(n_views, sid_mean, sdd_mean, sid_std=0.0, pos_std=0.0,
295324
det_u_vec = det_u_vec / torch.norm(det_u_vec, dim=1, keepdim=True)
296325
det_v_vec = det_v_vec / torch.norm(det_v_vec, dim=1, keepdim=True)
297326

327+
_check_source_positions(src_pos, "random_trajectory_3d")
328+
298329
return src_pos, det_center, det_u_vec, det_v_vec
299330

300331

@@ -343,6 +374,7 @@ def spiral_trajectory_3d(n_views, sid, sdd, z_range=100.0, n_turns=2.0,
343374
"""
344375
# Generate angles for spiral motion
345376
end_angle = start_angle + 2 * math.pi * n_turns
377+
_check_n_views(n_views)
346378
step = (end_angle - start_angle) / n_views
347379
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
348380

@@ -428,6 +460,7 @@ def sinusoidal_trajectory_3d(n_views, sid, sdd, amplitude=50.0, frequency=2.0,
428460
"""
429461
# Generate angles
430462
end_angle = start_angle + 2 * math.pi
463+
_check_n_views(n_views)
431464
step = (end_angle - start_angle) / n_views
432465
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
433466

@@ -514,6 +547,7 @@ def saddle_trajectory_3d(n_views, sid, sdd, z_amplitude=50.0, radial_amplitude=3
514547
"""
515548
# Generate angles
516549
end_angle = start_angle + 2 * math.pi
550+
_check_n_views(n_views)
517551
step = (end_angle - start_angle) / n_views
518552
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
519553

@@ -610,6 +644,7 @@ def custom_trajectory_3d(n_views, sid, sdd,
610644
"""
611645
# Generate angles
612646
end_angle = start_angle + 2 * math.pi
647+
_check_n_views(n_views)
613648
step = (end_angle - start_angle) / n_views
614649
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
615650

@@ -755,6 +790,7 @@ def sinusoidal_trajectory_2d_fan(n_views, sid, sdd, amplitude=50.0, frequency=2.
755790
"""
756791
# Generate angles
757792
end_angle = start_angle + 2 * math.pi
793+
_check_n_views(n_views)
758794
step = (end_angle - start_angle) / n_views
759795
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
760796

@@ -838,6 +874,7 @@ def custom_trajectory_2d_fan(n_views, sid, sdd,
838874
"""
839875
# Generate angles
840876
end_angle = start_angle + 2 * math.pi
877+
_check_n_views(n_views)
841878
step = (end_angle - start_angle) / n_views
842879
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
843880

@@ -982,6 +1019,7 @@ def sinusoidal_trajectory_2d_parallel(n_views, amplitude=50.0, frequency=2.0,
9821019
"""
9831020
# Generate angles
9841021
end_angle = start_angle + math.pi
1022+
_check_n_views(n_views)
9851023
step = (end_angle - start_angle) / n_views
9861024
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
9871025

@@ -1064,6 +1102,7 @@ def custom_trajectory_2d_parallel(n_views,
10641102
"""
10651103
# Generate angles
10661104
end_angle = start_angle + math.pi
1105+
_check_n_views(n_views)
10671106
step = (end_angle - start_angle) / n_views
10681107
angles = start_angle + torch.arange(n_views, device=device, dtype=dtype) * step
10691108

@@ -1078,6 +1117,9 @@ def custom_trajectory_2d_parallel(n_views,
10781117
raise ValueError(f"det_origin_fn must return tensor of shape ({n_views}, 2), "
10791118
f"got {det_origin.shape}")
10801119

1120+
# Reject degenerate directions before normalization turns them into NaN
1121+
_check_ray_directions(ray_dir)
1122+
10811123
# Normalize ray directions
10821124
ray_dir = ray_dir / torch.norm(ray_dir, dim=1, keepdim=True)
10831125

Collapse file

‎docs/source/_static/custom.css‎

Copy file name to clipboardExpand all lines: docs/source/_static/custom.css
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ html[data-theme="dark"] {
1010
--pst-color-link-hover: #f2a541;
1111
}
1212

13+
/* Every page keeps the same three columns, so the content does not move when the top navigation
14+
switches pages. The two sidebars have the same width. */
15+
@media (min-width: 960px) {
16+
html .bd-sidebar-primary { --pst-sidebar-primary-width: var(--pst-sidebar-secondary); }
17+
}
18+
19+
/* Site navigation: sections in the text color, pages below them muted, the current page in the primary color. */
20+
.site-nav .toctree-l1 { margin-bottom: 0.15rem; }
21+
.site-nav .toctree-l1 > a { font-weight: 600; color: var(--pst-color-text-base); }
22+
.site-nav .toctree-l2 > a, .site-nav .toctree-l3 > a { color: var(--pst-color-text-muted); }
23+
.site-nav li > a:hover { color: var(--pst-color-link-hover); }
24+
.site-nav li.current > a, .site-nav li > a.current { color: var(--pst-color-primary); }
25+
/* The search page has no secondary sidebar and no article element. Keep its column empty and
26+
give it the article padding on wide screens. */
27+
@media (min-width: 1200px) {
28+
.bd-content:not(:has(> .bd-sidebar-secondary)) > .bd-article-container { margin-right: var(--pst-sidebar-secondary); }
29+
.bd-main .bd-content .bd-article-container .bd-search-container { padding-left: 2rem; padding-top: 1.5rem; }
30+
}
31+
1332
/* Landing page search box */
1433
.landing-search { margin: 0.5rem 0 1.75rem; }
1534
.landing-search input {
Collapse file

‎docs/source/_templates/sidebar-site-nav.html‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{# The whole documentation tree, so that every page shows the same sidebar. The branch of the current page is open. #}
2+
<nav class="bd-docs-nav bd-links site-nav" aria-label="{{ _('Site Navigation') }}">
3+
<div class="bd-toc-item navbar-nav">
4+
{{- generate_toctree_html(
5+
"sidebar",
6+
startdepth=0,
7+
show_nav_level=1,
8+
maxdepth=3,
9+
collapse=False,
10+
includehidden=True,
11+
titles_only=True
12+
)
13+
-}}
14+
</div>
15+
</nav>
Collapse file

‎docs/source/conf.py‎

Copy file name to clipboardExpand all lines: docs/source/conf.py
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,8 @@
7575
'footer_start': ['copyright', 'llms-links'],
7676
'footer_end': ['sphinx-version', 'theme-version'],
7777
}
78-
html_sidebars = {
79-
'index': [],
80-
'examples': [],
81-
'getting_started': [],
82-
'changelog': [],
83-
}
78+
# Every page shows the whole documentation tree, so the layout does not change between sections.
79+
html_sidebars = {'**': ['sidebar-site-nav.html']}
8480

8581

8682
def setup(app):
Collapse file

‎docs/source/index.rst‎

Copy file name to clipboardExpand all lines: docs/source/index.rst
-2Lines changed: 0 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
:html_theme.sidebar_secondary.remove:
2-
31
diffct
42
======
53

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.