Repository navigation
Conversation
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
from
October 19, 2026 07:55
0cbaf3f to
54a09b3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 39-repr-chop-complex-overflow #649 +/- ##
=================================================================
+ Coverage 99.12% 99.17% +0.05%
=================================================================
Files 108 108
Lines 34629 34692 +63
Branches 3985 3998 +13
=================================================================
+ Hits 34327 34407 +80
+ Misses 195 175 -20
- Partials 107 110 +3 🚀 New features to boost your workflow:
|
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
from
October 20, 2026 22:28
54a09b3 to
52b7238
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
2 times, most recently
from
October 21, 2026 08:38
be7cdde to
e969713
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
from
October 28, 2026 04:29
e969713 to
e2b6a44
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
from
October 28, 2026 13:21
e2b6a44 to
053460e
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
3 times, most recently
from
November 3, 2026 12:10
f2e2278 to
fddfd68
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
from
November 3, 2026 16:44
fddfd68 to
2ba78fb
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
from
November 3, 2026 20:07
2ba78fb to
a0e95e1
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
from
November 3, 2026 23:09
a0e95e1 to
44ef49d
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
2 times, most recently
from
November 10, 2026 17:12
66733ef to
857ba58
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
14 times, most recently
from
November 11, 2026 05:42
19ad055 to
c319ee4
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
from
November 12, 2026 06:15
c319ee4 to
6d8b00e
Compare
eriknw
force-pushed
the
39b-from-coo-broadcast-iso
branch
5 times, most recently
from
November 13, 2026 04:30
a4ec29f to
5cd82ef
Compare
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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, andfrom_coostored n copies of the value for it, which also turns offis_isofast paths downstream. (SuiteSparse 10.5.0 dropped the post-buildcheck that noticed all-equal values.)
Matrix.from_cooandVector.from_coonow 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 scalarvalue 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 andduplicate indices raise the same
ValueErrorwith the same message, andout-of-range indices raise the same
IndexOutOfBound. Withdup_opgiven, UDT values or dtypes, 0-length or 2-d arrays, and the vanilla backend,
the general path stays.
Matrix.buildis 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):
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_workerand takes the mask'ssparsity_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.