{"record":{"id":"edb3ba32fcacd448","repo":"microsoft/garnet","slug":"vectorsetquantizationtaskcount-should-be-in-range","errorCode":null,"errorMessage":"VectorSetQuantizationTaskCount should be in range [0,{Environment.ProcessorCount}]!","messagePattern":"VectorSetQuantizationTaskCount should be in range \\[0,(.+?)\\]!","errorType":"validation","errorClass":"GarnetException","httpStatus":null,"severity":"error","filePath":"libs/server/Resp/Vector/VectorManager.cs","lineNumber":226,"sourceCode":"            cleanupTaskChannel = new();\n            requestCleanupTaskChannel = new();\n            requestDropTaskChannel = new();\n\n            cleanupTask = RunCleanupTaskAsync();\n            requestCleanupTask = RunRequestCleanupTaskAsync();\n            requestDropTask = RunRequestDropTaskAsync();\n\n            requestedDrops = new();\n\n            potentiallyDeleted = [];\n\n            recoveredIndexes = new();\n            recoveredMetadata = new();\n\n            quantizationChannel = Channel.CreateUnbounded<QuantizationState>(new() { SingleWriter = false, SingleReader = false, AllowSynchronousContinuations = false });\n\n            if (serverOptions.VectorSetQuantizationTaskCount < 0 || serverOptions.VectorSetQuantizationTaskCount > Environment.ProcessorCount)\n                throw new GarnetException($\"VectorSetQuantizationTaskCount should be in range [0,{Environment.ProcessorCount}]!\");\n            var vectorSetQuantizationTaskCount = serverOptions.VectorSetQuantizationTaskCount == 0 ? Environment.ProcessorCount : serverOptions.VectorSetQuantizationTaskCount;\n            quantizationTasks = new Task[vectorSetQuantizationTaskCount];\n            Array.Fill(quantizationTasks, Task.CompletedTask);\n\n            logger?.LogInformation(\"Created VectorManager\");\n        }\n\n        /// <summary>\n        /// Load state necessary for VectorManager from main store.\n        /// </summary>\n        public void Initialize()\n        {\n            if (!IsEnabled || initialized) return;\n\n            initialized = true;\n\n            // Come up empty, with one ContextMetadata\n            lock (this)","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Resp/Vector/VectorManager.cs#L208-L244","documentation":"Startup validation in the VectorManager constructor: VectorSetQuantizationTaskCount must be 0 (=> use Environment.ProcessorCount) or in [1, Environment.ProcessorCount]. The value sizes the quantizationTasks array used for background quantization of Vector Set data. As with the replay count, the CLI validator only allows [0, int.MaxValue] so the upper-bound check is enforced here at construction time.","triggerScenarios":"Launching with --enable-vector-set-preview and --vector-set-quantization-task-count N where N < 0 or N > Environment.ProcessorCount. Thrown at VectorManager.cs:225-226.","commonSituations":"Porting a config tuned for a high-core machine to a smaller instance; container CPU pinning reducing visible cores below the configured count.","solutions":["Set --vector-set-quantization-task-count to 0 to auto-match ProcessorCount.","Otherwise choose a value in [1, Environment.ProcessorCount] for the deployment target.","Verify Environment.ProcessorCount inside the container/runtime before pinning a value."],"exampleFix":"# before (fails on 8 cores)\ngarnet-server --enable-vector-set-preview --vector-set-quantization-task-count 64\n\n# after\ngarnet-server --enable-vector-set-preview --vector-set-quantization-task-count 0","handlingStrategy":"validation","validationCode":"var qCount = options.VectorSetQuantizationTaskCount;\nif (qCount < 0 || qCount > Environment.ProcessorCount) {\n    throw new ArgumentOutOfRangeException(nameof(qCount), $\"Must be 0 or in [1, {Environment.ProcessorCount}]\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to 0 so the value tracks the deployment's real CPU count.","Validate the value against Environment.ProcessorCount in config pipelines."],"tags":["garnet","vector-set","config","dotnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}