I am sorry for the tiny indication, but I found some typos in the documentation of Thrust.
At the Segmented Prefix Sums section,
[url]https://thrust.github.io/doc/group__segmentedprefixsums.html[/url]
in all sample codes for inclusive_scan_by_key, data[10] should be vals[10].