MCPcopy Create free account
hub / github.com/antirez/ds4 / ds4_dist_parse_cli_arg

Function ds4_dist_parse_cli_arg

ds4_distributed.c:8144–8278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8142
8143void ds4_dist_usage(FILE *fp) {
8144 fprintf(fp,
8145 " --role ROLE\n"
8146 " Distributed role: coordinator or worker.\n"
8147 " --layers A:B\n"
8148 " Inclusive distributed layer slice, e.g. 10:20 or 21:output.\n"
8149 " --listen HOST PORT\n"
8150 " Coordinator TCP listen address. Workers may later use it to force their data listener.\n"
8151 " --coordinator HOST PORT\n"
8152 " Coordinator TCP address for --role worker.\n"
8153 " --dist-prefill-chunk N\n"
8154 " Coordinator prefill pipeline chunk size. Default: session cap, normally 4096.\n"
8155 " Non-default values are experimental and can change logits unless validated.\n"
8156 " --dist-prefill-window N\n"
8157 " Coordinator max end-to-end prefill chunks in flight. Default: workers+2, capped at 8.\n"
8158 " --dist-activation-bits N\n"
8159 " Coordinator hidden-state transport width: 32, 16, or 8. Default: 32.\n"
8160 " --dist-replay-check\n"
8161 " Coordinator diagnostic: reset and replay the prompt, then compare logits.\n"
8162 " --debug\n"
8163 " Print coordinator route/debug logs. Workers keep their normal logs without this.\n"
8164 );
8165}
8166
8167ds4_dist_cli_parse_result ds4_dist_parse_cli_arg(
8168 const char *arg,
8169 int *index,
8170 int argc,
8171 char **argv,
8172 ds4_dist_options *opt,
8173 char *err,
8174 size_t errlen) {
8175 if (!arg) return DS4_DIST_CLI_NOT_MATCHED;
8176 if (!strcmp(arg, "--role")) {
8177 const char *role = dist_cli_need_arg(index, argc, argv, arg, err, errlen);
8178 if (!role) return DS4_DIST_CLI_ERROR;
8179 if (!opt || !dist_parse_role(role, &opt->role)) {
8180 if (errlen) snprintf(err, errlen,
8181 "invalid distributed role: %s (valid roles: none, coordinator, worker)",
8182 role);
8183 return DS4_DIST_CLI_ERROR;
8184 }
8185 return DS4_DIST_CLI_MATCHED;
8186 }
8187 if (!strcmp(arg, "--layers")) {
8188 const char *layers = dist_cli_need_arg(index, argc, argv, arg, err, errlen);
8189 if (!layers) return DS4_DIST_CLI_ERROR;
8190 if (!opt) {
8191 if (errlen) snprintf(err, errlen, "missing distributed options");
8192 return DS4_DIST_CLI_ERROR;
8193 }
8194 if (!dist_parse_layers(layers, &opt->layers, err, errlen)) {
8195 char detail[160];
8196 if (errlen && err[0] != '\0') {
8197 snprintf(detail, sizeof(detail), "%s", err);
8198 snprintf(err, errlen, "invalid --layers %s: %s", layers, detail);
8199 }
8200 return DS4_DIST_CLI_ERROR;
8201 }

Callers 5

parse_optionsFunction · 0.85
parse_optionsFunction · 0.85
parse_optionsFunction · 0.85
parse_optionsFunction · 0.85
parse_optionsFunction · 0.85

Calls 6

dist_cli_need_argFunction · 0.85
dist_parse_roleFunction · 0.85
dist_parse_layersFunction · 0.85
dist_cli_parse_portFunction · 0.85
dist_parse_positive_u32Function · 0.85

Tested by

no test coverage detected