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 — Build iso from a stride-0 values array; document a bitmap BFS levels Vector by eriknw · Pull Request #649 · python-graphblas/python-graphblas

Conversation

@eriknw

@eriknw eriknw commented Oct 19, 2026

Copy link
Copy Markdown
Member

From Nib's letter of 2026-08-27 (items 1 and 2).

np.broadcast_to(np.float64(1), n) is the cheap way to spell n ones, and
from_coo stored n copies of the value for it, which also turns off
is_iso fast paths downstream. (SuiteSparse 10.5.0 dropped the post-build
check that noticed all-equal values.) Matrix.from_coo and
Vector.from_coo now take a 1-d ndarray of a built-in dtype with strides
(0,) and at least one element as its one value and build iso, as a scalar
value does. Everything else is what the array path gives: the dtype comes
from the array (an np.int32 array stays INT32, where the scalar np.int32(-3)
gives INT64), dtype= casts as NumPy casts the array, length mismatches and
duplicate indices raise the same ValueError with the same message, and
out-of-range indices raise the same IndexOutOfBound. With dup_op
given, UDT values or dtypes, 0-length or 2-d arrays, and the vanilla backend,
the general path stays. Matrix.build is unchanged.

A script comparing the two paths over 56160 builds (13 NumPy dtypes, 12
values, 9 dtype= choices, 0-d and 1-element sources, nvals mismatches,
duplicates, explicit shapes, out-of-range indices; Matrix and Vector) found
no difference in result, dtype, exception, message or warnings apart from
is_iso.

Measured (mlx, SuiteSparse 10.5.0, Apple M5 Pro, best of 3 or of 300):

nvals          nbytes              build              mxv plus_times
50,000,000     584.1 -> 202.7 MiB  326 -> 254 ms      16.2 -> 14.6 ms
1,000          12496 -> 4504 B     17.2 -> 19.4 us

with 651 -> 79 MiB of peak RSS above the inputs at 50M, the same as
values=1.0. The small build costs about 2 us more, as a scalar does.

The docs note (user guide, "Opaque Objects") shows a level BFS whose
levels Vector is pinned with sparsity_control = "bitmap", says why
(the masked assign leaves pending tuples that each read as a mask must
merge first) and what it costs (a bitmap cannot compact to full). It also
says to set the option once the Vector has an entry: on SuiteSparse 10.5.0
and 10.5.1, a masked scalar assign into an empty Vector (Method 05e)
rebuilds it from the mask with GB_dup_worker and takes the mask's
sparsity_control, so pinning the empty Vector first did nothing.
Reproduced on a 50 by 20000 grid, 20049 rounds: 0.234 s with "auto"
(825 rounds saw a sparse levels Vector) against 0.201 s pinned (none did),
ending at 8.58 against 7.63 MiB. Nib's third note needed no change: the
docs never offer RSS as a measure of what an object holds.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eriknw
eriknw added this pull request to stack #650 October 19, 2026 07:50
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from 0cbaf3f to 54a09b3 Compare October 19, 2026 07:55
@codecov

codecov Bot commented Oct 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.10%. Comparing base (f93fc94) to head (6d8b00e).

Additional details and impacted files
@@                        Coverage Diff                        @@
##           39-repr-chop-complex-overflow     #649      +/-   ##
=================================================================
+ Coverage                          98.89%   99.10%   +0.21%     
=================================================================
  Files                                108      108              
  Lines                              34583    34646      +63     
  Branches                            3981     3994      +13     
=================================================================
+ Hits                               34200    34337     +137     
+ Misses                               236      198      -38     
+ Partials                             147      111      -36     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from 54a09b3 to 52b7238 Compare October 20, 2026 22:28
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch 2 times, most recently from be7cdde to e969713 Compare October 21, 2026 08:38
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from e969713 to e2b6a44 Compare October 28, 2026 04:29
@eriknw
eriknw removed this pull request from stack #650 October 28, 2026 04:29
@eriknw
eriknw added this pull request to stack #653 October 28, 2026 04:30
@eriknw
eriknw removed this pull request from stack #653 October 28, 2026 04:31
@eriknw
eriknw added this pull request to stack #655 October 28, 2026 04:32
@eriknw
eriknw removed this pull request from stack #655 October 28, 2026 04:33
@eriknw
eriknw added this pull request to stack #657 October 28, 2026 04:33
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from e2b6a44 to 053460e Compare October 28, 2026 13:21
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch 3 times, most recently from f2e2278 to fddfd68 Compare November 3, 2026 12:10
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from fddfd68 to 2ba78fb Compare November 3, 2026 16:44
@eriknw
eriknw removed this pull request from stack #657 November 3, 2026 16:44
@eriknw
eriknw added this pull request to stack #660 November 3, 2026 16:45
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from 2ba78fb to a0e95e1 Compare November 3, 2026 20:07
@eriknw
eriknw removed this pull request from stack #660 November 3, 2026 23:09
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from a0e95e1 to 44ef49d Compare November 3, 2026 23:09
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch 3 times, most recently from 970142a to f87e3c1 Compare November 9, 2026 15:51
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch 2 times, most recently from 66733ef to 857ba58 Compare November 10, 2026 17:12
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch 14 times, most recently from 19ad055 to c319ee4 Compare November 11, 2026 05:42
@eriknw
eriknw removed this pull request from stack #666 November 12, 2026 06:13
@eriknw
eriknw changed the base branch from 39-repr-chop-complex-overflow to main November 12, 2026 06:14
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from c319ee4 to 6d8b00e Compare November 12, 2026 06:15
@eriknw
eriknw changed the base branch from main to 39-repr-chop-complex-overflow November 12, 2026 06:16
@eriknw
eriknw added this pull request to stack #670 November 12, 2026 06:17
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from 6d8b00e to c8ee855 Compare November 12, 2026 17:10
eriknw added 2 commits November 12, 2026 11:25
@eriknw
Build iso from a stride-0 values array in from_coo
48aeca9
np.broadcast_to(np.float64(1), n) is the cheap way to spell n ones, and
from_coo stored n copies of the value for it: GrB_Matrix_build needs a
contiguous array, so _CArray made one, and the result was not iso, which
turns off is_iso fast paths downstream. (SuiteSparse 10.5.0 dropped the
post-build check that used to notice all-equal values.)

Matrix.from_coo and Vector.from_coo now take a 1-d ndarray of a built-in
dtype with strides (0,) and at least one element as its one value, and
build with GxB_*_build_Scalar, as a scalar value does. Everything else
is what the array path gives: the dtype comes from the array (an
np.int32 array stays INT32, where the scalar np.int32(-3) gives INT64),
dtype= casts the one value as NumPy casts the array, the length mismatch
and the duplicate indices raise the same ValueError with the same
message, and out-of-range indices raise the same IndexOutOfBound. With
dup_op given, duplicates combine as for any values, so the general path
stays; so do UDT values or dtypes, 0-length and 2-d arrays, and the
vanilla backend.
The docstrings say so. Matrix.build itself is unchanged: on a Matrix
with entries the error would name GxB_Matrix_build_Scalar instead of
GrB_Matrix_build_FP64.

A script comparing the two paths over 13 NumPy dtypes, 12 values, 9
dtype= choices, 0-d and 1-element sources, nvals mismatches, duplicates,
explicit shapes and out-of-range indices (56160 builds, Matrix and
Vector) found no difference in result, dtype, exception, message or
warnings, apart from is_iso.

Measured on mlx (SuiteSparse 10.5.0, Apple M5 Pro, load average about 3),
best of 3 (best of 300 at the small size), shuffled tuples, 16 per row:

    nvals          nbytes            build              mxv plus_times
    50,000,000     584.1 -> 202.7 MiB  326 -> 254 ms    16.2 -> 14.6 ms
    1,000          12496 -> 4504 B     17.2 -> 19.4 us

and 651 -> 79 MiB of peak RSS above the inputs at 50M, the same as
values=1.0. The small build costs about 2 us more, the same as a scalar
value.
@eriknw
Document pinning a BFS levels Vector to bitmap
9be95b5
A Vector written by a masked assign and read back as a complemented
mask every round, like the levels of a level-synchronous BFS, pays for
being sparse: the assign leaves pending tuples, and each read as a mask
makes SuiteSparse merge them first ("wait: build pending tuples ... add
pending tuples into existing A" in the burble). sparsity_control =
"bitmap" takes the assign in place. Nib (BrassGlyph) measured GAP-road
falling from 1.65 s to 0.85 s with it, level with LAGraph, which pins
its visited vector the same way.

Reproduced on mlx (SuiteSparse 10.5.0) with a 50 by 20000 grid from a
corner, 20049 rounds, best of 2: 0.234 s with "auto", where 825 rounds
saw a sparse levels Vector, and 0.201 s pinned to bitmap, where none
did. The levels Vector ends at 8.58 MiB as a bitmap against 7.63 MiB
full. The note gives no numbers, since they depend on the graph.

It also says to set the option once the Vector has an entry. On
SuiteSparse 10.5.0 and 10.5.1 a masked scalar assign into an empty
Vector (Method 05e, C empty <M,struct> = scalar) rebuilds it with
GB_dup_worker from the mask, which copies the mask's sparsity_control,
so pinning the empty Vector and then assigning under a mask ended
"auto", sparse, and as slow as before.

The docs say nothing about RSS as a measure of what an object holds, so
Nib's third note needs no change.
@eriknw
eriknw force-pushed the 39b-from-coo-broadcast-iso branch from c8ee855 to 9be95b5 Compare November 12, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@eriknw
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — 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.