feat(examples/ai-finetune)#182
Conversation
Greptile SummaryThis PR adds cross-cloud AI fine-tuning and tuned-model gateway routing.
Confidence Score: 2/5The PR is not safe to merge until fine-tuning updates are reconciled correctly and AWS/Azure stop silently ignoring the requested tuning method. Accepted configurations can report successful updates while retaining stale tuned artifacts and routes, and AWS or Azure deployments requesting DPO or LoRA can silently train with a different provider-default method. crates/alien-core/src/resources/ai.rs, crates/alien-infra/src/ai/aws.rs, crates/alien-infra/src/ai/azure.rs, crates/alien-infra/src/ai/gcp.rs
|
| Filename | Overview |
|---|---|
| crates/alien-core/src/resources/ai.rs | Adds the fine-tuning resource contract, but update validation permits configuration changes that no-op provider update handlers do not reconcile. |
| crates/alien-infra/src/ai/aws.rs | Adds the Bedrock tuning state machine, but silently collapses all requested tuning methods to the same request and performs no-op updates. |
| crates/alien-infra/src/ai/azure.rs | Adds Foundry account, tuning, and deployment phases, but does not forward or reject the requested tuning method. |
| crates/alien-infra/src/ai/gcp.rs | Adds Vertex tuning with explicit unsupported-method rejection, though its no-op update path participates in the incomplete update-validation defect. |
| crates/alien-gateway/src/router.rs | Adds exact-match tuned-model routing while preserving the existing curated catalog paths. |
| crates/alien-azure-clients/src/azure/openai_finetuning.rs | Adds the Foundry data-plane client and scoped authentication, but its request shape has no field through which the selected tuning method can be expressed. |
| crates/alien-aws-clients/src/aws/bedrock.rs | Adds signed Bedrock customization-job create and polling operations with structured status and error handling. |
| packages/core/src/ai.ts | Adds the TypeScript fine-tuning builder and forwards all generated fine-tuning options into the resource configuration. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Spec["AI finetune specification"] --> Controller{"Cloud controller"}
Controller -->|AWS| Bedrock["Bedrock tuning job"]
Controller -->|GCP| Vertex["Vertex tuning job"]
Controller -->|Azure| Foundry["Foundry tuning job"]
Bedrock --> Artifact["Tuned artifact / deployment"]
Vertex --> Artifact
Foundry --> Artifact
Artifact --> Binding["AI binding with served and upstream IDs"]
Binding --> Gateway["Gateway tuned-model route"]
Gateway --> Inference["Provider inference endpoint"]
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
crates/alien-core/src/resources/ai.rs:216-225
**Fine-tuning updates retain stale state**
When an existing AI resource changes `trainingKey`, `method`, or `servedModelId`, or adds or removes `finetune`, this validation accepts the update while the provider update handlers return directly to `Ready` without reconciling the tuning job or binding. The deployment reports success but continues serving the previous tuned artifact under the previous route, and newly added fine-tuning is never performed.
### Issue 2 of 2
crates/alien-infra/src/ai/aws.rs:23-28
**Requested tuning method is discarded**
When an AWS or Azure AI resource requests DPO or LoRA, the AWS controller maps every method to the same request without technique-specific hyperparameters, while Azure submits only the base model and training file. The deployment can therefore complete using the provider-default technique instead of the method selected in the public configuration.
Reviews (1): Last reviewed commit: "feat(examples/finetune)" | Re-trigger Greptile
| if let (Some(old), Some(new)) = (&self.finetune, &new_ai.finetune) { | ||
| if old.base_model != new.base_model || old.training_data != new.training_data { | ||
| return Err(AlienError::new(ErrorData::InvalidResourceUpdate { | ||
| resource_id: self.id.clone(), | ||
| reason: "finetune 'baseModel' and 'trainingData' are immutable; \ | ||
| create a new AI resource to retrain" | ||
| .to_string(), | ||
| })); | ||
| } | ||
| } |
There was a problem hiding this comment.
Fine-tuning updates retain stale state
When an existing AI resource changes trainingKey, method, or servedModelId, or adds or removes finetune, this validation accepts the update while the provider update handlers return directly to Ready without reconciling the tuning job or binding. The deployment reports success but continues serving the previous tuned artifact under the previous route, and newly added fine-tuning is never performed.
Knowledge Base Used: Provisioning Infra: Reconciliation Engine and IaC Generators
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/alien-core/src/resources/ai.rs
Line: 216-225
Comment:
**Fine-tuning updates retain stale state**
When an existing AI resource changes `trainingKey`, `method`, or `servedModelId`, or adds or removes `finetune`, this validation accepts the update while the provider update handlers return directly to `Ready` without reconciling the tuning job or binding. The deployment reports success but continues serving the previous tuned artifact under the previous route, and newly added fine-tuning is never performed.
**Knowledge Base Used:** [Provisioning Infra: Reconciliation Engine and IaC Generators](https://app.greptile.com/alien/-/custom-context/knowledge-base/alienplatform/alien/-/docs/provisioning-infra.md)
How can I resolve this? If you propose a fix, please make it concise.| /// Bedrock `customizationType` for a supervised / preference / LoRA fine-tune. | ||
| /// Bedrock's public model-customization API exposes `FINE_TUNING`; the specific | ||
| /// technique (SFT vs DPO vs LoRA) is selected per base model via hyperparameters, | ||
| /// not a distinct customizationType, so all `FinetuneMethod` variants map here. | ||
| fn bedrock_customization_type(_method: FinetuneMethod) -> &'static str { | ||
| "FINE_TUNING" |
There was a problem hiding this comment.
Requested tuning method is discarded
When an AWS or Azure AI resource requests DPO or LoRA, the AWS controller maps every method to the same request without technique-specific hyperparameters, while Azure submits only the base model and training file. The deployment can therefore complete using the provider-default technique instead of the method selected in the public configuration.
Knowledge Base Used: Provisioning Infra: Reconciliation Engine and IaC Generators
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/alien-infra/src/ai/aws.rs
Line: 23-28
Comment:
**Requested tuning method is discarded**
When an AWS or Azure AI resource requests DPO or LoRA, the AWS controller maps every method to the same request without technique-specific hyperparameters, while Azure submits only the base model and training file. The deployment can therefore complete using the provider-default technique instead of the method selected in the public configuration.
**Knowledge Base Used:** [Provisioning Infra: Reconciliation Engine and IaC Generators](https://app.greptile.com/alien/-/custom-context/knowledge-base/alienplatform/alien/-/docs/provisioning-infra.md)
How can I resolve this? If you propose a fix, please make it concise.
No description provided.