You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DataOperationsCatalog.Cache: reading a vector column while the cache is still filling can throw ArgumentOutOfRangeException ("valuesCount") from CacheDataView.ColumnCache.ImplVec.Fetch (Microsoft.ML 5.0.1, arm64) #7884
A cursor that reads a vector column of mlContext.Data.Cache(view) straight after the call, while the cache is still being filled, intermittently throws
System.ArgumentOutOfRangeException: If specified, must be non-negative. (Parameter 'valuesCount')
at Microsoft.ML.Data.CacheDataView.ColumnCache.ImplVec`1.Fetch(Int32 idx, VBuffer`1& value)
The rows are fine — the same scan succeeds in other runs on the same data — so a row is read before it is completely written.
Reproduction
Microsoft.ML 5.0.1, .NET 10.0.402, macOS arm64. A text file of 4,000,000 rows, a,b,c,d,y with four random floats and a class number:
varml=newMLContext(1);varloader=ml.Data.CreateTextLoader(newTextLoader.Options{HasHeader=true,Separators=[','],Columns=[newTextLoader.Column("Features",DataKind.Single,0,3),newTextLoader.Column("Label",DataKind.Single,4)],});varcached=ml.Data.Cache(loader.Load(path));varcolumn=cached.Schema["Features"];usingvarcursor=cached.GetRowCursor([column]);varget=cursor.GetGetter<VBuffer<float>>(column);VBuffer<float>value=default;while(cursor.MoveNext())get(refvalue);// intermittently throws in Fetch
Each run builds a fresh MLContext, loader and cache. Measured: more than a quarter of 20 runs threw. With an in-memory source (LoadFromEnumerable, 3,000,000 rows) the rate is lower (about 1 run in 30), so it depends on the reader having to wait for the filler.
What avoids it
A cursor over all columns that reads no value, run to its end before the real scan (using var c = cached.GetRowCursor(cached.Schema); while (c.MoveNext()) { }), gave 0 failures in 20 runs on the text file. A cursor over no columns did not help (7 in 80 failures on the enumerable source), and neither did a cursor reading only the scalar label.
Notes
Not verified on x64: the failure may depend on the weaker memory ordering of arm64 (the reader seeing the row count before the row's offsets). A consumer that trains on tables of millions of rows meets it as a training run dying at the start of its search about half the time.
Workaround in the consumer: cache through a helper that fills the copy (the all-column no-read pass above) before returning it.
Activity